Professional Documents
Culture Documents
A Review of the DSDV and AODV Ad-Hoc Routing Protocols and their Implementation in Network Simulator 2
Supervised By:
Inayat Ullah
DEPARTMENT OF COMPUTER SCIENCE &IT SARHAD UNIVERSITY OF SCIENCE & INFORMATION TECHNOLOGY, PESHAWAR
APPROVAL CERTIFICATE
SARHAD University of Science and Information Technology Ring Road Peshawar, Pakistan COMPUTER SCIENCE & IT Department
CERTIFICATE
This is to certify that the project thesis entitled A Review of the DSDV and AODV Ad-Hoc Routing Protocols and their Implementation in Network Simulator 2 is prepared by
Nasir Ahmad Reg No: SU/08-01-03028. Students of final year BS Telecom have satisfactory completed their work. Approved: Examiner Chairman
_______________
_______________
Supervisor _____________
ii
iii
Table of Contents
TITLE................................................................. 1-2 TABLE OF CONTENTS ..............................................................................3 LIST OF TABLES ...................................................................................... 3 LIST OF FIGURES ..................................................................................... 3 ABSTRACT ................................................................................................. 4 ACKNOWLEDGEMENTS ......................................................................... 5 CHAPTER 1 INTRODUCTION 1.1.1 WIRELESS COMMUNICATIONS .........1 1.1.2 WIRELESS NETWORKS ........2 1.1.3 MODES .....3 1.1.4 INFRA STRUCTURED NETWORK ......3 1.1.5 MOBILE AD HOC NETWORK ..4 1.2 AD-HOC NETWORK VS MOBILE AD HOC NETWORK .....5 1.3 HISTORY OF ROUTING PROTOCOLS IN MANETS ....8 1.4 APPLICATIONS OF MOBILE AD-HOC NETWORK.........8 1.5 ISSUES IN MANETS.......................8 CHAPTER 2 MANETS ROUTING PROTOCOLS 2.1 MANETS ROUTING PROTOCOLS. .....16 2.2 CLASSIFICATION OF AD-HOC ROUTING PROTOCOLS..17 2.2.1 PROACTIVE TABLE DRIVEN ROUTING PROTOCOLS ...17 2.2.1.1 DSDV...........18 2.2.1.2 CGSR................................................................................................................19 2.2.2 SOURCE INITIATED ON DEMAND ROUTING PROTOCOLS .20 2.2.2.1 AODV .....21 2.2.2.2 DSR ...23 2.2.2.3 TORA 26 2.2.2.4 ABR ...28 CHAPTER 3 INSTALLATION OF NETWORK SIMULATOR 3.1 INSTALING NS 2.35........31 3.2 LIVING UNDER NS2.......35 3.2.1 A SIMPLE SIMULATION ..36 3.3 NS BY EXAMPLE ...39 3.3.1 CODE FOR SIMPLE PROGRAM.....40
[Review and implementation of dsdv and aodv in network simulator 2] 3
CHAPTER 4 TOOL COMMAND LANGUAGE 4.1 TOOL COMMAND LANGUAGE..43 4.2 TOOL COMMANDS...43 4.2.1 VARIABLES.44 4.2.2 COMMAND SUBSTITUTION....44 4.2.3 MATH EXPRESSION..44 4.2.4 BACKSLASH SUBSTITUTION..44 4.2.5 GROUPING WITH BRACES AND DOUBLE QUOTES .45 4.2.6 PROCEDRE..45
CHAPTER 5 SIMULATIONS AND RESULTS 5.1 SIMULATIONS AND RESULTS ....47 CHAPTER 6 CONCLUSION AND FUTURE WORK 6.1 CONCLUSION AND FUTURE WORK...54 REFERENCES.....55
List of Tables
1.1 classification of security attacks.9 4.1 Arithmetic operators in tcl .....12 5.1 Simulation metrics......13
List of figures
Figure 1.1 wireless communication.1 Figure 1.2 wireless network....2 Figure 1.3 infra structured network 1..3 Figure 1.4 infra structured network 2......4 Figure 1.5 mobile ad hoc network ..5 Figure 1.6 mobile ad hoc hybrid network...7 Figure 2.1 ad hoc routing protocols12 Figure 2.1a MANETs routing protocols classification ..13 Figure 2.2 dsdv Operation ..........14 Figure 2.3 cgsr Operation ......16 Figure 2.4 aodv Operation .....18 Figure 2.5 dsr Operation 1......20 Figure 2.6 dsr Operation 2......21 Figure 2.7 tora Operation .......23 Figure 3.1 network simulation directory ........33 Figure 3.2 simple simulation ..........34 Figure 4.1 tcl puts.....35 Figure 4.2 tcl variables.....36 Figure 4.3 tcl command substitution....36
Figure 4.4 tcl back slash substitution...36 Figure 4.5 tcl Grouping with Braces and Double Quotes .....36 Figure 4.6 tcl procedure..37 Figure 5.1 6 node simulation of dsdv in nam.....39 Figure 5. 2 simulation of dsdv at nam for 0 sec.....40 Figure 5.3simulation of dsdv on 6 nodes before mobility of node 5.....40 Figure 5.4. simulation of dsdv on 6 nodes after mobility of node 5..........41 Figure 5.5 node 5 information.....41 Figure 5.6 start simulation of aodv in nam......42 Figure 5.7. aodv using 3 nodes........42 Figure 5.8 node 0 send packet to node 2 before mobility...43 Figure 5.9 node 1 forward only to node0 .......43 Figure 5.10 node 0 send packet to node 2 after 4.0 ms with mobility.....44 Figure 5.11 mobility factors were defined for node 0 and node 2 not for node1........44
ABSTRACT
The aim of this project is to implement the two most common ad hoc routing protocols DSDV (destination sequence distance vector) and AODV (ad hoc on demand distance vector) in network simulator 2 for different network environments. The mobility factor can be easily calculated from the network amulator. In MANETs (Mobile Ad Hoc Networks) communication at the mobile nodes can be achieved by using multi hop wireless links. The architecture of such network is based not on a centralized base station but on each node which acts as a router and forwards data packets to other nodes in the network. The aim of each protocol, in an ad-hoc network, is to find valid routes between two communicating nodes. These protocols must be able to handle high mobility of the nodes which often cause changes in the network topology. This thesis includes installation of network simulator 2.34 and basics of some important languages like C++ and TCL (tool command language). This thesis also includes how to write a simple program in ns2 and its implementation. It also gives overview and implementation, of two ad-hoc network protocols (DSDV and AODV) in different network scales taking into consideration the mobility factor, on network simulator- 2. This thesis is organized as follows. In Section II, a description of DSDV and AODV routing protocols are presented. In Section III, the ns2 software installation and tool command language. and the metric that are taken into consideration in the simulation are given whilst the results are presented in Section IV. Section V concludes the thesis and proposes ideas for future work. Keywords: Ad-hoc Network, Sensor Network, Power Aware Routing, Routing Protocols, AODV, DSDV,
ACKNOWLEDGMENTS
Special thanks to my supervisor Inayat ullah who taught me and guide me throughout in this work. I am thankful to him for giving me opportunity of working in network simulator and especially for the different general parameters used in different routing protocols and also for how to install and work in network simulator clearly and logically, and for supporting this work in ways too numerous to list. Also the analysis of the data generated was only possible under his supervision. I thank him wholeheartedly for accepting the difficult task of overseeing this work to completion and for taking time out of her busy schedule to consider this work.
CHAPTER#1 INTRODUCTION
1.1 Introduction
1.1.1 Wireless communication
Wireless communication is the transfer of information between two or more points that are not connected by an electrical conductor. The most common wireless technologies use electromagnetic wireless telecommunications, such as radio. With radio waves distances can be short, such as a few meters for television remote control, or as far as thousands or even millions of kilo metres for deep-space radio communications. It encompasses various types of fixed, mobile, and portable applications, including two-way radios, cellular telephones, personal digital assistants (PDAs), and wireless networking. Other examples of applications of radio wireless technology include GPS units, garage door openers, wireless computer mice, keyboards and headsets, headphones, radio receivers, satellite television, broadcast television and cordless telephones.
To span a distance beyond the capabilities of typical cabling, To provide a backup communications link in case of normal network failure, To link portable or temporary workstations, To overcome situations where normal cabling is difficult or financially impractical, or To remotely connect mobile users or networks.
1.1.3 Modes
Wireless communications can be via:
radio communication, microwave communication, for example long-range line-of-sight via highly directional antennas, or short-range communication, light, visible and infrared (IR) for example consumer IR devices such as remote controls or via Infrared Data Association (IrDA). sonic, especially ultrasonic short range communication electromagnetic induction short range communication and power
Applications may involve point-to-point communication, point-to-multipoint communication, broadcasting, cellular networks and other wireless networks. There are two types of mobile wireless network 1. Infra structured network 2. Mobile Ad hoc network
A Mobile Ad hoc network (MANET) is a kind of wireless ad-hoc network, and is a selfconfiguring network of mobile routers (and associated hosts) connected by wireless links the union of which forms an arbitrary topology. The routers are free to move randomly and organize themselves arbitrarily; thus, the network's wireless topology may change rapidly and unpredictably. Such a network may operate in a standalone fashion, or may be connected to the larger Internet. The main features of MANET are: a) Route: between nodes may contain multiple hops b) Rapidly deployable: due to self-configuring capability c) Dynamic: changes in network topology.
Mobile applications present additional challenges for mesh networks as changes to the network topology are swift and widespread. Such scenarios require the use of Mobile Ad hoc Networking (MANET) technology to ensure communication routes are updated quickly and accurately. MANETs are self-forming, self-maintained, and self-healing, allowing for extreme network flexibility. While MANETs can be completely self contained, they can also be tied to an IP-based global or local network (e.g. Internet or private networks). These are referred to as Hybrid MANETs. As you can see below in figure we have three self-configuring mobile routers connected by wireless links creating MANET. However, as the routers approach the other two IP based global forming a hybrid MANET. A mobile ad-hoc network (MANET) is a self-configuring network of mobile routers (and associated hosts) connected by wireless links - the union of which form a random topology. The routers are free to move randomly and organize themselves at random; thus, the network's wireless topology may change rapidly and unpredictably. Such a network may operate in a standalone fashion, or may be connected to the larger Internet. Minimal configuration and quick deployment make ad hoc networks suitable for emergency situations like natural or human induced disasters, military conflicts, emergency medical situations etc.
The unique characteristics of MANETs pose a number of nontrivial challenges to security design. Like Open peer-to-peer network architecture, Shared wireless medium, No clear line of defense, Stringent resource constraints and Highly dynamic network topology. The main assumption of the previously presented ad hoc routing protocols is that all anticipating nodes do so in good faith and without maliciously disrupting the operation of the protocol. However, the existence of malicious entities cannot be disregarded in any system, especially in open ones like ad hoc networks. In ad hoc network the routing function can be disrupted by internal or external attackers. An internal attacker can be any legitimate participant of the routing protocol. An external attacker is defined as any other entity. Cryptographic solutions can be employed to prevent the impact of external attackers by mutual authentication of the participating nodes through digital signature schemes [14]. However, the underlying protocols should also be considered since an attacker could manipulate a lower level protocol to interrupt a security mechanism in a higher level. Internal attackers having capability to complete access the communication link they are able to advertise false routing information at will and force arbitrary routing decisions on their peers.
A. Security Goals
Authentication Confidentially Integrity Availability Non-repudiation Access Control Malicious and selfish nodes are the ones that fabricate attacks [14] against physical, link, network, and application layer functionality. Current routing protocols are exposed to two types of attacks:
A. Active Attacks
Active attacks are the attacks that are performed by the malicious nodes that bear some energy cost in order to perform the attacks. Active attacks involve some modification of data stream or creation of false stream. These attacks can be classified into further following types: 1. Spoofing: Spoofing occurs when a malicious node misrepresents its identity in order to alter the vision of the network topology that a benign node can gather.
2. Fabrication:
The notation fabrication is used when referring to attacks performed by generating false routing messages. Such kind of attacks can be difficult to identify as they come as valid routing constructs, especially in the case of fabricated routing error messages, which claim that a neighbor can no longer be contacted [10].
3. Wormhole Attack:
An attacker records packets at one location in the network and tunnels them to another location. Routing can be disrupted when routing control messages are tunneled. This tunnel between two colluding attackers is referred as a wormhole.
B. Passive Attacks
In passive attacks the attacker does not perturb the routing protocol, instead try to extract the valuable information like node hierarchy and network topology from it. Passive attack is in nature of eavesdropping on, or monitoring of, transmission. The goal of opponent is to obtained information that is being transmitted [10]. Passive attacks are very difficult to detect because they do not involve any alteration of data.
Black hole attack Byzantine attack Rushing attack Replay attack Location disclosure attack
Despite being designed for the same type of underlying network, the characteristics of each of these protocols are quite distinct.
The mobile nodes maintain an additional table where they store the data sent in the incremental routing information packets. New route broadcasts contain the address of the destination, the number of hops to reach the destination, the sequence number of the information received regarding the destination, as well as a new sequence number unique to the broadcast. The route labeled with the most recent sequence number is always used. In the event that two updates have the same sequence number, the route with the smaller metric is used in order to optimize (shorten) the path. Mobiles also keep track of the settling time of routes, or the weighted average time that routes to a destination will fluctuate before the route with the best metric is received. By delaying the broadcast of a routing update by the length of the settling time, mobiles can reduce network traffic and optimize routes by eliminating those broadcasts that would occur if a better route was discovered in the very near future.
Gateway nodes are nodes that are within communication range of two or more cluster heads. A packet sent by a node is first routed to its cluster head, and then the packet is routed from the cluster head to a gateway to another cluster head, and so on until the cluster head of the destination node is reached. The packet is then transmitted to the destination. Using this method, each node must keep a cluster member table" where it stores the destination cluster head for each mobile node in the network. These cluster member tables are broadcast by each node periodically using the DSDV algorithm. Nodes update their cluster member tables on the reception of such a table from a neighbor. In addition to the cluster member table, each node must also maintain a routing table, which is used to determine the next hop in order to reach the destination. On receiving a packet, a node will consult its cluster member table and routing table to determine the nearest cluster head along the route to the destination. Next the node will check its routing table to determine the node in order to reach the selected cluster head. It then transmits the packet to this node.
When a node requires a route to a destination, it initiates a route discovery process within the network. This process is completed once a route is found or all possible route permutations have been examined. Once a route has been established, it is maintained by some form of route maintenance procedure until either the destination becomes inaccessible along every path from the source or until the route is no longer desired
When a source node desires to send a message to some destination node and does not already have a valid route to that destination, it initiates a Path Discovery process to locate the other node. It broadcasts a route request (RREQ) packet to its neighbors, which then forward the request to their neighbors, and so on, until either the destination or an intermediate node with a fresh enough" route to the destination is located. AODV utilizes destination sequence numbers to ensure all routes are loopfree and contain the most recent route information. Each node maintains its own sequence number, as well as a broadcast ID. The broadcast ID is incremented for every RREQ the node initiates, and together with the node's IP address, uniquely identifies a RREQ. Along with its own sequence number and the broadcast ID, the source node includes in the RREQ the most recent sequence number it has for the destination. Intermediate nodes can reply to the RREQ only if they have a route to the destination whose corresponding destination sequence number is greater than or equal to that contained in the RREQ. During the process of forwarding the RREQ, intermediate nodes record in their route tables the address of the neighbor from which the first copy of the broadcast packet is received, thereby establishing a reverse path.
If additional copies of the same RREQ are later received, these packets are discarded. Once the RREQ reaches the destination or an intermediate node with a fresh enough route, the destination/intermediate node responds by uncasting a route reply (RREP) packet back to the neighbor from which it first received the RREQ. As the RREP is routed back along the reverse path, nodes along this path set up forward route entries in their route tables which point to the node from which the RREP came. These forward route entries indicate the active forward route. Associated with each route entry is a route timer which will cause the deletion of the entry if it is not used within the specified lifetime. Because the RREP is forwarded along the path established by the RREQ, AODV only supports the use of symmetric links. Routes are maintained as follows. If a source node moves, it is able to reinitiate the route discovery protocol to find a new route to the destination. If a node along the route moves, its upstream neighbor notices the move and propagates a link failure notification message (a RREP with infinite metric) to each of its active upstream neighbors to inform them of the erasure of that part of the route. These nodes in turn propagate the link failure notification to their upstream neighbors, and so on until the source node is reached. The source node may then choose to reinitiate route discovery for that destination if a route is still desired.
A route reply is generated when either the route request reaches the destination itself, or when it reaches an intermediate node which contains in its route cache an unexpired route to the destination. By the time the packet reaches either the destination or such an intermediate node, it contains a route record yielding the sequence of hops taken.
If the node generating the route reply is the destination, it places the route record contained in the route request into the route reply. If the responding node is an intermediate node, it will append its cached route to the route record and then generate the route reply.
To return the route reply, the responding node must have a route to the initiator. If it has a route to the initiator in its route cache, it may use that route. Otherwise, if symmetric links are supported, the node may reverse the route in the route record. If symmetric links are not supported, the node may initiate its own route discovery and piggyback the route reply on the new route request. Route maintenance is accomplished through the use of route error packets and acknowledgments. Route error packets are generated at a node when the data link layer encounters a fatal transmission problem. When a route error packet is received, the hop in error is removed from the node's route cache and all routes containing the hop are truncated at that point. In addition to route error messages, acknowledgments are used to verify the correct operation of the route links. Such acknowledgments include passive acknowledgments, where a mobile is able to hear the next hop forwarding the packet along the route.
Figure 2.8. Re-establishing route on failure of link 5-7. The new reference level is node 5.
Links are reversed to reflect the change in adapting to the new reference level. This has the same effect as reversing the direction of one or more links when a node has no downstream links. Timing is an important factor for TORA because the height" metric is dependent on the logical time of a link failure; TORA assumes all nodes have synchronized clocks (accomplished via an external time source such as Global Positioning System). TORA's metric is a quintuple comprised of five elements, namely: (a) logical time of a link failure, (b) the unique ID of the node that defined the new reference level, (c) a reflection indicator bit, (d) a propagation ordering parameter, and (e) the unique ID of the node. The first three elements collectively represent the reference level. A new reference level is defined each time a node loses its last downstream link due to a link failure. TORA's route erasure phase essentially involves flooding a broadcast clear packet" (CLR) throughout the network to erase invalid routes.
When received by neighboring nodes, these beaconing causes their associativity tables to be updated. For each beacon received, the associativity tick of the current node with respect to the beaconing node is incremented. Association stability is defined by connection stability of one node with respect to another node over time and space. A high degree of association stability may indicate a low state of node mobility, while a low degree may indicate a high state of node mobility. Associativity ticks are reset when the neighbors of a node or the node itself moves out of proximity. A fundamental objective of ABR is to derive longer-lived routes for ad-hoc mobile networks. The three phases of ABR are: (a) route discovery (b) route re-construction (RRC) and (c) route deletion.
The route discovery phase is accomplished by a broadcast query and await reply (BQREPLY) cycle. A node desiring a route broadcasts a BQ message in search of mobiles that have a route to the destination. All nodes receiving the query (that are not the destination) append their addresses and their associativity ticks with their neighbors along with QoS information to the query packet. A successor node erases its upstream node neighbors' associativity tick entries and retains only the entry concerned with itself and its upstream node. In this way, each resultant packet arriving at the destination will contain the associativity ticks of the nodes along the route to the destination. The destination is then able to select the best route by examining the associativity ticks along each of the paths. In the case where multiple paths have the same overall degree of association stability, the route with the minimum number of hops is selected. The destination then sends a REPLY packet back to the source along this path. Nodes propagating the REPLY mark their routes as valid. All other routes remain inactive and the possibility of duplicate packets arriving at the destination is avoided.
http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.35/ns-allinone2.35.tar.gz/download B. Copy the downloded ns 2.35 file in home. (I have copy it in home/nasir through mouse) Open terminal by clicking the icon on the desktop Now write pwd without inverted commas it will show your present working directory. ( I have got like /home/lenovo). To enter into any directory simply write $cd /home ;press enter home is the directory name $ls ; it will show the list of containing files in yours directory Now goto that directory in which you have copied the ns2.35. (I have done so cd ..,now I am in /home directory.). Extract the package by writing this. tar -xvf ns-allinone-2.35-RC3.tar (be careful write the same name of ns file what you have copied) $cd ns-allinone-2.35 ;(press enter)
$./install A. Wait for installation to complete. B. Now if you have at the end of the window the same like below then its ok you have done it.
Now the most difficult thing is to set your bashrc file. Be careful I have wasted much of my time on this. But hope you will not. Cd ~/ nano ~/.bashrc Now simply copy the page # 7 text and past it in the terminal. Only change the path (dont confuse with this is so simple put your place where you have install the ns-allinone-2.35.
Once you made it you can copy/manually store the bashrc file, Be careful to write otcl8.5.10, tk1.14, ns2.35 etc. file names, because it changes with change of ns version. # LD_LIBRARY_PATH OTCL_LIB=/home/ns-allinone-2.35/otcl-1.14 NS2_LIB=/home/ns-allinone-2.35/lib X11_LIB=/usr/X11R6/lib USR_LOCAL_LIB=/usr/local/lib export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X 11_LIB:$USR_LOCAL_LIB # TCL_LIBRARY TCL_LIB=/home/ns-allinone-2.35/tcl8.5.10/library USR_LIB=/usr/lib export TCL_LIBRARY=$TCL_LIB:$USR_LIB # PATH XGRAPH=/home/ns-allinone-2.35/bin:/home/ns-allinone2.345/tcl8.5.10/unix:/home/$ NS=/home/ns-allinone-2.35/ns-2.35/ NAM=/home/ns-allinone-2.35/nam-1.15/
COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR 33
PATH=$PATH:$XGRAPH:$NS:$NAM After pasting press ctrl+o to save the .bashrc file. Now press enter and then ctrl+x to exit Now write the command $source ~/.bashrc Now your terminal can get hang close it will say for losing dont worry click ok Now try again open the terminal and type $ns % you will get this congratulation you have install successfully
Now enter to home then to ns-allinone-2.35 then 2.35 using the command $cd /home/ns-allinone-2.35/ns2.35 $./validate It will take much time than installation If you have this you are successful
restart the system. To check whether ns is installed successfully or not, test it by entering $ns If you are prompted with %, it means your installation is successful otherwise check your environment variables, specifically compare the versions of otcl, nam etc in ./bashrc with those in your ns-allinone-2.35.
#Define a finish procedure proc finish {} { global ns nf tf $ns flush-trace #Close the NAM trace file close $nf #Close the ns2 trace file close $tf exit 0 } Simple simulation: part 2: network structure #Create four nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] #Create links between the nodes $ns duplex-link $n0 $n2 2Mb 10ms DropTail $ns duplex-link $n1 $n2 2Mb 10ms DropTail $ns duplex-link $n2 $n3 1.7Mb 20ms DropTail #Set Queue Size of link (n2-n3) to 10 $ns queue-limit $n2 $n3 10 #Give node position (for NAM) $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 #Monitor the queue for link (n2-n3). (for NAM) $ns duplex-link-op $n2 $n3 queuePos 0.5
#Setup a TCP connection: from node 0 to node 3 set tcp [new Agent/TCP] $ns attach-agent $n0 $tcp
COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR 37
set sink [new Agent/TCPSink] $ns attach-agent $n3 $sink $ns connect $tcp $sink $tcp set fid_ 1 #Setup a FTP over TCP connection set ftp [new Application/FTP] $ftp attach-agent $tcp $ftp set type_ FTP ;#for Nam #Setup a UDP connection: from node 1 to node 3 set udp [new Agent/UDP] $ns attach-agent $n1 $udp set null [new Agent/Null] $ns attach-agent $n3 $null $ns connect $udp $null $udp set fid_ 2
3.3 Ns by example
NS (version 2) is an object-oriented, discrete event driven network simulator developed at UC Berkely written in C++ and OTcl. NS is primarily useful for simulating local and wide area networks. Although NS is fairly easy to use once you get to know the simulator, it is quite difficult for a first time user, because there are few user-friendly manuals. Even though there is a lot of documentation written by the developers which has in depth explanation of the simulator, it is written with the depth of a skilled NS user. The purpose of this project is to give a new user some basic idea of how the simultor works, how to setup simulation networks, where to look for further information about network components in simulator codes, how to create new network components, etc., mainly by giving simple examples and brief explanations based on our experiences. Although all the usage of the simulator or possible network simulation setups may not be covered in this project, the project should help a new user to get started quickly.
#Create a simulator object set ns [new Simulator] #Define different colors for data flows (for NAM) $ns color 1 Blue $ns color 2 Red #Open the NAM trace file set nf [open out.nam w] $ns namtrace-all $nf #Define a 'finish' procedure proc finish {} { global ns nf $ns flush-trace #Close the NAM trace file close $nf
#Execute NAM on the trace file exec nam out.nam & exit 0 } #Create four nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] #Create links between the nodes $ns duplex-link $n0 $n2 2Mb 10ms DropTail $ns duplex-link $n1 $n2 2Mb 10ms DropTail $ns duplex-link $n2 $n3 1.7Mb 20ms DropTail #Set Queue Size of link (n2-n3) to 10 $ns queue-limit $n2 $n3 10 #Give node position (for NAM) $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 #Monitor the queue for link (n2-n3). (for NAM) $ns duplex-link-op $n2 $n3 queuePos 0.5
#Setup a TCP connection set tcp [new Agent/TCP] $tcp set class_ 2 $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n3 $sink $ns connect $tcp $sink $tcp set fid_ 1 #Setup a FTP over TCP connection set ftp [new Application/FTP] $ftp attach-agent $tcp $ftp set type_ FTP
COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR 40
#Setup a UDP connection set udp [new Agent/UDP] $ns attach-agent $n1 $udp set null [new Agent/Null] $ns attach-agent $n3 $null $ns connect $udp $null $udp set fid_ 2 #Setup a CBR over UDP connection set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp $cbr set type_ CBR $cbr set packet_size_ 1000 $cbr set rate_ 1mb $cbr set random_ false
#Schedule events for the CBR and FTP agents $ns at 0.1 "$cbr start" $ns at 1.0 "$ftp start" $ns at 4.0 "$ftp stop" $ns at 4.5 "$cbr stop"
#Detach tcp and sink agents (not really necessary) $ns at 4.5 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n3 $sink"
#Call the finish procedure after 5 seconds of simulation time $ns at 5.0 "finish" #Print CBR packet size and interval puts "CBR packet size = [$cbr set packet_size_]" puts "CBR interval = [$cbr set interval_]" #Run the simulation $ns run
4.2 Tcl Commands Tcl stands for Tool Command Language. A command does something for you, like output a string, compute a math expression, or display a widget on the screen. The basic syntax for a Tcl command is: command arg1 arg2 arg3 ... hello world!
In this example, the command is puts, which takes two arguments: an I/O stream identifier and a string. puts writes the string to the I/O stream along with a trailing newline character.
4.2.1 Variables: The set command is used to assign a value to a variable. It takes two arguments: The first is the name of the variable, and the second is the value. Variable names can be any length, and case is significant. In fact, you can use any character in a variable name.
4.2.2 Command Substitution The second form of substitution is command substitution. A nested command is delimited by square brackets, [ ]. The Tcl interpreter takes everything between the brackets and evaluates it as a command.
4.2.4 Backslash Substitution The final type of substitution done by the Tcl interpreter is backslash substitution. This is used to quote characters that have special meaning to the interpreter.
4.2.5 Grouping with Braces and Double Quotes Double quotes and curly braces are used to group words together into one argument. The difference between double quotes and curly braces is that quotes allow substitutions to occur in the group, while curly braces prevent substitutions. This rule applies to command, variable, and backslash substitutions.
4.2.6 Procedures: Tcl uses the proc command to define procedures. Once defined, a Tcl procedure is used just like any of the other built-in Tcl commands. The basic syntax to define a procedure is: proc name arglist body
Parameters of the Simulation Channel type Wireless Channel Radio-propagation model Two Ray Ground Antenna type Omni Antenna Interface queue type DropTail/PriQueue Maximum packet in Queue 50 Network interface type Phy/WirelessPhy MAC type 802_11 Topographical Area 500 x 300 sq.m txPower 0.5W rxPower 0.1W idlePower 0.01W Initial energy of a Node 1000.0 Joules Routing protocols AODV/DSDV Number of mobile nodes 3 and 6 (number of nodes can be increased as much as you need) Mobility 0 or 20m/s table 5.1 simulation parameters
The performances of the two routing protocols with network size of 6 and 3 nodes with mobility (mobility 20 m/s) have been implemented. In all the cases, only two senders Constant Bit-rate (CBR) over User Datagram Protocol (UDP) and two receivers (null sink) have been used.
COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR 47
5.2 The Simulation Results The following graphs show the results of 6 nodes dsdv.
Figure 5.10 node 0 send packet to node 2 after 4.0 ms with mobility
Figure 5.11 mobility factors were defined for node 0 and node 2 not for node
These figures clearly define the mobility factor of mobile ad hoc networks. We have define the mobility factor from 0 to 20 meter/ sec for different scenarios of ad hoc network having reactive ad hoc routing protocols , destination sequence distance vector (DSDV) and ad hoc on demand distance vector (AODV) routing protocol. Which clearly define that DSDV and AODV ad hoc routing protocols can support mobility of node in the ad hoc network.
REFERENCES
(1). Marc Greis Tutorial for the UCB/LBNL/VINT Network Simulator ns. (2). Ns-2 network simulator, http://www.isi.edu/nsnam/ns/, 1998. (3). CMU Monarch extensions to ns-2, http://www.monarch.cs.cmu.edu/cmuns. html, 1999. (4). A. H. Abd Rahman, Z. A. Zukarnain, Performance Comparison of AODV, DSDV and I-DSDV Routing Protocols in Mobile Ad Hoc Networks, European Journal of Scientific Research Vol. 31, No. 4, pp. 556-576 (June 2009). DSDV and IDSDV Routing Protocols in Mobile Ad Hoc Networks, European (5). A. Rahman, S. Islam, A. Talevski, Performance Measurement of various Routing Protocol in Ad-Hoc Network, IMECS, Vol. 1, pp. 321-323 (March 2009). (6). M. Abolhasan, T. Wysocki, E. Dutkiewicz, A review of routing protocols for mobile ad hoc networks, Science Direct Vol. 2, Issue 1, pp. 1-22 (January 2004) (7) Matthias Transier Ns2 tutorial running simulations (8) C.E. Perkins & P. Bhagwat, Highly Dynamic Destination Sequence-Vector Routing (DSDV) for Mobile Computers, Computer Communication Review, vol. 24, no.4, 1994, pp. 234-244.
(9) C.E. Perkins and E.M. Royer, Ad-Hoc on-Demand Distance Vector Routing, Proc. Workshop Mobile Computing Systems and Applications (WMCSA 99), Feb. 1999 pp. 90-100 (10) Jean-Pierre Hubaux, Levente Buttyan, Srdjan Capkun. The Quest for security in Mobile Ad Hoc Networks. Proceedings of the 2010 ACM International Symposium on Mobile ad Hoc networking & computing, Long Beach, CA. 2001.
(11)Work sited http://en.wikipedia.org/wiki/Mobile_ad-hoc_network http://www.novaroam.com/Inside.asp?n=Technology&p=MANET http://www.ietf.org/html.charters/manet-charter.html http://www.cwc.oulu.fi/~hernia/linkit.html (12)Elizabeth Royer and C-K Toh, A Review of Current Routing Protocols for AdHoc Mobile (13)Wireless Networks, IEEE Personal Communications Magazine, April 1999, pp. 46-55. (14) TEMPORALLY-ORDERED ROUTING ALGORITHMhttp://en.wikipedia.org/wiki/Temporallyordered_routing_algorithm