37.5.2 Multihomed Example

	 # This example demonstrates multihoming. Two SCTP endpoints, each
	 # with 2 interfaces, are directly connected between each pair of
	 # interfaces.  In the middle of the association, a change primary
	 # is done. Running nam helps to visualize the multihomed
	 # architecture.
	 #
	 #       host0_if0      O===========O    host1_if0
	 #                     /             \
	 #       host0_core   O               O  host1_core
	 #                     \             /
	 #       host0_if1      O===========O    host1_if1
	 Trace set show\_sctphdr\_ 1

	 set ns [new Simulator]
	 set nf [open sctp.nam w]
	 \$ns namtrace-all \$nf
	 set allchan [open all.tr w]
	 \$ns trace-all \$allchan

	 proc finish {} {
	    exec nam sctp.nam &
	    exit 0
	 }

	 set host0\_core [\$ns node]
	 set host0\_if0 [\$ns node]
	 set host0\_if1 [\$ns node]
	 \$host0\_core color Red
	 \$host0\_if0 color Red
	 \$host0\_if1 color Red
	 \$ns multihome-add-interface \$host0\_core \$host0\_if0
	 \$ns multihome-add-interface \$host0\_core \$host0\_if1

	 set host1\_core [\$ns node]
	 set host1\_if0 [\$ns node]
	 set host1\_if1 [\$ns node]
	 \$host1\_core color Blue
	 \$host1\_if0 color Blue
	 \$host1\_if1 color Blue
	 \$ns multihome-add-interface \$host1\_core \$host1\_if0
	 \$ns multihome-add-interface \$host1\_core \$host1\_if1

	 \$ns duplex-link \$host0\_if0 \$host1\_if0 .5Mb 200ms DropTail
	 \$ns duplex-link \$host0\_if1 \$host1\_if1 .5Mb 200ms DropTail

	 set sctp0 [new Agent/SCTP]
	 \$ns multihome-attach-agent \$host0\_core \$sctp0

	 set trace\_ch [open trace.sctp w]
	 \$sctp0 set trace\_all\_ 1           # print all on a single trace event;
	 \$sctp0 trace rto\_
	 \$sctp0 trace errorCount\_
	 \$sctp0 attach \$trace\_ch

	 set sctp1 [new Agent/SCTP]
	 \$ns multihome-attach-agent \$host1\_core \$sctp1

	 \$ns connect \$sctp0 \$sctp1

	 set ftp0 [new Application/FTP]
	 \$ftp0 attach-agent \$sctp0

	 \$sctp0 set-primary-destination \$host1\_if0 # set primary before association starts;

	 \$ns at 7.5 "\$sctp0 set-primary-destination \$host1\_if1" # change primary;
	 \$ns at 7.5 "\$sctp0 print cwnd\_" # print all dests' cwnds at time 7.5;

	 \$ns at 0.5 "\$ftp0 start"
	 \$ns at 9.5 "\$ftp0 stop"
	 \$ns at 10.0 "finish"

	 \$ns run



Tom Henderson 2014-12-17