Re: [ns] Setting tcl script variables from inside C++ code
Hello Fernando, You can use the following code: Tcl tcl = Tcl::instance(); sprintf(tcl.buffer(), set my_tcl_var %f, 10.123); tcl.eval(); Note that you can use the same method to execute any command on Tcl. You can find more information in chapter 3 of the ns-manual. Good luck Waleed On Tue, Jan 20, 2009 at 3:09 PM, fh...@c3sl.ufpr.br wrote: Well, it is just as the title says: I would like to know how to change the value of my tcl script variables from inside my C++ code. I learned how to change C++ variables from inside the tcl code, but not the tcl variables from inside the C++ code. Is there any easy way? Thanks in advance, -- Fernando Henrique Gielow - UFPR - NR2 Computer Science graduation student.
Re: [ns] How to determine txpower from Pt_
Hello Manish, My understanding is that the two parameters are not related. Pt_ defines the amount of power transmitted from the antenna (Phy/WirelessPhy), and thus; it defines (together with the RXThresh_ parameter) the range of the mobile-node. And it is not used by the energy model. txpower defines how much power a mobile-node, as a whole, consumes when it is transmitting, and it is the one used by the energy model. For example; the PRO/Wireless 3945ABG card on my laptop can consume a maximum power of 1.8 Watt while transmitting and a maximum of 1.4 Watt while receiving. But the maximum transmitting power is 15 dBm ( ~ 31 mW) ! -- Waleed Tuffaha On Wed, Jan 21, 2009 at 7:07 AM, manish chaturvedi msc@gmail.comwrote: Hi, I am trying to incorporate energy model in my NS2.33 simulation. I have some confusion between Pt_(used to set transmission range), and txpower(energy model parameter specifying enegy consumption in transmission). I need to know what is the relation between these values, and how can I calculate one(txpower) given the other(Pt_). I looked at some old discussions on this mailing list but could not make it from there. Please give information or point to some source of this information. Thanking you,Manish.
Re: [ns] how to chang the shape of the nodes
use the following command to adjust the node size: $ns_ initial_node_pos $node 10 I don't know why it is called initial_node_pos ! if you have an array of nodes ( $nodes_( ) ), then use a for loop: for {set i 0} {$i $val(nn)} {incr i} { # The function must be called after mobility model is defined $ns_ initial_node_pos $node_($i) 10 } On Thu, Jan 1, 2009 at 12:22 PM, Panks PB pankajavall...@gmail.com wrote: hi, i'm working in ns2.33. I executed the wireless1.tcl which is available in Marc Greis' tutorial.In my nam window the nodes look very small.I tried to change the shape of the node by giving $node_(0) shape box but no change in my nodes.plz help me how to change and enlarge its size. Thank you -- Waleed Tuffaha.
[ns] DSR Route-Request size error
Hello all, I'm testing the DSR protocol in ns-2.33. I noticed that the size of the route request is wrong: each time a node adds itself to the path in the route request and forwards it; the size of the request should increase by 4 bytes, but instead it is increased by the whole size of the DSR request header! So the size of the route-request packet increases like this : 32 - 48 - 68 - 92 ( when the hop count increases from 1 - 2 - 3 - 4 ) as can be seen in the following lines of the trace file: s -t 0.596604780 -Hs 1 -Hd -1 -Ni 1 -Nx 31.54 -Ny 47.86 -Nz 0.00 -Ne -1.00 -Nl RTR -Nw --- -Ma 0 -Md 0 -Ms 0 -Mt 0 -Is 1.255 -Id 16.255 -It DSR -Il 32 -If 0 -Ii 2 -Iv 32 -P dsr -Ph 1 -Pq 1 -Ps 2 -Pp 0 -Pn 2 -Pl 0 -Pe 0-16 -Pw 0 -Pm 0 -Pc 0 -Pb 0-0 f -t 0.598515344 -Hs 11 -Hd -1 -Ni 11 -Nx 12.88 -Ny 81.10 -Nz 0.00 -Ne -1.00 -Nl RTR -Nw --- -Ma 0 -Md -Ms 1 -Mt 800 -Is 1.255 -Id 16.255 -It DSR -Il 48 -If 0 -Ii 2 -Iv 32 -P dsr -Ph 2 -Pq 1 -Ps 2 -Pp 0 -Pn 2 -Pl 0 -Pe 0-16 -Pw 0 -Pm 0 -Pc 0 -Pb 0-0 f -t 0.608855544 -Hs 12 -Hd -1 -Ni 12 -Nx 44.77 -Ny 96.77 -Nz 0.00 -Ne -1.00 -Nl RTR -Nw --- -Ma 0 -Md -Ms b -Mt 800 -Is 1.255 -Id 16.255 -It DSR -Il 68 -If 0 -Ii 2 -Iv 32 -P dsr -Ph 3 -Pq 1 -Ps 2 -Pp 0 -Pn 2 -Pl 0 -Pe 0-16 -Pw 0 -Pm 0 -Pc 0 -Pb 0-0 f -t 0.618942937 -Hs 13 -Hd -1 -Ni 13 -Nx 66.91 -Ny 69.78 -Nz 0.00 -Ne -1.00 -Nl RTR -Nw --- -Ma 0 -Md -Ms c -Mt 800 -Is 1.255 -Id 16.255 -It DSR -Il 92 -If 0 -Ii 2 -Iv 32 -P dsr -Ph 4 -Pq 1 -Ps 2 -Pp 0 -Pn 2 -Pl 0 -Pe 0-16 -Pw 0 -Pm 0 -Pc 0 -Pb 0-0 If you notice the increments in the size ( 32 - 32+16 - (32+16)+20 - ((32+16)+20)+24 ) , then these increments represent the actual size of the DSR request ( without the IP-header length). I looked at the DSR agent implementation and found that the size of the packet is always changed by +-srh-size() instead of +-4 : cmnh-size() += srh-size(); cmh-size() -= srh-size();// cut off the SR header 4/7/99 -dam I want to know if that is a bug ? or am I missing something ? Thanks, Waleed Tuffaha.
Re: [ns] Can anyone tell me how to debug ns2 2.33 using gdb? No successful examples could have been googled yet.
Hello Matt, A while ago I followed the steps in that FAQ to enable the debugging in ns2 and it worked fine with me. I used gdb to debug my C++ code as follows: gdb ns run my_tcl_script.tcl My code used to give me segmentation fault and I used gdb to find out where the problem was. I debug my Tcl code using puts to print on the output what is happening. I know it is not much efficient but till now it was sufficient. Best regards, On Sun, Dec 21, 2008 at 11:37 AM, matt Wood withhighp...@gmail.com wrote: Dear friends, I've read the ns-doc chap24 and chap28, and followed the instructions (Q3) found in http://web.syr.edu/~dchen02/FAQ.txthttp://web.syr.edu/%7Edchen02/FAQ.txt, but when I try to debug using '$gdb ns' it says: no debugging symbols found. Same questions can be found in the mail-list but they still remain unresolved. Please tell me if this 2.33-allinone can be debugged by gdb. And if it is not, what debugging method can I use if I want to add a new MAC protocol? Thank you in advance. Yours sincerely, Matthew Wood -- Waleed Tuffaha.
Re: [ns] puzzles on Agent and Router
Hello Phenix, Agent here means the TCP or UDP agent (Transport layer) to which a data source (like CBR or FTP) is connected. So the Agent represents the source of the data that is being injected into the network, and also represents the final destination to which the data is delivered at the destination node. Router represents the routing-agent (AODV in your example). So, if you have a network of 100 nodes that uses AODV for routing, and only two nodes are communicating with each other using FTP over TCP. Then all the nodes will have the Router (Agent/AODV) but only two nodes will have the Agent (Agent/TCP Agent/TCPSink). Take a look at Figure 16.1 in the NS2-manual, it expalins that structure of the wireless node and how the Agent (Src/Sink) is connected with the Router (RTagent) If you enable both -agentTrace and -routerTrace, then in the trace file you will see that the new data is being sent from the AGT (Agent) and has the type TCP or CBR and is received by the RTR (Routing Agent) in the same node. Then the RTR decides how to handle the data depending on what type of routing agent it is (AODV, DSDV, DSR ... etc ). Hope this explains it. On Sat, Dec 20, 2008 at 9:02 AM, Phenix phenix...@hhu.edu.cn wrote: Hi guys, Recently I'm rather puzzled about Agent and Router in NS-2. Take AODV for example, it is a kind of route protocol, meanwhile it's a kind of agent. Are agent and router equivalent? And also, both agent and router have respective trace switch, -agentTrace and -routerTrace. Which one should I use when evaluating my algorithm ? Wish someone can give me some explains. Thanks in advance. Regards, Phenix -- Waleed Tuffaha.
Re: [ns] problem when adding a new routing protocol to NS2:please help
Hell Nadine, I think you have an error in your Tcl simulation script. When you create the wireless nodes you have to create them in an array called node_ because the traffic generator (that generated the cbr-50-10-4-512 file ) expect the nodes to be created in that array. You can use this code to create the node: for {set i 0} {$i $val(nn) } {incr i} { set node_($i) [$ns_ node] } val(nn) here holds the number of nodes. On Wed, Dec 17, 2008 at 10:06 PM, Nadine Chen nadine...@yahoo.fr wrote: Hi all. I added a new routing protocol to NS2. I made the appropriate changes to tcl/lib/ns-default.tcl, ns-packet.tcl,ns-lib.tcl , common/paquet.h, queue/priqueue.cc and trace:cmu-trace.h and .cc .i recompiled ns2 and I had an error free compilation. I wanted to test my protocol: I changed in wireless.tcl set opt(rp) dsr by set opt(rp) newprotocolname but when I wrote ns wireless.tcl I had this : num_nodes is set 50 Loading connection pattern... can't read node_(1): no such variable while executing $ns_ attach-agent $node_(1) $udp_(0) (file ../mobility/scene/cbr-50-10-4-512 line 8) invoked from within source.orig ../mobility/scene/cbr-50-10-4-512 (uplevel body line 1) invoked from within uplevel source.orig [list $fileName] invoked from within if [$instance_ is_http_url $fileName] { set buffer [$instance_ read_url $fileName] uplevel eval $buffer } else { uplevel source.orig [list $fileName] ... (procedure source line 8) invoked from within source $opt(cp) invoked from within if { $opt(cp) == } { puts *** NOTE: no connection pattern specified. set opt(cp) none } else { puts Loading connection pattern... ... (file wireless.tcl line 257) So please if anyone has an idea about this error , help me. I don't know if I should add a file in mobility or what should I do exactly. help me please. -- Waleed Tuffaha.
Re: [ns] ns-2.33 re-compilation error
I found out the problem. It turned out that the install script in ns-allinone-2.33/ replaces the make-file in the ns-2.33/ directory with the original one. so my files weren't being compiled when I ran 'make', and in those files I had the class that inherits from PacketHeaderClass and binds the 'hdr_dgab_pkt::offset_' , and this cause the undefined reference error. Nevertheless, this small problem caused me a sever headache. On Sat, Dec 6, 2008 at 7:28 PM, Waleed Tuffaha [EMAIL PROTECTED] wrote: Hello, I was writing an agent in ns-2.33 and it was compiling and working well. Then I tried to recompile ns-allinone 2.33 with debugging enabled and I got the following error: trace/cmu-trace.o: In function `hdr_dgab_pkt::access(Packet const*)': cmu-trace.cc:(.text._ZN12hdr_dgab_pkt6accessEPK6Packet[hdr_dgab_pkt::access(Packet const*)]+0x7): undefined reference to `hdr_dgab_pkt::offset_' collect2: ld returned 1 exit status make: *** [ns] Error 1 Note that the same code didn't give any errors when I was compiling the ns-2.33 directory only, but when I ran ./install in the ns-allinone-2.33 directory I got that error. Does anyone know what causes this error or how to solve it ? Thanks, -- Waleed -- Waleed Tuffaha.
Re: [ns] Know destination and Source address
Hello Thanes Vela, You will have to define your problem a bit more. But Generally, the output of a simulation is stored in a trace file, and you can look at that file to see the source and destination of each packet. On Mon, Dec 1, 2008 at 5:08 AM, Thanes Vela [EMAIL PROTECTED] wrote: Hi All, I am newbie to ns2. I would like to know *destination* and *source address* of each incoming packet of a node. Could please anyone help me how to do this? Thanks in advance Regards Thanes -- Waleed Tuffaha.
Re: [ns] TCL Script - No Slot Error
Hello Aniruddha, I don't know about NSIS, but i had an error that might be similar. I was building a simple routing agent that at some point modified the IP header of the packet by changing the IP-destination-addr with the IP_BROADCAST address. And I forgot to restore the original IP header before handing the packet to the port classifier , so I got the following error: --- Classfier::no-slot{} default handler (tcl/lib/ns-lib.tcl) --- _o30: no target for slot 0 _o30 type: Classifier/Port content dump: classifier _o30 0 offset 0 shift 2147483647 mask 1 slots slot 255: _o17 (Agent/AllBroadcast) AllBroadcast is the name of my agent. So all i can say about your case is that somewhere a Classifier/Hash/Dest (node's address classifier?) is being used and it is passed a packet that it doesn't know how to classify ! Sorry I couldn't be of more help. Good luck. On Sat, Nov 22, 2008 at 5:25 PM, Aniruddha Niranjan [EMAIL PROTECTED]wrote: Hi. I am implementing a new protocol over the NSIS module on ns-2. The source code has compiled successfully. Now, I am running a sample script. The output starts off properly (first 6 lines of output below) but then I am getting an error as follows. Please give me some hints about this issue. (Script used is inline after the output message) Node n0 sent Pbs query to Node n1. The requested volume is 20. Api Call mode will be execed MRI: IPVersion must be 4 or 6 ***Node 0 send 'query' message (Dmode with rao) *** Send with UDP --- Classfier::no-slot{} default handler (tcl/lib/ns-lib.tcl) --- _o13: no target for slot -1 _o13 type: Classifier/Hash/Dest content dump: classifier _o13 0 offset 0 shift 2147483647 mask 2 slots slot 0: _o19 (Classifier/Port) slot 1: _o30 (Connector) -1 default -- Finished standard no-slot{} default handler -- -End of Output pbs-example.tcl Script: set ns [new Simulator] $ns rtproto DV set tracefd [open example.tr w] $ns trace-all $tracefd #Open the nam trace file set nf [open out.nam w] $ns namtrace-all $nf #Define a 'finish' procedure proc finish {} { global ns nf tracefd $ns flush-trace #Close the trace file close $tracefd close $nf #Execute nam on the trace file exec nam out.nam exit 0 } Create Eight nodes # set n0 [$ns node] set n1 [$ns node] $n0 color blue $n1 color red ### Trans with UDP set udp0 [new Agent/UDP] set udp1 [new Agent/UDP] $ns attach-agent $n0 $udp0 $ns attach-agent $n1 $udp1 Trans with TCP ### set tcp0 [new Agent/TCP/SimpleTcp] set tcp1 [new Agent/TCP/SimpleTcp] $ns attach-agent $n0 $tcp0 $ns attach-agent $n1 $tcp1 $tcp0 set fid_ 0 $tcp1 set fid_ 0 $tcp0 listen $tcp1 listen set app0 [new Application/TcpApp/GistTcpApp $tcp0] set app1 [new Application/TcpApp/GistTcpApp $tcp1] ### Set Gist ## set gist0 [new Application/Gist] set gist1 [new Application/Gist] $gist0 attachAgent $udp0 $gist1 attachAgent $udp1 $app0 setapp $gist0 $app1 setapp $gist1 $gist0 pbs-install $gist1 pbs-install ### Create a duplex link between the nodes # $ns duplex-link $n0 $n1 1Mb 100ms DropTail $ns duplex-link-op $n0 $n1 orient right ### Run the simulation ### #debug 1; $ns at 1.0 $gist0 pbs query n1 20 #debug 2; $ns at 5.0 finish $ns run -- Waleed Tuffaha.
Re: [ns] Fwd: Problem with trace-all in NS2
Hello kanupriya, you have an error in proc finish {} , you didn't do 'global tracefile1' , so the following adjustments to the finish proc should make it work: proc finish {} { global ns nf *tracefile1* $ns flush-trace #Close the trace file close $tracefile1 close $nf #Execute nam on the trace file exec nam out.nam exit 0 } On Sun, Nov 16, 2008 at 4:15 AM, kanupriya kabra [EMAIL PROTECTED] wrote: hi I am not able to collect the traces using trace-all command in NS2 (on windows): Here is a snapshot of my file #Create a simulator object set ns [new Simulator] #Open the Trace file set tracefile1 [open out.tr w] $ns trace-all $tracefile1 #Open the nam trace file set nf [open out.nam w] $ns namtrace-all $nf proc finish {} { global ns nf $ns flush-trace #Close the trace file close $tracefile1 close $nf #Execute nam on the trace file exec nam out.nam exit 0 } rest of file But there is an error when I run this $ ns example4a.tcl ns: finish: can't read tracefile1: no such variable while executing close $tracefile1 (procedure finish line 5) invoked from within finish I would really appreciate if anyone could help me out with this error? I am able to open the nam file using the open command but I am not able to find out why tracefile1 is not getting created. Regards Kanu -- Waleed Tuffaha.
Re: [ns] collisions in 802.11 or interference
Hello Imad The 802.11 Standard uses CSMA/CA ( Carrier Sense Multiple Access with Collision Avoidance ). It does not use collision detection. And 802.11.ccshould be coded according to the standard, so I guess you won't be able to capture the collided packets inside 802.11.cc. I think you can only capture the packets that did not pass the CRC check. Best regards, -- Waleed Tuffaha Date: Thu, 13 Nov 2008 10:23:05 -0500 From: Imad Abdeljaouad [EMAIL PROTECTED] Subject: Re: [ns] collisions in 802.11 or interference To: Basim Javed [EMAIL PROTECTED] Cc: ns-users@isi.edu ns-users@ISI.EDU Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=ISO-8859-1 Well, my idea was to simulate interference. You are right absolutely right, interference happens in the air so the receiver has no idea about it. But this is in real life. Since there are no signals in ns2, my idea was to calculate interference at the MAC layer which will know what are the packets (signals) that were sent at the same time on the air. So when the MAC receives more than one packet, I want to record these packets somewhere (and this will give me access to where they are coming from and going to, plus their powers), then I will apply a formula that will calculate interference between all these packets (in real life: signals). You are absolutely right, in case of one channel, this will be considered as collision IF the received packets are destined to the same receiver/. But there are two other cases, if the packet is not destined to that receiver, then I think this will be strong interference. Also, if the interfering packet belongs to a different channel (that I am willing to add after I figure out the interference) then this is will be interference depending on the correlation between the channels. Do you see my point? The first step I believe would be to capture all packets that come at the same time while I am receiving another packet. This way I can process them and decide if it is collision or strong or weak interference. I have the formula, all I need are the packets along with their powers and channels they belong to (don't care about the channels now, coz that's coming after). I am still wondering how and where in the 802.11.cc code I can capture all colliding/interfering packets and put them somewhere for processing. cheers, On Thu, Nov 13, 2008 at 5:00 AM, Basim Javed [EMAIL PROTECTED] wrote: hello Imad I can see ur point. Lets talk on the issues one by one: The interference of one packet to an already sent packet creates collision. right? so interference and collisions happen in the air. I dont see why it is important that the packets should be sent to one receiver and they if they interfere, then collision happens. I think even those nodes who are just listening to the channel, know that collision has happened in the air, even they were not recipients of the packet. Now, how does the node knows that a collision has happened.. through the received signal power, which is lower than a threshold level (i forgot the name). As far as I remember, the power level can be so low, that a node can not receive a packet, or it is bit high but still not good enough to decrypt the bits. What I am talking above is related to the situation of same channel (single hop). I think multiple channels are used in neighbouring BSSs. About ur formula: how a receiving node can know about the power of the signal when the packet was sent, in real situation? regards basim On Wed, Nov 12, 2008 at 4:16 PM, Imad Abdeljaouad [EMAIL PROTECTED] wrote: Thank you so much, I really need help! I would like to add interference support in 802.11. If my understanding is right, interference happens when signals send on the same channel (or adjacent channels, like 1 and 2 or 3 ... to 6) overlap in the medium (the air) and cause attenuations to each other. I think this will not be possible in ns2 since there are no real signals. So I was thinking that what I should do is collect the signals that arrive at the same time at the receiver MAC (and this is where I got collisions) and this means that these signals already overlapped in the air since they got to the receiver MAC at the same time. Do you see my point? Once I know which siganls overlapped, I can use a formula to calculate interference (the fornula uses Power of the signal sent + which channel does it belong to, to calculate the effect of one sigan on another ). So the point is, I need to capture the packet*s* that collide while I am receiving another packet and for how long they collided. I don't know if you get my point, but please do not hesitate to ask me more questions! thank you again !!! On Wed, Nov 12, 2008 at 4:36 AM, Basim Javed [EMAIL PROTECTED] wrote: hello Imad I want to help you, but I dont understand your definition