Professional Documents
Culture Documents
Routing On Ad Hoc Networks
Routing On Ad Hoc Networks
Signed
.............................................................................................................
Mathieu Gallissot
School of Engineering
The Robert Gordon University, Aberdeen
May 2007
This report will cover the adaptation of the mechanism of routing into wireless
networks, in particular, Wifi.
I am also grateful to people who help me through in one way or another, as:
Mark Greiss, Yuan Yuan and Chih-Heng Ke for their tutorials and help on
NS-2.
All people on the NS-2 mailing list, especially Allaa Hilal and Manpreet
Grewal
ABSTRACT ................................................................................................................................................. IV
ACKNOWLEDGEMENTS ........................................................................................................................ V
1 INTRODUCTION ............................................................................................................................... 1
1.1 THE WIRELESS WORLD .................................................................................................................. 1
1.1.1 Infrastructure ................................................................................. 1
1.1.2 Ad Hoc ........................................................................................... 1
1.2 USAGE OF AD HOC NETWORKS ..................................................................................................... 2
1.2.1 Extending Coverage ........................................................................ 2
1.2.2 Communicating where no infrastructure exists .................................... 3
1.2.3 Community Networks ...................................................................... 3
1.3 PROBLEMS IN WIRELESS COMMUNICATIONS ................................................................................. 5
1.3.1 Security ......................................................................................... 5
1.3.2 Bandwidth ...................................................................................... 5
1.3.3 Energy ........................................................................................... 6
1.3.4 Asymmetric connections .................................................................. 6
1.4 ROUTING .......................................................................................................................................... 7
1.4.1 Definition ....................................................................................... 7
1.4.2 Routing in a wired environment ........................................................ 7
1.4.3 Routing problems in Ad Hoc networks ................................................ 8
1.5 AD HOC ROUTING PROTOCOLS ....................................................................................................... 9
1.5.1 Proactive ........................................................................................ 9
1.5.2 Reactive ......................................................................................... 9
1.5.3 Hybrids .........................................................................................10
2 PRO-ACTIVE PROTOCOLS ........................................................................................................ 11
2.1 DESTINATION SEQUENCED DISTANCE VECTOR (DSDV).......................................................... 11
2.1.1 Algorithm ......................................................................................11
2.1.2 Illustration ....................................................................................12
5.1.1 Performance ..................................................................................13
5.2 OPTIMIZED LINKED STATE ROUTING (OLSR) ........................................................................... 13
5.2.1 Algorithm ......................................................................................14
5.2.2 MultiPoint Relay (MPR) ....................................................................14
5.2.3 Performance ..................................................................................16
5.2.4 Implementation .............................................................................16
10.1 OTHER PROACTIVE PROTOCOLS ............................................................................................... 18
10.1.1 Fisheye State Routing (FSR) ............................................................18
10.1.2 Hierarchical State Routing (HSR) ......................................................19
10.1.3 Distance Routing Effect Algorithm for Mobility (DREAM) ......................19
11 REACTIVE PROTOCOLS ......................................................................................................... 20
24 CONCLUSION .............................................................................................................................. 47
REFERENCES ............................................................................................................................................. 48
BIBLIOGRAPHY....................................................................................................................................... 49
APPENDIX A ............................................................................................................................................. 50
THE SIMULATION SYSTEM ............................................................................................................................ 50
APPENDIX B.............................................................................................................................................. 60
INSTALLATION OF NS-2 UNDER UBUNTU 6.06.............................................................................................. 60
1.1.1 Infrastructure
The most known example of infrastructure wireless network is GSM and, more
recently, wifi. As said above, this mode is just using the wireless for the end
user loop, which means between the user terminal and a “radio terminal”. This
term “radio terminal” describes a Base station (for GSM), or an access point
(for wifi). Its role is basically to serve as a gateway between a wired network
(called distribution system) and its wireless zone.
Technically speaking, each “radio terminal” spreads a signal around, creating a
coverage zone. Each client is able to communicate within this zone, but then,
has to renegotiate with another “radio terminal” if available. The “radio
terminal” has the key role of referee in this kind of network, as each station
has to communicate only with its radio terminal.
Mobility is then limited to a coverage zone, and so, has a limited impact on
this implementation. This infrastructure design can be seen as a first way to
implement wireless technologies into the settled wired world. In fact, from the
technical point of view, only the first two layers are modified in the OSI model.
These changes concern only the physical layer (going from a wire to a wireless
media) and the Logical Link Control (LLC) layer (how to access the media).
Other layers of the OSI model are working as in a wired network.
1.1.2 Ad Hoc
Ad Hoc is an expression from the Latin which means “for this purpose”. Ad Hoc
networks introduce a new way of communication. Since communications
1.3.1 Security
Because the signal is diffused in the air, everybody is able to receive it. This is
a major problem for security. If people have the correct equipment for a
specific signal, they are able to use it (i.e. radio, TV…). Using a wireless
communication is equivalent to shouting information from the top of a roof.
One of the most effective ways for securing a wireless signal is to encrypt it
(encrypting data or even the signal).
1.3.2 Bandwidth
Wireless networks suffer from low and unreliable bandwidth. This problem is
due to the radio media. Many parameters can affect a radio liaison:
interferences, obstacles, mobility…etc
1.3.3 Energy
A known problem of radio links is the amount of energy they require, not only
for the amount of calculation needed for modulation, but mainly for the power
needed for the antenna.
When a device wants to communicate with a wire, it concentrates all the
energy on this wire. For wireless communication, antennas are usually omni-
directional, as they need much more energy. Also, the absorption in the air is
very important compared to wires.
1.4 Routing
1.4.1 Definition
Routing is the mechanism used in communications to find a path between two
entities. This is represented in the OSI model as the third layer (called
Network). The role of routing a network is similar to the role of a road map for
a post office, in both cases; we need to locate the destination, and more
importantly, the best way to reach it.
It especially has an important role, as the Internet was first designed for
military communications. Americans wanted a communication infrastructure
able to handle the fact that some part of a network core may be down. In this
case, a mechanism should redirect data to its destination.
As an OSI layer, this mechanism receives data “ready to send” from the upper
layer, then calculates the best path for the destination, and forwards it to layer
2. In the real world, this layer has a very limited role for computers, but, it is
the main role for routers, in a network core.
For other kinds of network, there are similar mechanisms. For mobile phones,
a database centralises the base station where each mobile is connected. This
database is used for every call to a mobile phone, providing the end
destination to the network core.
1.5.1 Proactive
Proactive protocols are close to wired routing protocols in the manner that the
routing table is built before the data has to be sent. That means these
protocols are constantly making requests to their neighbours (if any) in order
to draw a network topology, and then, build the routing table.
The disadvantage of this principle is to not be reactive to topology changes, as
the tables are pre-established. At the time the data has to be sent, it is not
certain that the gateway designed by the routing table will still be there to
forward the data.
1.5.2 Reactive
Reactive protocols are more specific to Ad Hoc networks. Contrary to the
proactive algorithm, they ask their neighbours for a route when they have
data to send. If the neighbours do not have any known route, they broadcast
1.5.3 Hybrids
A Hybrid protocol will use the two above algorithms. The main goal is to
reduce broadcasts and latency, but improve the dynamism impact. The whole
network will be separated into logical zones, and each zone will have a
gateway. Inside each zone, a reactive protocol will be used. For inter-zone
routing, a proactive protocol will be used.
2.1.1 Algorithm
DSDV is based on the Bellman-Ford algorithm. First designed for graph search
applications, this algorithm is also used for routing since it is the one used by
RIP. With DSDV, each routing table will contain all available destinations, with
the associated next hop, the associated metric (numbers of hops), and a
sequence number originated by the destination node.
Tables are updated in the topology per exchange between nodes. Each node
will broadcast to its neighbours entries in its table. This exchange of entries
can be made by dumping the whole routing table, or by performing an
2.1.2 Illustration
Let us consider the two following topologies (figure 2-1 and figure 2-2). At
t=0, the network is organized as shows figure 2-1. We suppose at this time the
network is stable, each node has a correct routing table of all destinations.
2.1.3 Performance
As with every table-driven protocol, DSDV reduces the latency by having a
route when the data has to be sent. But, DSDV presents a few problems,
mainly in the route table update process. One of the major problems is that
data is exchanged only between neighbours, and then, a change in the
topology can take time to be spread in the whole topology. That introduces the
notion of route fluctuation. When a node disappears, it takes time for this
change to be reflected in the whole topology. So, if the topology is dynamic,
the routing layer will be unstable until changes are reflected everywhere.
This route fluctuation problem can be demonstrated with the example in
chapter 2.1.2. Updates are sent after events, links broken and new links. At
t+1, the routing protocol will transmit routing table updates according to the
newly detected events. But, once these updates are processed by nodes D, B
and E, nodes C and D still have no routes for G, and it will take two more
updates until the entire topology will be updated on all nodes.
2.2.3 Performance
OLSR increases performance comparing to DSDV, due to the multipoint relay
mechanism. This mechanism reduces the amount of data exchanged by
avoiding useless transmissions such as duplicates. MPR also reflects changes
quicker in the topology by reducing the route fluctuation impact in a mobile
environment.
So, compared to DSDV, OLSR is quicker and uses less control traffic. But, on
large topologies, OLSR is still vulnerable to quick network changes.
2.2.4 Implementation
OLSR has been widely implemented, especially for community networks. This
protocol is available for both Linux and Windows operating systems. The most
famous implementation of OLSR is olsrd, published as open source software
per OLSR.ORG. In addition to the protocol specification, this implementation
includes a link quality extension. A few plugins are also available, such as:
HTTPInfo, a plugin giving information about protocol statistics through a
web page
Nameservice, a plugin acting as a name server for Ad Hoc networks. This
plugin is useful as Ad Hoc networks can be infrastructure-less, and does
not necessarily have a DNS server.
3.1.1 Algorithm
The AODV algorithm is inspired from the Bellman-Ford algorithm like DSDV.
The principal change is to be On Demand. The node will be silent while it does
not have data to send. Then, if the upper layer is requesting a route for a
packet, a “ROUTE REQUEST” packet will be sent to the direct neighbourhood.
If a neighbour has a route corresponding to the request, a packet “ROUTE
REPLY” will be returned. This packet is like a “use me” answer. Otherwise,
each neighbour will forward the “ROUTE REQUEST” to their own
neighbourhood, except for the originator and increment the hop value in the
packet data. They also use this packet for building a reverse route entry (to
the originator). This process occurs until a route has been found.
Another part of this algorithm is the route maintenance. While a neighbour is
no longer available, if it was a hop for a route, this route is not valid anymore.
AODV uses “HELLO” packets on a regular basis to check if they are active
neighbours. Active neighbours are the ones used during a previous route
discovery process. If there is no response to the “HELLO” packet sent to a
3.1.2 Illustration
3.1.3 Implementation
Table 3-1 shows the list of available implementations of AODV. Some are
proposing improvements such as multicast and ipv6 compatibility.
Name IP Operating Systems License Comments
AODV-UCSB 4 Free BSD BSD Compliant with AODV Draft
v6 (No longer supported)
AODV-UIUC 4 Linux GNU
Net
AODV-UU 4 Linux, Embedded Linux GNU RFC 3561 Compliant
AODV-UU for 6 Linux GNU AODV for IPv6
IPv6
AODV for 4 MS Windows XP ?
Windows
HUT AODV for 6 Linux BSD AODV IPv6 draft 01
IPv6
KERNEL-AODV 4 Linux ? RFC 3561 Compliant
MAODV 4 Linux GNU Multicast AODV, based on
AODV-UU
TinyAODV n/a TinyOS BSD Simplified version of AODV
for TinyOS
UoB-JAdhoc 4 Linux, Windows (XP & GPL RFC 3561 Compliant
2000), Embedded Linux
UoBWinAODV 4 Windows XP Mixed RFC 3561 Compliant
WinAODV 4 Windows XP & Windows GNU RFC 3561 Compliant
CE
Table 3-1: List of available AODV implementation
3.2.1 Algorithm
DSR uses explicit source routing, which means that each time a data packet is
sent, it contains the list of nodes it will use to be forwarded. In other terms, a
sent packet contains the route it will use. This mechanism allows nodes on the
route to cache new routes, and also, allows the originator to specify the route
it wants, depending on criteria such as load balancing, QoS… This mechanism
also avoids routing loops.
4.1 Definition
The Zone Routing Protocol (ZRP) is the reference in terms of hybrid protocol.
Initiated by staff of the Cornell University, it is a hybrid routing framework
using both reactive and proactive ad hoc routing protocol. Even if this
proposition has been rejected by the MANET group, it still stands as the most
advanced hybrid routing project for Ad Hoc networks.
ZRP relies on the simple fact that nearest changes are the most important. So,
in order to reduce useless traffic on the topology, the approach is to define
zones for each node. Inside each zone, a proactive routing protocol will be
used. This proactive protocol will be defined as IntrAzone Routing Protocol
(IARP) in the ZRP protocol, in opposition to the IntErzone Routing Protocol
(IERP) which will be used for finding a route outside the defined zone. This
inter-zone routing protocol will be a reactive protocol. ZRP did not define any
specific protocol for IARP. In fact, ZRP is more a framework than an entire
solution, and then, IARP and IERP are free to be chosen
5.1.3 Observations
The complexity of NS-2 was the main problem of my experiments. A beginner
in C++ and a stranger to the TCL family, it took me time to understand how to
process. The installation of this software reported bugs at the compilation
stage, so, I had to correct a few files. The integration of ZRP was also a
problem. Created for a different structure of NS-2, I had to adapt a few parts
of its code. Also, ZRP‟s C++ code was erroneous. A lot of warnings related to
the C++ syntax were reported while compiling. I first ignored these errors but
simulations ends prematurely with a segmentation fault. So, after correcting
all these errors, and using debugging options with the compiler, I was able to
run simulations. But, after a few seconds, memory leaks appeared. Despite
my efforts, I was unable to correct this error, and I could not integrate ZRP
into my simulation system.
9.1.3.1 DSDV
Figure 5-9 shows a simulation with 20 nodes, a random speed range between
0 and 5 meters per second, and a 500 square meters topology. Traffic
between nodes is set to start after 2 seconds.
9.1.3.3 AODV
Figure 5-11 shows a simulation with 30 nodes, a random speed range between
0 and 10 meters per second, and a 500 square meters topology. Traffic
between nodes is set to start after 2 seconds.
9.1.3.4 DSR
Figure 5-12 shows a simulation with 30 nodes, a random speed range between
0 and 5 meters per second, and a 500 square meters topology. Traffic
between nodes is set to start after 2 seconds.
Zygmunt Haas, Marc Pearlman and Prince Samar “The Zone Routing
Protocol (ZRP) for Ad Hoc Networks”
BIBLIOGRAPHY
Wikipedia
http://en.wikipedia.org
ZRP homepage
http://www.zrp.be
NS-2 official website
http://www.isi.edu/nsnam/ns
OLSR developer team:
http://www.inria.fr
Andrew Tanenbaum
“Les Réseaux”
Tayeb Lemlouma
Thomas Clausen
SQL Script
The following script was used for creating the tables in the project database.
Data format was selected in order to reduce the overall size of data.
Perl 1 Script
The Perl 1 script (See figure 5-1 and figure 5-2) was the script used in order
to compute simulation scenarios. Some of the parameters of this script are
hard coded and were changed (topology size and speed).
1 #!/usr/bin/perl -w
2 $routingp[0] = "DSDV";
3 $routingp[1] = "AODV";
4 $routingp[2] = "DSR";
5 $routingp[3] = "OLSR";
6 $nbnode = 100;
7 $speed=10;
8 $size=2000;
9
10 if (! -e "/home/project/simulation/log") { system("touch
/home/project/simulation/log") ; }
11 open(LOG,">>/home/project/simulation/log") || die "Erreur de
lecture /home/project/simulation/log, Erreur: $!";
12 $m=0;
13 while(TRUE) {
14 if($m==4) { exit(); }
15 for($l=2; $l<$nbnode; $l = $l+1) {
16 $home_folder = "/home/project/simulation/".$routingp[$m];
17 $work_folder = $home_folder."/".$l;
18 if (! -d "$work_folder") {
19 print "Creating home folder $work_folder\n";
20 mkdir ($work_folder);
21 }
22 $k=1;
23 while (-e "$work_folder/$k.tcl") {
24 $k++;
25 }
26
27 $mapx = $size;
28 $mapy = $size;
29
30 print LOG "Start simulation with routing protocol
$routingp[$m]\t mobile node = $l \t instance $k\n";
31 system("touch $work_folder/$k.tcl");
32 open(FILE,">$work_folder/$k.tcl") || die "Erreur de lecture
$work_folder/$k.tcl, Erreur: $!";
33 init();
34 place_nodes();
35 generate_movement();
36 generate_traffic();
37 finish();
38
39 sub init {
40 print FILE "# Define options
41 set val(chan) Channel/WirelessChannel
;# channel type
42 set val(prop) Propagation/TwoRayGround
;# radio-propagation model
43 set val(netif) Phy/WirelessPhy
;# network interface type
44 set val(mac) Mac/802_11
;# MAC type\n";
45 if ($m==3) {
46 print FILE "set val(ifq) CMUPriQueue
;# interface queue type\n";
47 }
48 else { print FILE "set val(ifq)
Queue/DropTail/PriQueue ;# interface queue type\n"; }
49 print FILE " set val(ll) LL
;# link layer type
50 set val(ant) Antenna/OmniAntenna
;# antenna model
51 set val(ifqlen) 50
;# max packet in ifq
52 set val(nn) $l
;# number of mobilenodes
53 set val(rp) $routingp[$m]
;# routing protocol
54 set val(x) $mapx ;# X
dimension of topography
55 set val(y) $mapy ;# Y
dimension of topography
56 set val(stop) 15 ;# time of
simulation end
57 set ns [new Simulator]
58 set tracefd [open $work_folder/$k.trace.tr
w]
59
60 \$ns trace-all \$tracefd
61 # set up topography object
62 set topo [new Topography]
63
64 \$topo load_flatgrid \$val(x) \$val(y)
65
66 create-god \$val(nn)
67
68 #
69 # Create nn mobilenodes [\$val(nn)] and attach
them to the channel.
70 set chan_1_ [new \$val(chan)]
71
72 # configure the nodes
73 \$ns node-config -adhocRouting \$val(rp) \\
74 -llType \$val(ll) \\
75 -macType \$val(mac) \\
76 -ifqType \$val(ifq) \\
77 -ifqLen \$val(ifqlen) \\
78 -antType \$val(ant) \\
79 -propType \$val(prop) \\
80 -phyType \$val(netif) \\
81 -channel \$chan_1_ \\
82 -topoInstance \$topo \\
83 -agentTrace ON \\
84 -routerTrace ON \\
85 -macTrace OFF \\
86 -movementTrace ON
87
88 for {set i 0} {\$i < \$val(nn) } { incr i } {
89 set node_(\$i) [\$ns node]
90 }\n";
91 }
92
93 sub place_nodes {
94 print FILE "# Provide initial location of mobilenodes
95 for {set i 0} {\$i < \$val(nn) } { incr i } {
96 \$node_(\$i) set X_ [expr ($mapx*rand())]
97 \$node_(\$i) set Y_ [expr ($mapy*rand())]
98 \$node_(\$i) set Z_ 0.0
99 }
100 ";
101 }
102
103 sub generate_movement {
104 print FILE "# Generation of movement
105 for {set i 0} {\$i < \$val(nn) } {incr i} {
106 for {set j 0} {\$j < \$val(stop) } {set j [expr
{\$j + 10}]} {
107 \$ns at \$j \"\$node_(\$i) setdest [expr
($mapx*rand())] [expr ($mapy*rand())] [expr (10+$speed*rand())]\"
108 }
109 }
110 ";
111 }
112 sub generate_traffic {
113 for($i=0; $i<$l-1; $i = $i+2) {
114 print FILE "# Generation of traffic
115 set tcp$i [new Agent/TCP/Newreno]
116 \$tcp$i set class_ 2
117 set sink$i [new Agent/TCPSink]
118 \$ns attach-agent \$node_($i) \$tcp$i
119 \$ns attach-agent \$node_(".($i+1).") \$sink$i
120 \$ns connect \$tcp$i \$sink$i
121 set ftp$i [new Application/FTP]
122 \$ftp$i attach-agent \$tcp$i
123 \$ns at 2.0 \"\$ftp$i start\"
124 ";
125 }
126 }
127
128 sub finish {
129 print FILE "
130
131
132 # Telling nodes when the simulation ends
133 for \{set i 0\} \{\$i < \$val(nn) \} \{ incr i \}
\{
134 \$ns at \$val(stop) \"\$node_(\$i) reset\";
135 \}
136
137 # ending nam and the simulation
138 \$ns at \$val(stop) \"stop\"
139 \$ns at 150.01 \"puts \\\"end simulation\\\" ; \$ns
halt\"
140 proc stop \{\} \{
141 global ns tracefd
142 \$ns flush-trace
143 close \$tracefd
144 \}
145
146 \$ns run
147 ";
148 }
149 close(FILE);
150 system ("ns $work_folder/$k.tcl");
151 }
152 $m++;
153 }
154
155 close(LOG);
Perl 2 Script
This script was used in order to extract the main information of each
simulation and put this data into the “simulation” table of the project database
(see figure 5-1 and figure 5-3).
1 #!/usr/bin/perl -w
2 use Switch;
3 use DBI;
4 $dbh = DBI->connect(
"DBI:mysql:database=project;host=localhost",
5 "project",
6 "project",
7 {'RaiseError' => 1}
8 );
9
10 $folder[0]="sim100-5-500";
11 $folder[1]="sim100-10-500";
12 $folder[2]="sim100-10+5-500";
13 $folder[3]="sim100-5-2000";
14 $folder[4]="sim100-10-2000";
15 $folder[5]="sim100-10+5-2000";
16
17 $size[0]=500;
18 $size[1]=2000;
19
20 $speed[0]="5";
21 $speed[1]="10";
22 $speed[2]="10+10";
23
24 $routingp[0] = "DSDV";
25 $routingp[1] = "AODV";
26 $routingp[2] = "DSR";
27 $routingp[3] = "OLSR";
28
29 $index=1;
30
31 for($i=0; $i<6; $i++) {
32 for($m=0; $m<4; $m++) {
33 $home_folder =
"/home/project/".$folder[$i]."/".$routingp[$m];
34 for($l=2; $l<100; $l++) {
35 $work_folder = $home_folder."/".$l;
36 $filename=$work_folder."/1.trace.tr";
37 if ($i<3) { $n=0; }
38 else { $n=1; }
39 if ( $i==0 || $i==3 ) { $o = 0; }
40 if ( $i==1 || $i==4 ) { $o = 1; }
41 if ( $i==2 || $i==5 ) { $o = 2; }
42 open(FILE,"<$filename");
43 if (FILE) {
44 @file = <FILE>;
45 foreach $line (@file) {
46 @words = split(/ /, $line);
47 if($words[0] eq "M") { $moves++;}
48 if($words[0] eq "D" || $words[0] eq "d") {
49 if($words[4] eq "NRTE") {
50 $traffic_size+=$words[7];
51 }
52 else { $dropped_size+=$words[8]; }
53 $dropped_packets++;
54 }
55 if($words[0] eq "s" || $words[0] eq "r")
56 { if($words[3] eq "AGT") {
57 $traffic_packet++;
58 $traffic_size+=$words[8];
59 }
60 else {
61 if($words[3] eq "RTR") {
62 if($words[7] eq "tcp" || $words[7]
eq "ack") {
63 }
64 else {
65 $routing_packet++;
66 $routing_size+=$words[8];
67 }
68 }
69 }
70 }
71 $duration = $words[1];
72 }
73 close(FILE);
74 }
75 else { $duration=0; }
76 $query = "INSERT INTO simulation (
77 sim_id,
78 nodes,
79 duration,
80 topology,
81 speed,
82 protocol,
83 filename,
84 dropped_packets,
85 dropped_size,
86 routing_packet,
87 routing_size,
88 traffic_packet,
89 traffic_size,
90 moves
91 )
92 VALUES (
93 '$index',
94 '$l',
95 '$duration',
96 '$size[$n]',
97 '$speed[$o]',
98 '$routingp[$m]',
99 '$filename',
100 '$dropped_packets',
101 '$dropped_size',
102 '$routing_packet',
103 '$routing_size',
104 '$traffic_packet',
105 '$traffic_size',
106 '$moves'
107 );";
108 print "sim_id '$index', nodes '$l', duration
'$duration', topology '$size[$n]', speed '$speed[$o]', protocol
'$routingp[$m]'\n";
109 $sth = $dbh->prepare($query);
110 $res = $sth->execute;
111 $index++;
112 }
113 }
114 }
Perl 3 script
This script is similar to the last one except it parses trace files in detail and put
each trace into the „trace‟ table of the project database (see figure 5-1 and
figure 5-3).
1 #!/usr/bin/perl -w
2 use Switch;
3 use DBI;
4 $dbh = DBI->connect(
"DBI:mysql:database=project;host=localhost",
5 "project",
6 "project",
7 {'RaiseError' => 1}
8 );
9
10 $folder[0]="sim100-5-500";
11 $folder[1]="sim100-10-500";
12 $folder[2]="sim100-10+5-500";
13 $folder[3]="sim100-5-2000";
14 $folder[4]="sim100-10-2000";
15 $folder[5]="sim100-10+5-2000";
16
17 $size[0]=500;
18 $size[1]=2000;
19
20 $speed[0]="5";
21 $speed[1]="10";
22 $speed[2]="10+10";
23
24 $routingp[0] = "DSDV";
25 $routingp[1] = "AODV";
26 $routingp[2] = "DSR";
27 $routingp[3] = "OLSR";
28 open(LOG,">>/home/project/traces_log");
29 $index=1;
30 for($i=0; $i<6; $i++) {
31 for($m=0; $m<4; $m++) {
32 #$home_folder =
"/home/project/".$folder[$i]."/".$routingp[$m];
33
34
35 for($l=2; $l<100; $l++) {
36 $query = "SELECT `filename` FROM `simulation` WHERE
sim_id =$index";
37 $sth = $dbh->prepare($query);
38 $res = $sth->execute;
39 $row = $sth->fetchrow_hashref;
40 print $row->{filename}."\n";
41 $filename=$row->{filename};
42 #$work_folder = $home_folder."/".$l;
43 #$filename=$work_folder."/1.trace.tr";
44 if ($i<3) { $n=0; }
45 else { $n=1; }
46 if ( $i==0 || $i==3 ) { $o = 0; }
47 if ( $i==1 || $i==4 ) { $o = 1; }
48 if ( $i==2 || $i==5 ) { $o = 2; }
49 open(FILE,"<$filename");
50 if (FILE) { @file = <FILE>;}
51 else { @file={0}; }
52 foreach $line (@file) {
53 @words = split(/ /, $line);
54 @node = split(//, $words[2]);
55 if($words[0] eq "M") {
56 $query = "INSERT INTO traces (
57 sim_id,
58 event,
59 time,
60 node
61 )
62 VALUES (
63 '$index',
64 'M',
65 '$words[1]',
66 '$words[2]'
67 );";
68 }
69 else { $query = "INSERT INTO traces (
70 sim_id,
71 event,
72 time,
73 node,
74 layer,
75 type,
76 size)
77 VALUES (
78 '$index',
79 '$words[0]',
80 '$words[1]',
81 '$node[1]',
82 '$words[3]',
83 '$words[7]',
84 '$words[8]'
85 );";
86
87 }
88 #print LOG "sim_id $index,event $words[0],time
$words[1],node $node[1],layer $words[3],type $words[7],size $words[8]\n";
89 $sth = $dbh->prepare($query);
90 $res = $sth->execute;
91 }
92 close(FILE);
93 $index++;
94 }
95 }
96 }
97 close(LOG);
The installation can be tested by executing a test script (see output of the
install script).
More specifically, for NS-2, a correction has to be made on the file ns-allinone-
2.31/ns-2.31/mac/wireless-phy.cc, line 55, the line redefining “MAX” should
be commented as it is already defined as per a header file.
In order to install OLSR, the archive containing the code should be
downloaded on the UM-OLSR webpage. This package contains a patch file with
code. The patch file will do all the work. There might be some conflicts
depending of the version (latest version supported of NS-2 is 2.29), but these
conflicts are minor and can be easily recovered. The patch will add OLSR
entries into NS-2 common code.
NS-2 must be recompiled after this new addition.
#cd ns-allinone-2.31/ns-2.31/
#make clean
#./configure –-enable-debug
#make
#make install
The installation of ZRP is a bit more complex. The latest version supported for
NS-2 is more than 3 years old. It is also given with a patch file. This file can
be modified in order to reflect the changes over the last versions (a few
number of lines to change).
The code has also to be modified since the new version of C++ compiler
requires a correct syntax. The code must be changed as variables in
constructors must be declared in the same order they are used in the
constructor‟s arguments.