I've been trying to run a bus topology code using LAN but I keep getting an error
warning: no class variable LanRouter::debug_
see tcl-object.tcl in tclcl for info about this warning."
I've tried to change the code a bit and also include the line
LanRouter set debug_ 0
That line just makes the code not run at all in linux, it just does nothing. What can I do to resolve this issue ?
set nf [open out.nam w]
$ns namtrace-all $nf
proc finish {} {
global ns nf
$ns flush-trace
close $nf
#Executenam on the trace file
exec nam out.nam &
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set lan0 [$ns newLan "$n0 $n1 $n2 $n3 $n4" 0.5Mb 40ms LL Queue/DropTail MAC/Csma/Cd Channel]
set tcp0 [new Agent/TCP]
$tcp0 set class_ 1
$ns attach-agent $n1 $tcp0
set sink0 [new Agent/TCPSink]
$ns attach-agent $n3 $sink0
$ns connect $tcp0 $sink0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.01
$cbr0 attach-agent $tcp0
$ns at 0.5 "$cbr0 start"
$ns at 4.5 "$cbr0 stop"
$ns at 5.0 "finish"
$ns run
First : A warning is not an error. A warning is an informational text.
The setting LanRouter set debug_ 0 should be e.g. at "line 1" .....
# http://forum.shiburaj.com/viewtopic.php?f=9&t=11&sid=0490c83d0f777154e467deef7ec3fb74
# New file name : Bus-topo-1.tcl
#**************************************************#
# Aim : To monitor traffic for Bus topology using NS2
#**************************************************#
#LanRouter set debug_ 1
LanRouter set debug_ 0
#Create a simulator object
set ns [new Simulator]
#Open the nam trace file
set nf [open out.nam w]
$ns namtrace-all $nf
Link, Bus-topo-1.tcl https://www.dropbox.com/s/ymkrtrudd1q9wiy/Bus-topo-1.tcl?dl=0
All ~3500 ns2 simulations https://drive.google.com/drive/folders/0B7S255p3kFXNSmRYb2lGcDRUdWs?usp=sharing
Related
This simulation is set to work for 10 seconds but stops at 4.5 when the FTP is supposed to start sending packets. would you please help me fix it?
I have been working with NS2 for 3 hours. I am a hell of a noob right now.
#Creating a simulator object
set ns [new Simulator]
global $ns
set traceFile [open output.tr w]
$ns trace-all $traceFile
set namFile [open output.nam w]
$ns namtrace-all $namFile
#Defining the finish procedure
proc finish {} {
global ns namFile traceFile fert
$ns flush-trace
close $namFile
close $traceFile
exec nam output.nam &
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
set n6 [$ns node]
#for {set i 0} {$i<5} {incr i} {
#set n($i) [$ns node]
#}
#Creating the links
$ns duplex-link $n0 $n1 1Mb 20ms DropTail
$ns duplex-link $n0 $n2 1Mb 20ms DropTail
$ns duplex-link $n1 $n3 1Mb 20ms DropTail
$ns duplex-link $n2 $n3 1Mb 20ms DropTail
$ns duplex-link $n2 $n4 1Mb 20ms DropTail
$ns duplex-link $n2 $n6 1Mb 20ms DropTail
$ns duplex-link $n4 $n6 1Mb 20ms DropTail
$ns duplex-link $n4 $n5 1Mb 20ms DropTail
#Topology
$ns duplex-link-op $n0 $n1 orient down
$ns duplex-link-op $n0 $n2 orient right
$ns duplex-link-op $n1 $n3 orient right
$ns duplex-link-op $n2 $n3 orient down
$ns duplex-link-op $n2 $n4 orient right
$ns duplex-link-op $n2 $n6 orient right-down
$ns duplex-link-op $n4 $n5 orient right-down
$ns duplex-link-op $n4 $n6 orient down
#Agents - Attach Agents - SInk and Null connetions
set udp0 [new Agent/UDP]
set tcp3 [new Agent/TCP]
set null4 [new Agent/Null]
set sink5 [new Agent/TCPSink]
$ns attach-agent $n0 $udp0
$ns attach-agent $n3 $tcp3
$ns attach-agent $n4 $null4
$ns connect $udp0 $null4
$ns connect $tcp3 $sink5
#CBR over UDP connection
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
$cbr0 set type_ CBR
$cbr0 set packet_size_ 1500
$cbr0 set rate_ 830kb
#FTP over TCP connection
set ftp3 [new Application/FTP]
$ftp3 attach-agent $tcp3
$ftp3 set type_ FTP
#Queue Limit of n2-n4 and n4-n5
$ns queue-limit $n2 $n4 30
$ns queue-limit $n4 $n5 20
#Assigning a link variable for the link between n4 and n5
#Monitoring
set mon [open "mon.txt" w]
set qmon [$ns monitor-queue $n2 $n4 $mon 0.01]
[$ns link $n2 $n4] queue-sample-timeout
#set qmon24 [$ns monitor-queue $n2 $n4 "" 0.01]
#............................................
set link01 [$ns link $n2 $n3]
# Create monitor
set fmonitor [$ns makeflowmon Fid]
$ns attach-fmon $link01 $fmonitor
set drop_count [$fmonitor set parrivals_]
#............................................
proc mon { } {
global ns qmon
set t [$ns now]
puts "$t [$qmon set pkts_]"
$ns at [expr $t + 0.5] "mon"
}
#Link Down and Up at 5.0 and 7.0
$ns rtmodel-at 5.0 down $n2 $n4
$ns rtmodel-at 7.0 up $n2 $n4
#$ns rtproto LS
$ns at 0 "mon"
$ns color cbr "red"
$ns at 2.0 "$cbr0 start"
$ns at 4.5 "$ftp3 start"
$ns at 8.0 "$cbr0 stop"
$ns at 9.0 "$ftp3 stop"
$ns at 10.0 "finish"
$ns run
And another question. What is a link queue? I gotta monitor the queue of a link between two nodes for my project but I don't understand the concept of a link queue! oh and one more thing. The Nam doesn't start automatically and I get this:
Classfier::no-slot{} default handler (tcl/lib/ns-lib.tcl) ---
_o21: no target for slot 4294967295
_o21 type: Classifier/Hash/Dest
content dump:
classifier _o21
0 offset
0 shift
1073741823 mask
1 slots
slot 3: _o196 (Classifier/Port)
-1 default
Classfier::no-slot{} default handler
The error "Classfier::no-slot{} default handler .." indicate coding errors (or a too complex file.)
Besides that, the error causes the simulation not to finish.
EDIT : The typical ways to have "mixed traffic" → cbr, tcp, udp, ftp ... see examples https://www.dropbox.com/s/63ultpb20ugqlvf/new-A-ex.tar.gz?dl=0
A primitive fix : With ftp entries commented out, your simulation ends OK, and the NAM window opens. Snippet :
#FTP over TCP connection
#set ftp3 [new Application/FTP] ;# edited
#$ftp3 attach-agent $tcp3 ;# edited
#$ftp3 set type_ FTP ;# edited
.
#$ns at 4.5 "$ftp3 start" ;# edited
$ns at 8.0 "$cbr0 stop"
#$ns at 9.0 "$ftp3 stop" ;# edited
Simulation :
$ ns 3-no-ftp__2Aramesh.tcl
0 0
0.5 0
1 0
1.5 0
2 0
2.5 0
3 0
3.5 0
4 1
4.5 0
5 -4
5.5 -4
6 -4
6.5 -4
7 -4
7.5 -3
8 -4
8.5 -4
9 -4
9.5 -4
Files created: mon.txt 1001 lines, output.nam 514.7kB, output.tr 203.7kB .
"Link queue" ns2 doc 49.2.2 https://www.isi.edu/nsnam/ns/doc/node634.html
Note : The time you have set is maximum time.
If a simulation finishes in two seconds, no time setting will extend the actual simulation time.
i just make a simple simulation setting, but im confused when i increase the buffer size it causes more packet loss. can someone explain the reason?
set ns [new Simulator]
set tr [open out1.tr w]
$ns trace-all $tr
set ftr [open "out.nam" w]
$ns namtrace-all $ftr
set n0 [$ns node]
set n0 [$ns node]
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
$ns duplex-link $n0 $n2 10mb 10ms DropTail
$ns duplex-link $n1 $n2 10mb 10ms DropTail
$ns duplex-link $n2 $n3 1mb 10ms DropTail
$ns duplex-link $n4 $n3 10mb 10ms DropTail
$ns duplex-link $n5 $n3 10mb 10ms DropTail
$ns queue-limit $n2 $n3 50
set tcp0 [new Agent/TCP/Newreno]
$tcp0 set fid_ 1
$tcp0 set window_ 1000
set tcp1 [new Agent/TCP/Newreno]
$tcp1 set fid_ 2
$tcp1 set window_ 1000
set sink1 [new Agent/TCPSink]
set sink0 [new Agent/TCPSink]
$ns attach-agent $n0 $tcp0
$ns attach-agent $n1 $tcp1
$ns attach-agent $n4 $sink0
$ns attach-agent $n4 $sink1
$ns connect $tcp0 $sink0
$ns connect $tcp1 $sink1
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
proc finish { } {
global ns tr ftr
$ns flush-trace
close $tr
close $ftr
#exec nam out.nam &
exec awk -f output.awk out1.tr &
exec awk -f throughputtest.awk out1.tr &
exec awk -f throughputtest.awk out1.tr > dataout.xg &
exit 0
}
$ns at 0.1 "$ftp0 start"
$ns at 0.1 "$ftp1 start"
$ns at 300 "finish"
$ns run
i was set my buffer size from 50/100/150/200 but when i run the simulation, the result is packet drop increase when i increase the buffer size,please someone give me an explanation, im beginner in NS2 simulator.
Using NS2 and NAM, I want to display a tree topology containing many nodes. How to set position of nodes and orientation as displayed in the image. First image shows before editing and changing the position of nodes in NAM tool. Second image displays after editing the node position manually using NAM tool. I want to see nodes position as displayed in the second image. I do not want to edit manually. How to write the TCL code for this ?
Here is the TCL Code
#Create a simulator object
set ns [new Simulator]
$ns color 1 Green
$ns color 2 Red
$ns color 3 blue
$ns color 4 magenta
#Tell the simulator to use dynamic routing
$ns rtproto DV
set tracefile [open out.tr w]
$ns trace-all $tracefile
#Open the nam trace file
set nf [open out.nam w]
$ns namtrace-all $nf
#Define a 'finish' procedure
proc finish {} {
global ns tracefile nf
$ns flush-trace
#Close the trace file
close $nf
#Execute nam on the trace file
exec nam out.nam &
exit 0
}
#Create thirty six nodes
for {set i 0} {$i < 21} {incr i} {
set n($i) [$ns node]
}
$ns duplex-link $n(0) $n(1) 1Mb 10ms DropTail
$ns duplex-link $n(0) $n(2) 1Mb 10ms DropTail
$ns duplex-link $n(0) $n(3) 1Mb 10ms DropTail
$ns duplex-link $n(0) $n(4) 1Mb 10ms DropTail
$ns duplex-link $n(1) $n(5) 1Mb 10ms DropTail
$ns duplex-link $n(1) $n(7) 1Mb 10ms DropTail
$ns duplex-link $n(1) $n(9) 1Mb 10ms DropTail
$ns duplex-link $n(1) $n(11) 1Mb 10ms DropTail
$ns duplex-link $n(2) $n(5) 1Mb 10ms DropTail
$ns duplex-link $n(2) $n(7) 1Mb 10ms DropTail
$ns duplex-link $n(2) $n(9) 1Mb 10ms DropTail
$ns duplex-link $n(2) $n(11) 1Mb 10ms DropTail
$ns duplex-link $n(3) $n(6) 1Mb 10ms DropTail
$ns duplex-link $n(3) $n(8) 1Mb 10ms DropTail
$ns duplex-link $n(3) $n(10) 1Mb 10ms DropTail
$ns duplex-link $n(3) $n(12) 1Mb 10ms DropTail
$ns duplex-link $n(4) $n(6) 1Mb 10ms DropTail
$ns duplex-link $n(4) $n(8) 1Mb 10ms DropTail
$ns duplex-link $n(4) $n(10) 1Mb 10ms DropTail
$ns duplex-link $n(4) $n(12) 1Mb 10ms DropTail
$ns duplex-link $n(5) $n(13) 1Mb 10ms DropTail
$ns duplex-link $n(5) $n(14) 1Mb 10ms DropTail
$ns duplex-link $n(6) $n(13) 1Mb 10ms DropTail
$ns duplex-link $n(6) $n(14) 1Mb 10ms DropTail
$ns duplex-link $n(7) $n(15) 1Mb 10ms DropTail
$ns duplex-link $n(7) $n(16) 1Mb 10ms DropTail
$ns duplex-link $n(8) $n(15) 1Mb 10ms DropTail
$ns duplex-link $n(8) $n(16) 1Mb 10ms DropTail
$ns duplex-link $n(9) $n(17) 1Mb 10ms DropTail
$ns duplex-link $n(9) $n(18) 1Mb 10ms DropTail
$ns duplex-link $n(10) $n(17) 1Mb 10ms DropTail
$ns duplex-link $n(10) $n(18) 1Mb 10ms DropTail
$ns duplex-link $n(11) $n(19) 1Mb 10ms DropTail
$ns duplex-link $n(11) $n(20) 1Mb 10ms DropTail
$ns duplex-link $n(12) $n(19) 1Mb 10ms DropTail
$ns duplex-link $n(12) $n(20) 1Mb 10ms DropTail
# Provide initial location of mobilenodes
$n(0) set X_ 0.0
$n(0) set Y_ 0.0
#Create a UDP Source Node
set udp0 [new Agent/UDP]
$udp0 set class_ 1
$ns attach-agent $n(0) $udp0
#Create a UDP1 Source Node
set udp1 [new Agent/UDP]
$udp1 set class_ 2
$ns attach-agent $n(0) $udp1
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 250
$cbr0 set interval_ 0.010
$cbr0 attach-agent $udp0
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 250
$cbr1 set interval_ 0.010
$cbr1 attach-agent $udp1
set null0 [new Agent/Null]
$ns attach-agent $n(13) $null0
set null1 [new Agent/Null]
$ns attach-agent $n(20) $null1
$ns connect $udp0 $null0
$ns connect $udp1 $null1
$ns at 0.0 "$cbr0 start"
$ns at 0.0 "$cbr1 start"
$ns at 5.0 "finish"
#Run the simulation
$ns run
It's all a matter of spreading the nodes. There's a few ways to do it, but the key is that you've got a rectangular space.
# Describe the indices of the nodes and how we approximately want to arrange them.
set indexLayout {
{0}
{1 2 3 4}
{5 6 7 8 9 10 11 12}
{13 14 15 16 17 18 19 20}
}
# Describe the space we're going to lay them out over; you might need to tune this
set originX 0
set originY 0
set width 100
set height 100
# Do the layout
set nRows [llength $indexLayout]
set rowsize [expr {$height / $nRows}]
set rowY [expr {$originY + $rowsize / 2}]
foreach row $indexLayout {
set nCols [llength $row]
set colsize [expr {$width / $nCols}]
set rowX [expr {$originX + $colsize / 2}]
foreach index $row {
$n($index) set X_ $rowX
$n($index) set Y_ $rowY
set rowX [expr {$rowX + $colsize}]
}
set rowY [expr {$rowY + $rowsize}]
}
I'm not sure if you need to explicitly set the link orientations if you lay the nodes out, but if you do, you should read this Stack Overflow question: Angle based orientation ns2 not working for information about what the syntax is like. If you need to lay the links out explicitly, you will need to do some geometry (though I can't see why anyone would make that required by default).
Example grid : pbcast_sim.tcl + p_bcast.tcl
http://disc.ece.illinois.edu/downloads/lab108.html
→ → http://disc.ece.illinois.edu/downloads/pbcast_sim.tcl
and http://disc.ece.illinois.edu/downloads/p_bcast.tcl
Simulation example : $ ns pbcast_sim.tcl -prob 20
I am working on a project and I am having problems getting my simulations to work. I have a total of 22 nodes, and when I set up my connections, I am not getting packets on certain links. TO be more specific, I have connectivity and successful packet delievery from node 4 to node 2 and any of node 2's subnodes. When I try to send packets anywhere else, none are delivered. I have looked over my code thoroughly and I can't seem to figure out what i'm doing wrong. Any pointers in the right direction would be appreciated.
Main File
#Create a simulator object
set ns [new Simulator]
#Tell the simulator to use dynamic routing
$ns rtproto DV
#Create a trace file
set tracefd [open project2trace.tr w]
$ns trace-all $tracefd
#Define a ‘finish’ procedure
proc finish {} {
global ns nf
$ns flush-trace
exit 0
}
#Create nodes
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
set n6 [$ns node]
set n7 [$ns node]
set n8 [$ns node]
set n9 [$ns node]
set n10 [$ns node]
set n11 [$ns node]
set n12 [$ns node]
set n13 [$ns node]
set n14 [$ns node]
set n15 [$ns node]
set n16 [$ns node]
set n17 [$ns node]
set n18 [$ns node]
set n19 [$ns node]
set n20 [$ns node]
set n21 [$ns node]
set n22 [$ns node]
#Create 1Mbps connections
#Create a duplex link between the nodes 1 and subnodes
$ns duplex-link $n1 $n11 1Mb 10ms DropTail
$ns duplex-link $n1 $n12 1Mb 10ms DropTail
$ns duplex-link $n1 $n13 1Mb 10ms DropTail
$ns duplex-link $n1 $n14 1Mb 10ms DropTail
#Create a duplex link between the nodes 2 and subnodes
$ns duplex-link $n2 $n6 1Mb 10ms DropTail
$ns duplex-link $n2 $n7 1Mb 10ms DropTail
$ns duplex-link $n2 $n8 1Mb 10ms DropTail
$ns duplex-link $n2 $n9 1Mb 10ms DropTail
$ns duplex-link $n2 $n10 1Mb 10ms DropTail
#Create a duplex link between the nodes 4 and subnodes
$ns duplex-link $n4 $n19 1Mb 10ms DropTail
$ns duplex-link $n4 $n20 1Mb 10ms DropTail
$ns duplex-link $n4 $n21 1Mb 10ms DropTail
$ns duplex-link $n4 $n22 1Mb 10ms DropTail
#Create a duplex link between the nodes 5 and subnodes
$ns duplex-link $n5 $n15 1Mb 10ms DropTail
$ns duplex-link $n5 $n16 1Mb 10ms DropTail
$ns duplex-link $n5 $n17 1Mb 10ms DropTail
$ns duplex-link $n5 $n18 1Mb 10ms DropTail
#Create 2Mbps links
#Create a duplex link between nodes 1 and 3
$ns duplex-link $n1 $n3 2Mb 20ms DropTail
#Create a duplex link between nodes 3 and 5
$ns duplex-link $n3 $n5 2Mb 20ms DropTail
#Create 4Mbps links
#Create a duplex link between nodes 2 and 3
$ns duplex-link $n2 $n3 4Mb 40ms DropTail
#Create a duplex link between nodes 2 and 4
$ns duplex-link $n2 $n4 4Mb 40ms DropTail
#Create a duplex link between nodes 3 and 4
$ns duplex-link $n3 $n4 4Mb 40ms DropTail
#Create a UDP agent and attach it to node n4
set udp0 [new Agent/UDP]
$ns attach-agent $n4 $udp0
# Create a CBR traffic source and attach it to udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 set random_ 1
$cbr0 attach-agent $udp0
#Create a Null agent (a traffic sink) and attach it to node n8
set null0 [new Agent/Null]
$ns attach-agent $n8 $null0
#Connect CBR to Null agent
$ns connect $udp0 $null0
# Create a CBR traffic source and attach it to udp0
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$cbr1 set random_ 1
$cbr1 attach-agent $udp0
#Create a Null agent (a traffic sink) and attach it to node n18
set null1 [new Agent/Null]
$ns attach-agent $n18 $null1
#Connect CBR to Null agent
$ns connect $udp0 $null1
# Create a CBR traffic source and attach it to udp0
set cbr2 [new Application/Traffic/CBR]
$cbr2 set packetSize_ 500
$cbr2 set interval_ 0.005
$cbr2 set random_ 1
$cbr2 attach-agent $udp0
#Create a Null agent (a traffic sink) and attach it to node n21
set null2 [new Agent/Null]
$ns attach-agent $n21 $null2
#Connect CBR to Null agent
$ns connect $udp0 $null2
# Create a CBR traffic source and attach it to udp0
set cbr3 [new Application/Traffic/CBR]
$cbr3 set packetSize_ 500
$cbr3 set interval_ 0.005
$cbr3 set random_ 1
$cbr3 attach-agent $udp0
#Create a Null agent (a traffic sink) and attach it to node n10
set null3 [new Agent/Null]
$ns attach-agent $n10 $null3
#Connect CBR to Null agent
$ns connect $udp0 $null3
# Create a CBR traffic source and attach it to udp0
set cbr4 [new Application/Traffic/CBR]
$cbr4 set packetSize_ 500
$cbr4 set interval_ 0.005
$cbr4 set random_ 1
$cbr4 attach-agent $udp0
#Create a Null agent (a traffic sink) and attach it to node n11
set null4 [new Agent/Null]
$ns attach-agent $n11 $null4
#Connect CBR to Null agent
$ns connect $udp0 $null4
# Create a CBR traffic source and attach it to udp0
set cbr5 [new Application/Traffic/CBR]
$cbr5 set packetSize_ 500
$cbr5 set interval_ 0.005
$cbr5 set random_ 1
$cbr5 attach-agent $udp0
#Create a Null agent (a traffic sink) and attach it to node n16
set null5 [new Agent/Null]
$ns attach-agent $n16 $null5
#Connect CBR to Null agent
$ns connect $udp0 $null5
# Create a CBR traffic source and attach it to udp0
set cbr6 [new Application/Traffic/CBR]
$cbr6 set packetSize_ 500
$cbr6 set interval_ 0.005
$cbr6 set random_ 1
$cbr6 attach-agent $udp0
#Create a Null agent (a traffic sink) and attach it to node n13
set null6 [new Agent/Null]
$ns attach-agent $n13 $null6
#Connect CBR to Null agent
#$ns connect $udp0 $null6
#Schedule events for the CBR agent
$ns at 1.0 "$cbr0 start"
$ns at 1.0 "$cbr1 start"
$ns at 1.0 "$cbr2 start"
$ns at 2.0 "$cbr3 start"
$ns at 2.0 "$cbr4 start"
$ns at 2.0 "$cbr5 start"
$ns rtmodel-at 6.0 down $n2 $n4
$ns rtmodel-at 2.0 up $n2 $n4
$ns at 10.0 "$cbr0 stop"
$ns at 10.0 "$cbr1 stop"
$ns at 10.0 "$cbr2 stop"
$ns at 2.0 "$cbr3 stop"
$ns at 2.0 "$cbr4 stop"
$ns at 2.0 "$cbr5 stop"
$ns at 10.0 "finish"
#Run the simulation
$ns run
The way the code is now, 0 pakets will be delivered. If I comment out everything except the first connection, I get packets. When I uncomment anything else, I lose all packets. Here is my awk file.
cbr.awk
BEGIN {
node = 1;
time1 = 0.0;
time2 = 0.0;
num_packets = 0;
}
{
time2 = $2;
if (time2 - time1 > 0.050) {
throughput = bytes_counter / (time2 - time1);
printf("%f \t %f\n", time2, throughput) > "dataset.xls";
time1 = $2;
bytes_counter = 0;
}
if ($1 == "r" && $4 == node && $5 == "cbr") {
bytes_counter += $6;
num_packets++;
}
}
END {
print("********");
printf("Total number of packets received: \n%d\n", num_packets);
print("********");
}
I'm at a loss. Literally.
I am working in NS2 and trying to mix the tcp and udp packets, by using MD1 queue type. I want to split the arrival rate between each udp and tcp packets. I have managed to set the udp as Poisson traffic and found out how to control the generation of packets, but in tcp I haven't figured out how I can control the generation of packets meaning how to set the arrival rate in tcp source traffic, (I will be using ftp and cbr traffic). I have tried many ways but I haven't managed to solve it. Which parameter in the .tcl file for tcp should I use to do that?
My .tcl file:
set ns [new Simulator]
set tf [open output.tr w]
set nf [open nam.nam w]
$ns trace-all $tf
$ns namtrace-all $nf
proc finish {} {
global ns nf tf
$ns flush-trace
close $tf
close $nf
exec nam nam.nam &
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
$ns duplex-link $n0 $n2 1Mb 10ms DropTail
$ns simplex-link $n1 $n2 1Mb 10ms DropTail
$ns duplex-link $n2 $n3 0.04Mb 10ms DropTail
$ns queue-limit $n0 $n2 100
$ns queue-limit $n1 $n2 100
$ns queue-limit $n2 $n3 100
$ns duplex-link-op $n0 $n2 orient right-down
$ns simplex-link-op $n1 $n2 orient right-up
$ns duplex-link-op $n2 $n3 orient right
$ns duplex-link-op $n0 $n2 queuePos 0.5
$ns simplex-link-op $n1 $n2 queuePos 0.5
$ns duplex-link-op $n2 $n3 queuePos 0.5
set udp [new Agent/UDP]
$ns attach-agent $n1 $udp
set null [new Agent/Null]
$ns attach-agent $n3 $null
$ns connect $udp $null
set exp [new Application/Traffic/Exponential]
$exp attach-agent $udp
$exp set burst_time_ 0
$exp set idle_time_ 400ms
$exp set rate_ 1mb
$exp set packetSize_ 1000
set tcp [new Agent/TCP]
$tcp set class_ 2
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n3 $sink
$ns connect $tcp $sink
$tcp set window_ 20
$tcp set packetSize_ 555
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP
$ns at 0.2 "$exp start"
$ns at 0.3 "$ftp start"
$ns at 30000 "$exp stop"
$ns at 30000 "$ftp stop"
$ns at 30000 "finish"
$ns run