SUMO is the Simulation of Urban mobility software that enables to simulate the road traffic. Open Street map (www.openstreetmap.org) provides the xml based .osm file for any part of the world selected through their website. #openstreetmap
#SUMO can able to convert the osm file to its native xml file. The post tells you the simulation of a real traffic network and how it is ported to #ns2 for network animation and tracing.
Step 1: Prerequisites
Now you can run the above using sumo-gui guindy.sumo.cfg (now you can see as per the following screenshot)
Step 3: Exporting to NS2
from sumo trace to ns2, here is the step to do
Open terminal and type the following commands,
Just comment below if you need any queries (the above video will give you full information).
T S Pradeep Kumar
#SUMO can able to convert the osm file to its native xml file. The post tells you the simulation of a real traffic network and how it is ported to #ns2 for network animation and tracing.
Step 1: Prerequisites
- SUMO to be installed - in my case I installed sumo this way
sudo add-apt-repository pap:sumo/stable
sudo apt-get update
sudo apt-get install sumo sumo-doc sumo-tools
Also, Download the sumo source sumo-src-0.26.tar.gz from this link and unzip or untar it to the home directory (/home/pradeepkumar). There are some python files that are needed to generate random trips and to export xml files to tcl files. the commands sumo, sumo-gui will run only the graphical simulation.
Once the software is unzipped, set the SUMO_HOME in the environment, Open /home/pradeepkumar/.profile (for Linux Mint) and /home/pradeepkumar/.bashrc (for Ubuntu) and give this command (in my case the home is pradeepkumar, it might be different for you)
export SUMO_HOME=/home/pradeepkumar/sumo-0.26.0
- ns2 have to be installed - ns-2.35 is installed (Use this link to install ns2)
Step 2: Steps to create a Traffic
- Open browser and type http://www.openstreetmap.org and search a particular area and click export in the top.
- click "Manually select an area" and select the area (as shown in the video below) and click export again (it will download a file called map.osm, rename this file as per your convenience)
- Open the terminal and type the commands one by one (assume my file name is guindy.osm, so i maintain the same file name guindy for all the xml files)
$] netconvert --osm-files guindy.osm -o guindy.net.xml
Now, copy the osmPolyconvert.typ.xml from the $SUMO_HOME/data/typemap/ and copy it to the folder where you put all the files.
$] polyconvert --osm-files guindy.osm --net-file guindy.net.xml --type-file osmPolyconvert.typ.xml -o guindy.poly.xml
$] python $SUMO_HOME/tools/randomTrips. py -n guindy.net.xml -r guindy.rou.xml -e 100 -l
Now, create a new file (to be named as guindy.sumo.cfg) and paste the following lines
<configuration>
<input>
<net-file value="guindy.net.xml"/>
<route-files value="guindy.rou.xml"/>
<additional-files value="guindy.poly.xml"/>
</input>
<time>
<begin value="0"/>
<end value="100"/>
<step-length value="0.1"/>
</time>
</configuration>
Now you can run the above using sumo-gui guindy.sumo.cfg (now you can see as per the following screenshot)
SUMO |
Step 3: Exporting to NS2
from sumo trace to ns2, here is the step to do
Open terminal and type the following commands,
$] sumo -c guindy.sumo.cfg --fcd-output guindy.sumo.xml
$] python /home/pradeepkumar/sumo-0.26. 0/tools/traceExporter.py
--fcd-input guindy.sumo.xml --ns2config-output guindy.tcl
--ns2activity-output activity.tcl --ns2mobility-output mobility.tcl
This will generate three tcl files (guindy.tcl, activity.tcl and mobility.tcl). Among this activity.tcl might not be needed, but mobility.tcl file is mandatory)
The generated guindy.tcl have to be modified or altered as per the networking parameters like routing protocol, Mac layer, physical layer, link layer, etc.
You can see the following video for all the instructions.
A Sample TCL File for your Use
Here is the guindy.tcl file, you can use it for your purpose
Here is the guindy.tcl file, you can use it for your purpose
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_11 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 41 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
set opt(x) 4707
set opt(y) 3002
# ======================================================================
# Main Program
# ======================================================================
#
# Initialize Global Variables
#
set ns_ [new Simulator]
set tracefd [open guindy.tr w]
$ns_ trace-all $tracefd
set namf [open guindy.nam w]
$ns_ namtrace-all-wireless $namf $opt(x) $opt(y)
# set up topography object
set topo [new Topography]
$topo load_flatgrid $opt(x) $opt(y)
#
# Create God
#
create-god $val(nn)
#
# Create the specified number of mobilenodes [$val(nn)] and "attach" them
# to the channel.
# Here two nodes are created : node(0) and node(1)
# configure node
$ns_ node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace ON
for {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0 ;# disable random motion
$ns_ initial_node_pos $node_($i) 20
}
#
#
source mobility.tcl
set tcp [new Agent/TCP]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns_ attach-agent $node_(0) $tcp
$ns_ attach-agent $node_(22) $sink
$ns_ connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns_ at 10.0 "$ftp start"
#
# Tell nodes when the simulation ends
#
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at 100.0 "$node_($i) reset";
}
$ns_ at 100.0 "stop"
$ns_ at 100.01 "puts \"NS EXITING...\" ; $ns_ halt"
proc stop {} {
global ns_ tracefd
$ns_ flush-trace
close $tracefd
}
puts "Starting Simulation..."
$ns_ run
Just comment below if you need any queries (the above video will give you full information).
T S Pradeep Kumar
Thank you sir ..
ReplyDeleteexcellent helpfull sumo-vanets tutorial in research
Thank you very much...
DeleteCan this be used for NS-3
ReplyDeleteHello Sir,
ReplyDeleteCould you please help me to resolve the issue is faced while following the above instructions.
SORTING LISTS ...DONE!
ns: _o86 setdest 801806.63 1459904.04 0.00:
(_o86 cmd line 1)
invoked from within
"_o86 cmd setdest 801806.63 1459904.04 0.00"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o86" line 2)
(SplitObject unknown line 2)
invoked from within
"_o86 setdest 801806.63 1459904.04 0.00"
awesome work sir||
ReplyDeleteSir, how can I solve this error: couldn't read file "mobility.tcl": no such file or directory
ReplyDeletewhile executing
Sir, how to solve this error while running the tcl file for ns2
ReplyDeletecouldn't read file "mobility.tcl": no such file or directory
while executing
when i run polyconvert --osm-files guindy.osm --net-file guindy.net.xml --type-file osmPolyconvert.typ.xml -o guindy.poly.xml, on ubuntu terminal i faced Error: unable to open primary document entity '/home/aye/simulation/osmPolyconvert.typ.xml' how can i fix it? please these is urgent
ReplyDeletehello sir, i have the sumo-0.12.3 can i do this simulation with this version or i need the sumo-0.23 ?
ReplyDeleteDear,
ReplyDeleteI am getting this error when running
ns guindy.tcl
wrong # args: should be "set varName ?newValue?"
while executing
"set tracefd [open map.tr w]
(file "guindy.tcl" line 63)
How can I solve this?
Thanks.
Hello sir,
ReplyDeletePlease help. Want to convert my trace file(.tr) into a .csv or into excel format(.xls, xlsx) for machine learning purposes?
undefined reference to symbol 'pthread_mutexattr_settype@@GLIBC_2.2.5'
ReplyDelete//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:445: recipe for target 'sumo-gui' failed
make[3]: *** [sumo-gui] Error 1
make[3]: Leaving directory '/home/user15/sumo-0.12.3/src'
Makefile:496: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/user15/sumo-0.12.3/src'
Makefile:360: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/user15/sumo-0.12.3/src'
Makefile:265: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
trid to install SUMO 0.12.3 in ubuntu 16
.04 lts... during make command above error came... how to resolve it sir... please help
please give all files of drive link
ReplyDeleteplease sir give me all files drive link
ReplyDelete