Re: How to add road and junction in NS2 script

182 views
Skip to first unread message
Message has been deleted

Rajeshwari Madli

unread,
Sep 24, 2021, 1:30:56 PM9/24/21
to ns-u...@googlegroups.com
Hi,

For simulation of roads, junctions and vehicular movements that resemble the urban scenario, you can use SUMO (Simulation of Urban Mobility). You can find the installation details in the video below:

The trace file generated can be imported into NS-2 and V2V and V2R communication models can then be simulated. For details of V2V communication, you can refer to 

For simulating Road Side Units and V2R communication, you can refer to my script attached here.

 

On Fri, Sep 24, 2021 at 8:21 PM Durgesh Tiwari <dnme...@gmail.com> wrote:
Can someone pls share a sample NS2 script which shows 2 roads and junction and also RSU units. 

--
You received this message because you are subscribed to the Google Groups "Network Simulator 2 (NS2)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-users+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-users/6760e57e-90a3-4eb2-8983-eaa23b2cbaa5n%40googlegroups.com.


--
Thanks and Regards
Rajeshwari Madli
Research Scholar
Department of CSE
B.M.S College of Engineering
Bengaluru
wifi_infra_vanet.tcl

Durgesh Tiwari

unread,
Sep 24, 2021, 4:27:38 PM9/24/21
to Network Simulator 2 (NS2)
Thank you Rajeshwari.

But I could not run your script successfully. It errored out. Can you pls recheck and attach it again. 

knudfl

unread,
Sep 24, 2021, 7:01:20 PM9/24/21
to Network Simulator 2 (NS2)
The file `wifi_infra_vanet.tcl´ can be run with ns-2.35/ns-noah-ODFM , i.e. an ns-2.35 patched for the NOAH protocol +  one of "Wimax--ODFM" patches.  
May be @Rajeshwari will share the suggested patch ?

.... there is e.g. "fhmip_ns235.patch with NOAH" and several Wimax - ODFM patches.

Rajeshwari Madli

unread,
Sep 24, 2021, 10:24:57 PM9/24/21
to ns-u...@googlegroups.com
What error are you getting? Can you please mention it. I am able to run it successfully.

Rajeshwari Madli

unread,
Sep 24, 2021, 10:57:09 PM9/24/21
to ns-u...@googlegroups.com
You can replace NOAH with any of the other ad-hoc protocols such as AODV. If you want to use NOAH, follow the steps in the link below
Network interface, you can use "Phy/WirelessPhy" instead of "Phy/WirelessPhy/OFDM".

@knudfl, I have not used Wimax patch here. I was trying to run it with 802.11p patch. But it did not work for me. So I had to use 802.11 itself.


Durgesh Tiwari

unread,
Sep 25, 2021, 7:25:25 AM9/25/21
to Network Simulator 2 (NS2)
I was able to run the file without error but did not get the nam animator as output. Just got below messages. What am i doing wrong. 

********************************************************************
num_nodes is set 10
INITIALIZE THE LIST xListHead
Starting Simulation...
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5,  distCST_ = 550.0
SORTING LISTS ...DONE!
Client 5: Handoff Attempted
Client 4: Handoff Attempted
*******************************************************************

knudfl

unread,
Sep 25, 2021, 9:35:09 AM9/25/21
to Network Simulator 2 (NS2)
"aodv__wifi_infra_vanet.tcl" :

Client 5: Handoff Attempted
Client 4: Handoff Attempted
....... will / can happen with a default 'ns' from a stock ns-2.35 .
Please remember that ns2 is ancient. Officially unsupported since 2015.
And miscellaneous instability is expected with the most contemporary OS.

"Handoff Attempted" can just be ignored.
Or you may stabilize ns-2.35 with mannasim + CRN-D2CARP_ns235.patch
export CC=gcc-4.8 CXX=g++-4.8 && install

Durgesh Tiwari

unread,
Sep 25, 2021, 9:42:15 AM9/25/21
to Network Simulator 2 (NS2)
Thanks Kundfl. But the nam should still show as an output right. Why that does not show. 

knudfl

unread,
Sep 25, 2021, 11:48:04 AM9/25/21
to Network Simulator 2 (NS2)
wifi_infra_vanet.tcl :  NAM shows what's available with the file settings:
All nodes in the same position, and one node moving : node 4

The file-text says,  line 76 :
# Set Node 0 and Node $val(nn) as the APs. Thus the APs are the ends of the horizontal line
........... I don't see any horizontal line.
_____________________________________________________________

Please run the available examples.  
A good one is vanetiaodv.tcl :  Node 2 and 3 are static, i.e. not moving.  ( RSU's ? )
It has sumo generated settings: Node positions ,  movement.
See   ex-vanet-10.19/

Durgesh Tiwari

unread,
Sep 25, 2021, 9:21:13 PM9/25/21
to Network Simulator 2 (NS2)
HI Kundfl,

when i ran "vanetiaodv.tcl" it just showed below message but animator did not open. Do i need to modify someone in that code?
___________________________________
num_nodes is set 50
INITIALIZE THE LIST xListHead
Starting Simulation...
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5,  distCST_ = 550.0
SORTING LISTS ...DONE!
NS EXITING...


Durgesh Tiwari

unread,
Sep 25, 2021, 9:38:23 PM9/25/21
to Network Simulator 2 (NS2)
Also for any nam file i get below message:

invalid command name "n"
    while executing
"n -t * -s 0  -x 0 -y 0 -Z 0 -z 50  -v circle -c black"
    (file "vanet-infra.nam" line 1)


knudfl

unread,
Sep 26, 2021, 3:38:42 AM9/26/21
to Network Simulator 2 (NS2)
Some simulation will have a line like    exec nam out &
...... and with others you will have to run nam yourself :
$ nam vanetiaodv.net.xml &
---------------------------------------------------------------------------

About `vanet-infra.nam´ :
$ nam vanet-infra &        
[1] 7941                ## that's the only text output

And repeating the command :
$ nam vanet-infra &
[2] 8244
[1]   Done          nam vanet-infra
--------------------------------------------------------------------------------------

Time to tell which OS you have : OS name and version, please. And how is it installed? To a hard disk partition or a Virtual Machine like VirtualBox or wmWare ??

How was ns-2.35 installed ?   And nam ?  Did you build the executable yourself? Or install with apt?
Message has been deleted

knudfl

unread,
Sep 26, 2021, 3:23:53 PM9/26/21
to Network Simulator 2 (NS2)
Hi.
Parameters : Analyzing is done with awk, perl scripts, and with shell scripts.
A script must match the trace file.   Hence 240 different scripts :

Examples with AWK-first.06.19/

$ awk -f Avg_Tput.awk vanetiaodv.tr
       startTime:  0
        stopTime:  998
    receivedPkts:  1.13896e+06
   avgTput[kbps]:  256919

$ awk -f Avg_Tput.awk vanet-infra.tr
       startTime:  0
        stopTime:  19
    receivedPkts:  7104
   avgTput[kbps]:  1108.34

$ awk -f Instnt_Tput.awk vanetiaodv.tr    : OK
$ awk -f Instnt_Tput.awk vanet-infra.trn   : OK

$ awk -f t-put-Chauhan.awk vanetiaodv.tr
Average Throughput[kbps] = 583.45               StartTime=0.07  StopTime=998.99

$ awk -f THRU-irfan.awk vanetiaodv.tr
Average Throughput[kbps] = 592.57                StartTime=0.07 StopTime=998.99

$ awk -f THRU-irfan.awk vanet-infra.tr
Average Throughput[kbps] = -0.00                 StartTime=400.00       StopTime=0.00

$ perl packetloss.pl vanetiaodv.tr tcp
Percentage of tcp packets that were dropped: 0.000442926682346271%

$ perl packetloss.pl vanet-infra.tr cbr
Percentage of cbr packets that were dropped: 46.9183359013867%

$ awk -f nrm_rt_ld.awk vanetiaodv.tr
 Normalized Routing Load = 0.068

$ awk -f tess.awk vanetiaodv.tr
==> Average delay 2 =  0.342265 s
                     =  342.265 ms

$ awk -f tess.awk vanet-infra.tr
==> Average delay 2 =  0 s
                     =  0 ms

$ awk -f tess-Packets.awk vanetiaodv.tr
==> Average delay 2 =  0.342265 s
                     =  342.265 ms  # the file "Packets-arrival-time.txt" is created

$ awk -f PDR_zhibinwu.awk vanetiaodv.tr
142746 141931

$ awk -f pdr.awk vanetiaodv.tr
s:142746 r:141931, r/s Ratio:0.9943, f:22461

On Sunday, September 26, 2021 at 5:23:58 PM UTC+2 dnme...@gmail.com wrote:
Hi Knudfl,

Thank you. 

Can you pls help me to find below parameters:
1. Throughput 
2. Efficiency 
3. Packet loss ratio
4. Handoff 
5. Packet transmission rate

Durgesh Tiwari

unread,
Sep 27, 2021, 10:13:59 AM9/27/21
to Network Simulator 2 (NS2)
Thank you Sir. 

How to calculate Handoff and Efficiency? There is no script for that. 

Rajeshwari Madli

unread,
Sep 27, 2021, 10:34:50 AM9/27/21
to ns-u...@googlegroups.com
Handoff and its efficiency cannot be determined through scripts. 
You need to go through the backend code and capture data wherever needed. 

Durgesh Tiwari

unread,
Sep 27, 2021, 10:54:06 AM9/27/21
to Network Simulator 2 (NS2)
Thanks Rajeshwari. Can you pls provide some more details. 

pavan kumar

unread,
Sep 27, 2021, 12:15:44 PM9/27/21
to Network Simulator 2 (NS2)
Hi sir  can you share me the code for it 
Create a topology diagram and implement it in NS2 based on the following scenario.
There is a smart city having two road junctions of four roads, minimum of two RSU units, 2
two-lane roads, where vehicles cross each other. It is mandatory that there should be
communication between vehicles to vehicles and Vehicles to RSUs, i.e., mandatory to show the
V2V and V2R communication. Choose the best available routing algorithm (e.g., DSR, AODV,
DSDV etc) for your designed topology. TCP model should be used as a network model for
packet transmission. Show the performance of the topology based on the following parameters

knudfl

unread,
Sep 28, 2021, 1:37:46 PM9/28/21
to Network Simulator 2 (NS2)
@pk3... ,   Hi.

Please use SUMO to create the simulation / the required set of files for ns2.

$ git clone --recursive https://github.com/eclipse/sumo
Reply all
Reply to author
Forward
0 new messages