Hi ns2 users, I am a brand new user in NS2 and try to cotton up with it. I already got a lot of knowledge, but with tiny details I get stuck e.g. how can I color the Streams? I'm not able to find the error
here is my code. # new simulator / Neuer Simulator set ns [new Simulator] #Open the output files / öffnen neuer outputfiles set f0 [open out0.tr w] set f1 [open out1.tr w] #Open file for nam tracing set nf [open out1.nam w] $ns namtrace-all $nf #creating new nodes / Erzeugen von Nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] set n4 [$ns node] set n5 [$ns node] $n0 color "blue" $n1 color "green" $n2 color "black" $n3 color "black" $n4 color "blue" $n5 color "Green" $n0 label "Audio Source" $n1 label "PC1" $n2 label "Switch1" $n3 label "Switch2" $n4 label "Audio sink" $n5 label "PC2" #connect the nodes / Verbinden der Nodes $ns duplex-link $n0 $n2 100Mb 10ms DropTail $ns duplex-link $n1 $n2 100Mb 10ms DropTail $ns duplex-link $n3 $n2 100Mb 10ms RED $ns duplex-link $n4 $n3 100Mb 10ms DropTail $ns duplex-link $n5 $n3 100Mb 10ms DropTail #arrange the nodes / Anordnung der Nodes $ns duplex-link-op $n0 $n2 orient right-down $ns duplex-link-op $n1 $n2 orient right-up $ns duplex-link-op $n2 $n3 orient right $ns duplex-link-op $n3 $n4 orient right-up $ns duplex-link-op $n3 $n5 orient right-down proc record {} { global sink4 sink5 f0 f1 #Get an instance of the simulator set ns [Simulator instance] #Set the time after which the procedure should be called again set time 0.5 #How many bytes have been received by the traffic sinks? set bw0 [$sink4 set bytes_] set bw1 [$sink5 set bytes_] #Get the current time set now [$ns now] #Calculate the bandwidth (in MBit/s) and write it to the files puts $f0 "$now [expr $bw0/$time*8/1000000]" puts $f1 "$now [expr $bw1/$time*8/1000000]" #Reset the bytes_ values on the traffic sinks $sink4 set bytes_ 0 $sink5 set bytes_ 0 #Re-schedule the procedure $ns at [expr $now+$time] "record" } proc attach-expoo-traffic { node sink size burst idle rate agent traffica } { #Get an instance of the simulator set ns [Simulator instance] #Erzeugen neuer Agents und konfig. parameter setzen set source [new Agent/$agent] $ns attach-agent $node $source ##Create an Expootraffic agent and set its configuration parameters set traffic [new Application/Traffic/$traffica] $traffic set packetSize_ $size $traffic set burst_time_ $burst $traffic set idle_time_ $idle $traffic set rate_ $rate $traffic color "red" # Attach traffic source to the traffic generator $traffic attach-agent $source #Connect the source and the sink $ns connect $source $sink return $traffic } #Finishprozedur hinzufügen proc finish {} { global ns nf f0 f1 $ns flush-trace close $f0 close $f1 close $nf exec xgraph out0.tr out1.tr -geometry 800x400 & exec nam out1.nam & exit 0 } #create the two sink / zwei Empfänger erzeugen set sink4 [new Agent/LossMonitor] set sink5 [new Agent/LossMonitor] $ns attach-agent $n4 $sink4 $ns attach-agent $n5 $sink5 #create the two sources / zwei Sources erzeugen set rtp0 [attach-expoo-traffic $n0 $sink4 500kb 0.02s 0.5s 500k RTP RealAudio] set udp1 [attach-expoo-traffic $n1 $sink5 500Gb 0.02s 0.5s 500k UDP CBR] #distinguish the streams / Unterscheiden der Verkehrsströme $rtp0 set class_ 2 $udp1 set class_ 1 #color the streams / Markierung der Stöme $ns color 2 "Red" ;# <--? $ns color 1 "Green" ;# <--? #watch the queue / überwachen der Warteschlange $ns duplex-link-op $n2 $n3 queuePos 0.5 $ns duplex-link-op $n3 $n2 queuePos 0.5 #start record / Aufnahme beginnen $ns at 0.0 "record" #define start stop / Sendebeginn und -ende definieren $ns at 0.2 "$udp1 start" $ns at 4.1 "$udp1 stop" $ns at 0.1 "$rtp0 start" $ns at 4.5 "$rtp0 stop" #fix simulation time / Simulationsdauer festlegen $ns at 5.0 "finish" #start simulation / starten der Simulation $ns run Best regards from Germany / Viele Grüße aus Deutschland Tom