ad hoc routing protocols implementation project thesis

86
FINAL YEAR PROJECT A Review of the DSDV and AODV Ad- Hoc Routing Protocols and their Implementation in Network Simulator 2 SESSION 2008-2012 Submitted By Nasir Ahmad B.S Telecom Reg No:SU/08-01- 03028 Supervised By: Inayat Ullah i

Upload: nasirahmad

Post on 28-Nov-2015

51 views

Category:

Documents


6 download

DESCRIPTION

this is my final year project on ad hoc network routing protocols using network simulator 2.35

TRANSCRIPT

Page 1: Ad hoc routing protocols implementation Project Thesis

FINAL YEAR PROJECT

A Review of the DSDV and AODV Ad-Hoc Routing Protocols and their Implementation in

Network Simulator 2

SESSION 2008-2012

Submitted By

Nasir Ahmad

B.S Telecom Reg No:SU/08-01-03028

Supervised By:

Inayat Ullah

DEPARTMENT OF COMPUTER SCIENCE &IT

SARHAD UNIVERSITY OF SCIENCE & INFORMATION

TECHNOLOGY, PESHAWAR

i

Page 2: Ad hoc routing protocols implementation Project Thesis

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 byNasir Ahmad Reg No: SU/08-01-03028.

Students of final year BS Telecom have satisfactory completed their work.

Approved:

Examiner Chairman

_______________ _______________

Supervisor

_____________

ii

Page 3: Ad hoc routing protocols implementation Project Thesis

iii

Page 4: Ad hoc routing protocols implementation Project Thesis

3

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 ……………………………...…….….....11.1.2 WIRELESS NETWORKS ………………………..…………………….….....21.1.3 MODES …………………………………………………………………..…...31.1.4 INFRA STRUCTURED NETWORK …………………………….…….…....31.1.5 MOBILE AD HOC NETWORK ……………………………………….…….41.2 AD-HOC NETWORK VS MOBILE AD HOC NETWORK ……………….....51.3 HISTORY OF ROUTING PROTOCOLS IN MANETS ………………….…...81.4 APPLICATIONS OF MOBILE AD-HOC NETWORK..…….……………......81.5 ISSUES IN MANETS………………………………………….…......................8

CHAPTER 2 MANETS ROUTING PROTOCOLS

2.1 MANETS ROUTING PROTOCOLS…. …………………………………….....162.2 CLASSIFICATION OF AD-HOC ROUTING PROTOCOLS……………..……172.2.1 PROACTIVE TABLE DRIVEN ROUTING PROTOCOLS ……………...…172.2.1.1 DSDV…………………………………………………………………...........182.2.1.2 CGSR................................................................................................................192.2.2 SOURCE INITIATED ON DEMAND ROUTING PROTOCOLS ………….202.2.2.1 AODV …….……………………………………………………………...….212.2.2.2 DSR …………………………………………………………………….…..232.2.2.3 TORA ………………………………………………………………………262.2.2.4 ABR ………………………………………………………………………...28

CHAPTER 3 INSTALLATION OF NETWORK SIMULATOR

3.1 INSTALING NS 2.35……………………………………………………....…....31

3.2 LIVING UNDER NS2……………………….…………………..…………..…..353.2.1 A SIMPLE SIMULATION ………………..…………………………………36

[Review and implementation of dsdv and aodv in network simulator 2]

Page 5: Ad hoc routing protocols implementation Project Thesis

3

3.3 NS BY EXAMPLE …………………….………………………………………..393.3.1 CODE FOR SIMPLE PROGRAM………………………………………...…..40

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

[Review and implementation of dsdv and aodv in network simulator 2]

Page 6: Ad hoc routing protocols implementation Project Thesis

3

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………………………………………………………....2Figure 1.3 infra structured network 1…………………………………………….….3 Figure 1.4 infra structured network 2…….…………………….………...……….…4Figure 1.5 mobile ad hoc network ………………………….…………………….…5 Figure 1.6 mobile ad hoc hybrid network…………………………………………...7Figure 2.1 ad hoc routing protocols…………………………………………………12Figure 2.1a MANETs routing protocols classification ……………………………..13 Figure 2.2 dsdv Operation ………………………………………………….….........14Figure 2.3 cgsr Operation …………………………………………………….….....16Figure 2.4 aodv Operation …………………………………………………….…....18Figure 2.5 dsr Operation 1…………………………………………………….….....20Figure 2.6 dsr Operation 2…………………………………………………….….....21Figure 2.7 tora Operation …………………………………………………….…......23Figure 3.1 network simulation directory ………………………………………........33 Figure 3.2 simple simulation……………………… ………….……………..….......34Figure 4.1 tcl puts………………………………………………………………….....35 Figure 4.2 tcl variables…………………………………………………………….....36 Figure 4.3 tcl command substitution……………….………………………………...36

[Review and implementation of dsdv and aodv in network simulator 2]

Page 7: Ad hoc routing protocols implementation Project Thesis

3

Figure 4.4 tcl back slash substitution………………………………………………...36 Figure 4.5 tcl Grouping with Braces and Double Quotes ……………………..…...36Figure 4.6 tcl procedure………………………………………………………………..37Figure 5.1 6 node simulation of dsdv in nam………………….………………..…..39 Figure 5. 2 simulation of dsdv at nam for 0 sec………………………………….....40Figure 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……………….……………………………………....41Figure 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 …………….……………………….….....43Figure 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

[Review and implementation of dsdv and aodv in network simulator 2]

Page 8: Ad hoc routing protocols implementation Project Thesis

3[Review and implementation of dsdv and aodv in network simulator 2]

Page 9: Ad hoc routing protocols implementation Project Thesis

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,

Page 10: Ad hoc routing protocols implementation Project Thesis

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 whole-heartedly for accepting the difficult task of overseeing this work to completion and for taking time out of her busy schedule to consider this work.

Page 11: Ad hoc routing protocols implementation Project Thesis

Review and implementation of dsdv and aodv in network simulator 2

CHAPTER#1

INTRODUCTION

1.1Introduction

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.

Figure 1.1 wireless communication

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

1

Page 12: Ad hoc routing protocols implementation Project Thesis

Review and implementation of dsdv and aodv in network simulator 2

1.1.2 wireless networks

Wireless networking (e.g., the various types of unlicensed 2.4 GHz WiFi devices) is used to meet many needs. Perhaps the most common use is to connect laptop users who travel from location to location. Another common use is for mobile networks that connect via satellite. A wireless transmission method is a logical choice to network a LAN segment that must frequently change locations. The following situations justify the use of wireless technology:

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.

Figure 1.2 wireless network

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

2

Page 13: Ad hoc routing protocols implementation Project Thesis

Review and implementation of dsdv and aodv in network simulator 2

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

1.1.4 Infra structured network

Those networks with fixed and wired gateway called infra structured network. The bridges for these networks are known as base stations. A mobile unit within these networks connects to, and communicates with, the nearest base station that is within its communication radius. As the mobile travels out from range of one base station into the range of another, a “handoff” occurs from the old base station to the new and the mobile is able to continue communication seamlessly throughout the network. Typical applications of this type of network include once wireless local area networks (WLANs). These networks consist of many nodes as you can see inside the figure the nodes can move from one place to another. Every node is participating in this network. It is clear that the nodes can move from place to place.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

3

Page 14: Ad hoc routing protocols implementation Project Thesis

Review and implementation of dsdv and aodv in network simulator 2

Figure 1.3 infra structured network 1

Figure 1.4 infra structured network 2

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

4

Page 15: Ad hoc routing protocols implementation Project Thesis

Review and implementation of dsdv and aodv in network simulator 2

1.1.5 Mobile Ad hoc network

A Mobile Ad hoc network (MANET) is a kind of wireless ad-hoc network, and is a self-configuring 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.

Figure 1.5 mobile ad hoc network

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

5

Page 16: Ad hoc routing protocols implementation Project Thesis

Review and implementation of dsdv and aodv in network simulator 2

1.2 Ad-hoc Networks Versus Mobile Ad-hoc Networks

Ad-hoc networks form spontaneously without a need of an infrastructure or centralized controller. This type of peer-to-peer system infers that each node, or user, in the network can act as a data endpoint or intermediate repeater. Thus, all users work together to improve the reliability of network communications. These types of networks are also popularly known to as "mesh networks" because the topology of network communications resembles a mesh. The redundant communication paths provided by ad hoc mesh networks drastically improve fault tolerance for the network. Additionally, the ability for data packets to "hop" from one user to another effectively extends the network coverage area and provides a solution to overcome non-line of sight (LOS) issues.

Figure 1.8 Ad hoc network vs mobile ad hoc network

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

6

Page 17: Ad hoc routing protocols implementation Project Thesis

Review and implementation of dsdv and aodv in network simulator 2

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.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

7

Page 18: Ad hoc routing protocols implementation Project Thesis

Review and implementation of dsdv and aodv in network simulator 2

Figure 1.6 hybrid mobile ad hoc network

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

8

Page 19: Ad hoc routing protocols implementation Project Thesis

Review and implementation of dsdv and aodv in network simulator 2

1.3 HISTORY OF MANETs

The earliest MANETs were called “packet radio” networks, and were sponsored by DARPA in the early 1970s. BBN Technologies and SRI International designed, built, and experimented with these earliest systems. Experimenters included Jerry Burchfiel, Robert Kahn, and Ray Tomlinson of later TENEX, Internet and email fame. It is interesting to note that these early packet radio systems predated the Internet, and indeed were part of the motivation of the original Internet Protocol suite. Later DARPA experiments included the Survivable Radio Network (SURAN) project, which took place in the 1980s. Another third wave of academic activity started in the mid 1990s with the advent of inexpensive 802.11 radio cards for personal computer. Current MANETs are designed primary for military utility; examples include JTRS and NTDR.

1.4 Applications of MANETs

Different commercial and industrial applications involve co-operative mobile data exchange using MANET technology. Applications for MANET’s are wide ranging and have use in many critical situations, such as

disaster recovery conferences lectures emergency situation in hospitals meetings crowd control battle fields disaster management local talking in a conference emergency situations inhospitable terrains vehicles control robots control

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

9

Page 20: Ad hoc routing protocols implementation Project Thesis

Review and implementation of dsdv and aodv in network simulator 2

Figure 1.7 application of manets

1.5 Issues in MANETS

Scientists say that MANETs and WSNs throw several challenges to those involved in their design. MANETs require complex routing strategy to provide highly reliable communication amongst the nodes. In the case of WSNs the challenge lies in routing under severely constrained energy availability.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

10

Page 21: Ad hoc routing protocols implementation Project Thesis

Review and implementation of dsdv and aodv in network simulator 2

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:

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

11

Page 22: Ad hoc routing protocols implementation Project Thesis

Review and implementation of dsdv and aodv in network simulator 2

• Active attacks

• Passive attacks

Table 1.1 classification of security 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.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

12

Page 23: Ad hoc routing protocols implementation Project Thesis

Review and implementation of dsdv and aodv in network simulator 2

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].

Figure 1.6 spoofing

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.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

13

Page 24: Ad hoc routing protocols implementation Project Thesis

Review and implementation of dsdv and aodv in network simulator 2

Wormhole attacks are severe threats to MANET routing protocols

Figure 1.7 wormhole attacks

B. Passive AttacksIn 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.

C. Other Advanced AttacksWe will now discuss several specific attacks that can affect the operation of a routing protocol in ad hoc network.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

14

Page 25: Ad hoc routing protocols implementation Project Thesis

Review and implementation of dsdv and aodv in network simulator 2

• Black hole attack• Byzantine attack• Rushing attack• Replay attack• Location disclosure attack

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

15

Page 26: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

Chapter 2

2.1 MANETs routing protocols

In order to facilitate communication within the network, a routing protocol is used to discover routes between nodes. The primary goal of such an ad-hoc network routing protocol is correct and efficient route establishment between a pair of nodes so that messages may be delivered in a timely manner. Route construction should be done with a minimum of overhead and bandwidth consumption. An Ad-hoc routing protocol is a convention or standard that controls how nodes come to agree which way to route packets between computing devices in a MANET.In ad-hoc networks, nodes do not have a priori knowledge of topology of network around them, they have to discover it. The basic idea is that a new node announces its presence and listens to broadcast announcements from its neighbors. The node learns about new near nodes and ways to reach them, and announces that it can also reach those nodes. As time goes on, each node knows about all other nodes and one or more ways how to reach them. Routing algorithms have to:Keep routing table reasonably small;Choose best route for given destination (this can be the fastest, most reliable and highest through put or cheapest route)Keep table up-to-date when nodes die, move or join;Require small amount of messages/time to converge

In a wider context, an ad-hoc protocol can also mean an improvised and often impromptu protocol established for a particular specific purpose. Since the advent of DARPA packet radio networks in the early 1970s, numerous protocols have been developed for ad-hoc mobile networks. Such protocols must deal with the typical limitations of these networks, which include high power consumption, low bandwidth, and high error rates. As shown in Figure 2.1 below. these routing protocols may generally be categorized as: (a) table-driven (b) source-initiated on-demand driven. Solid lines in this figure represent direct descendants while dotted lines depict logical descendants.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

16

Page 27: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

Despite being designed for the same type of underlying network, the characteristics of each of these protocols are quite distinct.

2.2 classification of Ad- Hoc Routing protocol

Figure 2.1 ad hoc routing protocols

2.2.1 Proactive (Table-Driven) Routing Protocols

The table-driven routing protocols attempt to maintain consistent, up-to-date routing information from each node to every other node in the network. These protocols require each node to maintain one or more tables to store routing information, and they respond to changes in network topology by propagating updates throughout the network in order to maintain a consistent network view. The areas where they differ are the number of necessary routing-related tables and the methods by which changes in network structure are broadcast.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

17

Page 28: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

2.2.1.1 Destination-Sequenced Distance-Vector Routing (DSDV)

The Destination-Sequenced Distance-Vector Routing protocol (DSDV) is a table-driven algorithm based on the classical Bellman-Ford routing mechanism. The improvements made to the Bellman-Ford algorithm include freedom from loops in routing tables. Every mobile node in the network maintains a routing table in which all of the possible destinations within the network and the number of hops to each destination are recorded. Each entry is marked with a sequence number assigned by the destination node. The sequence numbers enable the 2 mobile nodes to distinguish stale routes from new ones, thereby avoiding the formation of routing loops. Routing table updates are periodically transmitted throughout the network in order to maintain table consistency. To help ease the potentially large amount of network traffic that such updates can generate, route updates can employ two possible types of packets. The first is known as a “full dump." This type of packet carries all available routing information and can require multiple network protocol data units (NPDUs). During periods of occasional movement, these packets are transmitted infrequently. Smaller “incremental" packets are used to relay only that information which has changed since the last full dump. Each of these broadcasts should fit into a standard size NPDU, thereby decreasing the amount of traffic generated.

Figure 2.2 dsdv operation

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

18

Page 29: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

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.

2.2.1.2 Cluster head Gateway Switch Routing (CGSR)

The Cluster head Gateway Switch Routing (CGSR) protocol differs from the previous protocol in the type of addressing and network organization scheme employed. Instead of a “fat" network, CGSR is a clustered multi hop mobile wireless network with several heuristic routing schemes. By having a cluster head controlling a group of ad-hoc nodes, a framework for code separation (among clusters), and channel access, routing and bandwidth allocation can be achieved. A cluster head selection algorithm is utilized to elect a node as the cluster head using a distributed algorithm within the cluster. The disadvantage of having a cluster head scheme is that frequent cluster head changes can adversely affect routing protocol performance since nodes are busy in cluster head selection rather than packet relaying.

Hence, instead of invoking cluster head reselection every time the cluster membership changes, a Least Cluster Change (LCC) clustering algorithm is introduced. Using LCC, cluster heads only change when two cluster heads come into contact, or when a node moves out of contact of all other cluster heads. CGSR uses DSDV as the underlying routing scheme, and hence has much of the same overhead as DSDV. However, it modifies DSDV by using a hierarchical cluster head-to-gateway routing approach to route traffic from source to destination

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

19

Page 30: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

Figure 2.3 cgsr operation

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.

2.2.2 Source-Initiated On-Demand Routing

A different approach from table-driven routing is source-initiated on-demand routing. This type of routing creates routes only when desired by the source node.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

20

Page 31: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

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

2.2.2.1 Ad-hoc On-Demand Distance Vector Routing (AODV)

The Ad-hoc On-Demand Distance Vector (AODV) routing protocol builds on the DSDV algorithm previously described. AODV is an improvement on DSDV because it typically minimizes the number of required broadcasts by creating routes on an on-demand basis, as opposed to maintaining a complete list of routes as in the DSDV algorithm. The authors of AODV classify it as a pure on-demand route acquisition system, as nodes that are not on a selected path do not maintain routing information or participate in routing table exchanges.

Figure 2.4 aodv operation

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

21

Page 32: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

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 loop-free 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.

Figure 1.9 aodv operation 2

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

22

Page 33: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

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.

2.2.2.2 Dynamic Source Routing (DSR)

The Dynamic Source Routing (DSR) protocol is an on-demand routing protocol that is based on the concept of source routing. Mobile nodes are required to maintain route caches that contain the source routes of which the mobile is aware. Entries in the route cache are continually updated as new routes are learned. The protocol consists of two major phases: route discovery and route maintenance. When a mobile node has a packet to send to some destination, it first consults its route cache to determine whether it already has a route to the destination. If it has an unexpired route to the destination, it will use this route to send the packet. On the other hand, if the node does not have such a route, it initiates route discovery by broadcasting a route request packet. This route request contains the address of the destination, along with the source node's address and a unique identification number. Each node receiving the packet checks whether it knows of a route to the destination. If it does not, it adds its own address to the route record of the packet and then forwards the packet along its outgoing links. To limit the number of route requests propagated on the outgoing links of a node, a mobile only forwards the route request if the request has not yet been seen by the mobile and if the mobile's address does not already appear in the route record.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

23

Page 34: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

Figure 2.5 dsr operation

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.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

24

Page 35: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

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.

Figure 2.6 dsr operation 2

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

25

Page 36: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

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.

2.2.2.3 Temporally-Ordered Routing Algorithm (TORA)

TORA (Temporally-Ordered Routing Algorithm) is a highly adaptive, loop-free, distributed routing algorithm based on the concept of link reversal. TORA is proposed to operate in a highly dynamic mobile networking environment. It is source-initiated and provides multiple routes for any desired source/destination pair. The key design concept of TORA is the localization of control messages to a very small set of nodes near the occurrence of a topological change. To accomplish this, nodes need to maintain routing information about adjacent (1-hop) nodes. The protocol performs three basic functions: (a) route creation(b) route maintenance(c) route erasure.

During the route creation and maintenance phases, nodes use a “height" metric to establish a directed acyclic graph (DAG) rooted at the destination. Thereafter, links are assigned a direction (upstream or downstream) based on the relative height metric of neighboring nodes. This process of establishing a DAG is similar to the query/reply process proposed in LMR (Lightweight Mobile Routing). In times of node mobility, the DAG route is broken and route maintenance is necessary to re-establish a DAG rooted at the same destination. Upon failure of the last downstream link, a node generates a new reference level which results in the propagation of that reference level by neighboring nodes, effectively coordinating a structured reaction to the failure.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

26

Page 37: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

Figure 2.7 tora operation

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

27

Page 38: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

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.

2.2.2.4 Associativity-Based Routing (ABR) The Associativity-Based Routing (ABR) protocol is free from loops, deadlock, and packet duplicates, and defines a new routing metric for ad-hoc mobile networks. This metric is known as the degree of association stability. In ABR, a route is selected based on the degree of association stability of mobile nodes. Each node periodically generates a beacon to signify its existence.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

28

Page 39: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

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.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

29

Page 40: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

The route discovery phase is accomplished by a broadcast query and await reply (BQ-REPLY) 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.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

30

Page 41: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

Chapter 3

Installation of network simulator

3.1 Installing ns 2.35

To download the new version follow this link

http :// sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.35/ns-allinone- 2.35.tar.gz/download

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)

B. $./install

A. Wait for installation to complete.

B. Now if you have at the end of the window the same like below then it’s ok you have done it.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

31

Page 42: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

Figure 3.1 network simulation installation

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 (don’t confuse with this is so simple put your place where you have install the ns-allinone-2.35.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

32

Page 43: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

I have install it in home/ns-allinone-2.35/ you have to write your own.)

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:$X11_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-allinone-2.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

Page 44: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

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 don’t 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

Figure 3.2 network simulation installation complete

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

34

Page 45: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

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.

3.2 Living under NS2

Figure 3.1 ns2 directory

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

35

Page 46: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

3.2.1 A Simple Simulation

Figure 3.2 simple simulation

Simple simulation: part 1: set up

#Create a simulator objectSet ns [new Simulator]#Specify the scheduler, default $ns use-scheduler Heap#Define different colors for data flows (for NAM)$ns color 1 Blue$ns color 2 Red set nf [open out.nam w]#Create trace files for simulation$ns namtrace-all $nfset tf [open trace.tr w]$ns trace-all $tf

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

36

Page 47: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

#Define a ’finish’ procedureproc finish {} {global ns nf tf$ns flush-trace#Close the NAM trace fileclose $nf#Close the ns2 trace fileclose $tfexit 0}

Simple simulation: part 2: network structure

#Create four nodesset 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

Simple simulation: part 3: transport and traffic

#Setup a TCP connection: from node 0 to node 3set tcp [new Agent/TCP]$ns attach-agent $n0 $tcp

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

37

Page 48: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

set sink [new Agent/TCPSink]$ns attach-agent $n3 $sink$ns connect $tcp $sink$tcp set fid_ 1#Setup a FTP over TCP connectionset ftp [new Application/FTP]$ftp attach-agent $tcp$ftp set type_ FTP ;#for Nam#Setup a UDP connection: from node 1 to node 3set udp [new Agent/UDP]$ns attach-agent $n1 $udpset null [new Agent/Null]$ns attach-agent $n3 $null$ns connect $udp $null

$udp set fid_ 2

Simple simulation: part 3: traffic#Setup a CBR over UDP connectionset cbr [new Application/Traffic/CBR]$cbr attach-agent $udp $cbrset type_ CBR $cbr ;#used by Namset packet_size_ 1000 $cbrset rate_ 1mb $cbrset random_ false ;#generating traffic periodically#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"#Run the simulation

$ns run

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

38

Page 49: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 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.

3.3.1 Code of simple program

#Create a simulator objectset ns [new Simulator]

#Define different colors for data flows (for NAM)$ns color 1 Blue$ns color 2 Red

#Open the NAM trace fileset nf [open out.nam w]$ns namtrace-all $nf

#Define a 'finish' procedureproc finish {} { global ns nf $ns flush-trace #Close the NAM trace file close $nf

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

39

Page 50: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

#Execute NAM on the trace file exec nam out.nam & exit 0}

#Create four nodesset 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 connectionset tcp [new Agent/TCP]$tcp set class_ 2$ns attach-agent $n0 $tcpset sink [new Agent/TCPSink]$ns attach-agent $n3 $sink$ns connect $tcp $sink$tcp set fid_ 1

#Setup a FTP over TCP connectionset ftp [new Application/FTP]$ftp attach-agent $tcp$ftp set type_ FTP

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

40

Page 51: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

#Setup a UDP connectionset udp [new Agent/UDP]$ns attach-agent $n1 $udpset null [new Agent/Null]

$ns attach-agent $n3 $null$ns connect $udp $null$udp set fid_ 2

#Setup a CBR over UDP connectionset 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 intervalputs "CBR packet size = [$cbr set packet_size_]"puts "CBR interval = [$cbr set interval_]"

#Run the simulation$ns run

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

41

Page 52: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

Figure 3. 4 nodes in animator

Figure 3. four nodes in animator

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

42

Page 53: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

Chapter # 4

Tool command language

4.1 Tool command language

It is a string-based command language. The language has only a few fundamental constructs and relatively little syntax, which makes it easy to learn. The Tcl syntax is meant to be simple. Tcl is designed to be glue that assembles software building blocks into applications.

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!

Figure 4.1 tcl puts

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.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

43

Page 54: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

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.

Figure 4.2 tcl variables

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.3 Math Expressions The Tcl interpreter itself does not evaluate math expressions. Tcl just does grouping, substitutions and command invocations. The expr command is used to parse and evaluate math expressions.

Figure 4.3 tcl command substitution

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.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

44

Page 55: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

Figure 4.4 tcl back slash substitution

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.

Figure 4.5 Grouping with Braces and Double Quotes

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

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

45

Page 56: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

Figure 4.6 tcl procedure

Table 4.1 arithmetic operators use in TCl

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

46

Page 57: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

Chapter 5

5.1 Simulation and Results

The simulation tool that has been used in this study is ns2 [7]. Communication Management Unit’s (CMU’s) wireless extension to ns2 provides the implementation of the DSDV, AODV ad-hoc routing protocols. So ns2 is selected for evaluating these protocols.

Parameters of the SimulationChannel type Wireless ChannelRadio-propagation model Two Ray GroundAntenna type Omni AntennaInterface queue type DropTail/PriQueueMaximum packet in Queue 50Network interface type Phy/WirelessPhyMAC type 802_11Topographical Area 500 x 300 sq.mtxPower 0.5WrxPower 0.1WidlePower 0.01WInitial energy of a Node 1000.0 JoulesRouting protocols AODV/DSDVNumber 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

Page 58: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

5.2 The Simulation Results

The following graphs show the results of 6 nodes dsdv.

Figure 5.1 6 node simulation of DSDV in NAM

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

48

Page 59: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

Figure5. 2 simulation of DSDV at NAM for 0 sec

Figure5.3. simulation of DSDV on 6 nodes before mobility of node 5

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

49

Page 60: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

Figure5.4. simulation of DSDV on 6 nodes after mobility of node 5

Figure 5.5. node 5 information

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

50

Page 61: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

Figure5.6 start simulation of AODV in NAM

Figure5.7. AODV using 3 nodes.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

51

Page 62: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

Figure 5.8 node 0 send packet to node 2 before mobilty

Figure5.9 node 1 forward only to node0

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

52

Page 63: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

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

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

53

Page 64: Ad hoc routing protocols implementation Project Thesis

Review and implementation of DSDV and AODV in network simulator 2

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.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

54

Page 65: Ad hoc routing protocols implementation Project Thesis

A review of DSDV and AODV ad hoc routing protocols in network simulator 2

Chapter 6

6.1 Conclusion and Future Work

This study shows implementation of two ad-hoc routing protocols in different network environment taking into consideration node mobility Overall and also shows that DSDV and AODV ad-hoc routing protocols support mobility of node in mobile ad-hoc networks. Other factors like energy consumption, delay, throughput, number of packet drop/ received and MAC load like parameters can be analyzed using the same mentioned routing protocols in network simulator.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

55

Page 66: Ad hoc routing protocols implementation Project Thesis

A review of DSDV and AODV ad hoc routing protocols in network simulator 2

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, EuropeanJournal of Scientific Research Vol. 31, No. 4, pp. 556-576 (June 2009). DSDV and I-DSDV Routing Protocols in Mobile Ad Hoc Networks, European

(5). A. Rahman, S. Islam, A. Talevski, Performance Measurement of variousRouting Protocol in Ad-Hoc Network, IMECS, Vol. 1, pp. 321-323(March 2009).

(6). M. Abolhasan, T. Wysocki, E. Dutkiewicz, A review of routing protocolsfor 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.

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

56

Page 67: Ad hoc routing protocols implementation Project Thesis

A review of DSDV and AODV ad hoc routing protocols in network simulator 2

(11)Work sitedhttp://en.wikipedia.org/wiki/Mobile_ad-hoc_networkhttp://www.novaroam.com/Inside.asp?n=Technology&p=MANEThttp://www.ietf.org/html.charters/manet-charter.htmlhttp://www.cwc.oulu.fi/~hernia/linkit.html(12)Elizabeth Royer and C-K Toh, “A Review of Current Routing Protocols for Ad-Hoc Mobile(13)Wireless Networks”, IEEE Personal Communications Magazine, April 1999, pp. 46-55.

(14) TEMPORALLY-ORDERED ROUTING ALGORITHM”http://en.wikipedia.org/wiki/Temporallyordered_routing_algorithm

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

57

Page 68: Ad hoc routing protocols implementation Project Thesis

A review of DSDV and AODV ad hoc routing protocols in network simulator 2

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

58

Page 69: Ad hoc routing protocols implementation Project Thesis

A review of DSDV and AODV ad hoc routing protocols in network simulator 2

COMPUTER SCIENCE DEPARTMENT SARHAD UNIVERSITY PESHAWAR

59