Listing 1. SCTP Simulation Script
# This needs to be set for tracing SCTP packets
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 {} {
global ns nf allchan trace_ch
$ns flush-trace
close $nf
close $allchan
close $trace_ch
set PERL "/usr/bin/perl"
set USERHOME [exec env | grep "^HOME" | sed /^HOME=/s/^HOME=//]
set NSHOME "$USERHOME/ns-allinone-2.1b8"
set XGRAPH "$NSHOME/bin/xgraph"
set GETRC "$NSHOME/ns-2.1b8/bin/getrc"
set SETFID "$NSHOME/ns-2.1b8/bin/set_flow_id"
set RAW2XG "$NSHOME/ns-2.1b8/bin/raw2xg"
set RAW2XG_SCTP "$NSHOME/ns-2.1b8/bin/raw2xg-sctp"
exec $PERL $GETRC -s 0 -d 1 all.tr > all.tr.sctp
exec $PERL $GETRC -s 1 -d 0 all.tr >> all.tr.sctp
exec $PERL $SETFID -m all.tr.sctp | \
$PERL $RAW2XG_SCTP -A -q -t SCTP | \
$XGRAPH -bb -tk -nl -m -x time -y packets &
exec nam sctp.nam &
exit 0
}
set false 0
set true 1
set n0 [$ns node]
set n1 [$ns node]
$ns duplex-link $n0 $n1 .5Mb 300ms DropTail
$ns duplex-link-op $n0 $n1 orient right
$ns queue-limit $n0 $n1 93000
set err [new ErrorModel/List]
$err droplist {15}
$ns lossmodel $err $n0 $n1
set sctp0 [new Agent/SCTP]
$ns attach-agent $n0 $sctp0
$sctp0 set fid_ 0
$sctp0 set debugMask_ 0x00303000 # u can use -1 to turn on everything
$sctp0 set debugFileIndex_ 0
$sctp0 set mtu_ 1500
$sctp0 set dataChunkSize_ 1448
$sctp0 set numOutStreams_ 1
$sctp0 set initialCwndMultiplier_ 2
$sctp0 set useMaxBurst_ $true
set trace_ch [open trace.sctp w]
$sctp0 set trace_all_oneline_ 0 # do not trace all variables
$sctp0 trace cwnd_
$sctp0 attach $trace_ch
set sctp1 [new Agent/SCTP]
$ns attach-agent $n1 $sctp1
$sctp1 set debugMask_ -1
$sctp1 set debugFileIndex_ 1
$sctp1 set mtu_ 1500
$sctp1 set initialRwnd_ 65536
$sctp1 set useDelayedSacks_ $false
$ns color 0 Red
$ns color 1 Blue
$ns connect $sctp0 $sctp1
set ftp0 [new Application/FTP]
$ftp0 attach-agent $sctp0
$ns at 0.5 "$ftp0 start"
$ns at 4.5 "$ftp0 stop"
$ns at 5.0 "finish"
$ns run