A Agent/TCP/Reno or Agent/TCP/Tahoe needs to be attached to some Node (see figure)
Also, a Agent/TCP/Reno or Agent/TCP/Tahoe need to be associated with a Agent/TCP/Sink !
A Agent/TCP/Sink sends ACK packets and needs to be attached to some Node (see figure)
A Application/FTP needs to be attached to some TCP agent (see figure)
The Application/FTP does not need to be asscoiated with a receiver:
|
The Simulator object is the network simulation system and provides many methods needed to construct the network simulation.
new Simulator |
set ns [new Simulator] |
You only need one Simulator object
If you look in the source of a NS script, you will always see this statement at the top of the program !
The following expression will return a Node object in NS that you use to simulate ONE router:
set ns [new Simulator] [$ns node] |
set ns [new Simulator] set n0 [$ns node] |
Example: create Nodes n(0), n(1), ..., n(9):
for {set i 0} {$i < 10} {incr i} { set n($i) [$ns node] } |
BTW, a duplex link is actually 2 simplex links..
Units: b (#bits/sec), Mb (#Megabits/sec)
Units: s (seconds), ms (milliseconds)
Some commonly used values:
We will mostly use DropTail
set n0 [$ns node] set n1 [$ns node] $ns duplex-link $n0 $n1 10Mb 10ms DropTail |
For example, the bottleneck link is f times the normal bandwidth in other network links
set bw 10 set f 0.5 $ns duplex-link $n0 $n1 [expr $bw]Mb 10ms DropTail $ns duplex-link $n0 $n1 [expr $f*$bw]Mb 10ms DropTail |
$ns duplex-link $n0 $n1 10Mb 10ms DropTail $ns queue-limit $n0 $n1 10 |
Queue/DropTail set queue-limit $n0 $n1 10 |
 
|
Example:
set tcp1 [new Agent/TCP/Reno] |
 
|
Example:
set sink1 [new Agent/TCPSink] |
They can be attached to any Node object
$ns attach-agent NODE TCP-Agent |
set ns [new Simulator] set node1 [$ns node] set tcp1 [new Agent/TCP/Reno] $ns attach-agent $node1 $tcp1 |
We need to tell NS the destination of each sending Transport Agent.
The destination must be a receiving Transport Agent.
set ns [new Simulator] set tcp1 [new Agent/TCP/Reno] set sink1 [new Agent/TCPSink] (tcp1 and sink1 must also be attached to nodes, this step is omitted) $ns connect $tcp1 $sink1 |
This will make NS route all packets from the source tcp1 towards the destination sink1
set tcp1 [new Agent/TCP/Reno] $tcp1 set packetSize_ 552 |
Example:
set tcp1 [new Agent/TCP/Reno] set pksize [$tcp1 set packetSize_] // get packetzise used |
new Application/FTP |
set ftp1 [new Application/FTP] |
set tcp1 [new Agent/TCP/Reno] set ftp1 [new Application/FTP] $ftp1 attach-agent $tcp1 |
set ftp1 [new Application/FTP] $ftp1 start // Start the FTP application |
set ftp1 [new Application/FTP] $ftp1 stop // Stop the FTP application |
When the FTP traffic generator stops generating traffic, TCP will have no data to send and will "go quiet".
You can start the FTP again after stopping it.