I have created in NS two nodes connected over a 4Mbps connection with a delay of 10ms.
Node1 is a transmitter and Node2 is a receiver.
The transmitter node sends packets at a rate of 10ms (0.01s).
Packet transmission starts at 2s in the simulation.
Considering the above, as long as my packets are < 5000 bytes in size I am below the 4Mbps limit of the connection.
What I am trying to understand is what happens when I increase packet size beyond 5000 bytes.
So, if i increase packet size to 8000 bytes here is what happens, using NAM for the animation
The first packet is sent at 2s and the second is sent at 2.016s. Note that a packet is sent every 0.01s, so the 2nd packet should have been sent at 2.01s. Also notice that we are currently at 2.02+ seconds in the simulation, so the third packet should have already left Node1.
NAM's documentation says that
Queued packets are shown as little squares.[...] Dropped packets are shown as falling rotating squares, and disappear at the end of the screen.
So I am not having any dropped packets?
Using XGRAPH for the simulation we get this graph
Now, I can't quite understand the following:
- What is the relation between the packet arrows length and the connection?
- What does the fact that packet transmission does not happen at the set interval of 10ms mean?
- What does the fact that I am pushing a transmission rate above 4Mbps mean for a connection limited to 4Mbps?
- Why, in the graph, I see spikes and why do they go beyond 4Mbps?
UPDATE: Added the .tcl
script
set ns [new Simulator]
set nf [open lab1.nam w]
$ns namtrace-all $nf
set xf [open lab1.tr w]
proc record {} {
global sink xf
set ns [Simulator instance]
set time 0.12
set bw [$sink set bytes_]
set now [$ns now]
puts $xf "$now [expr ((($bw/$time)*8)/1000000)]"
$sink set bytes_ 0
$ns at [expr $now+$time] "record"
}
proc finish {} {
global ns nf xf
$ns flush-trace
close $nf
close $xf
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
$ns duplex-link $n0 $n1 4Mb 10ms DropTail
set udp0 [new Agent/UDP]
$udp0 set packetSize_ 1500
$ns attach-agent $n0 $udp0
set traffic0 [new Application/Traffic/CBR]
$traffic0 set packetSize_ 1500
$traffic0 set interval_ 0.01
$traffic0 attach-agent $udp0
set sink [new Agent/LossMonitor]
$ns attach-agent $n1 $sink
$ns connect $udp0 $sink
$ns at 0.0 "record"
$ns at 2.0 "$traffic0 start"
$ns at 10.0 "$traffic0 stop"
$ns at 12.0 "finish"
$ns run
UPDATE2:
Dropped packets begin to show in the simulation animation after some time passes and not immediately, it turns out. So for example I'll have to run the simulation for about 3-4 seconds before dropped packets begin to show.