You are on page 1of 99

ZRP Agent for NS2 (NS-2 v2.

33) (Implementation Documentation)

By Brijesh Patel MAGNeT Group, DA-IICT, Gandhinagar

April 2009

Contents
1 Introduction 1.1 1.2 1.3 1.4 2 How to patch ZRP agent in the NS2? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How to run simulations using this agent? . . . . . . . . . . . . . . . . . . . . . . . . . . . How to use this Manual? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Referrence Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 2 4 4 5 5 7 7 9 9 12 13 15 17 19 19 21 24 27 31 33 35 37 39 44

Module Index 2.1 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Class Index 3.1 Class List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Module Documentation 4.1 4.2 4.3 4.4 4.5 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . NDP Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . IARP Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . IERP Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ZRP Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Class Documentation 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 DetectedQuery Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DetectedQueryList Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . hdr_zrp Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . IARPAgent Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . IARPExpirationTimer Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . IARPPeriodicUpdateTimer Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . IARPUpdate Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . IARPUpdateDetectedList Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . IERPAgent Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5.10 IERPExpirationTimer Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ii

CONTENTS 5.11 InnerRoute Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.12 InnerRouteList Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.13 LinkState Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.14 LinkStateList Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.15 LSU Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.16 NDPAckTimer Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.17 NDPAgent Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.18 NDPBeaconTransmitTimer Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . 5.19 Neighbor Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.20 NeighborList Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.21 PacketUtil Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.22 PeripheralNode Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.23 PeripheralNodeList Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.24 SendBuffer Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.25 SendBufferEntry Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.26 SentQuery Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.27 SentQueryList Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.28 ZRPAgent Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 48 50 52 55 57 59 62 64 66 69 75 77 79 81 83 85 87

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

Chapter 1

Introduction
This document provides implementation documentation of ZRP agent for NS v2.33. It provides the answers for following how to questions: 1. How to patch ZRP agent in the NS2? 2. How to run simulations using this agent? 3. How to use this Manual?

1.1

How to patch ZRP agent in the NS2?

In order to patch the ZRP agent, rst you must have following les with you. 1. PatchZRP.patch This le contains the changes needed for ZRP agent in the following NS les. (a) (b) (c) (d) (e) (f) (g) (h) /tcl/lib/ns-agent.tcl /tcl/lib/ns-default.tcl /tcl/lib/ns-lib.tcl /tcl/lib/ns-packet.tcl /common/packet.h /trace/cmu-trace.h /trace/cmu-trace.cc /Makele

2. ns-allinone-2.33_ZRP.tar.gz This zip le contains the actual code of the ZRP Agent. It must be unzipped in such a way so that it should be placed in NS home directory. 3. patchmyZRP.sh Once you do the aforementioned tasks, then you need to rebuild the NS2. All these operations are scripted in this shell script. So, for patching ZRP agent, only you need to do is run this shell script in NS home directory. (Please go through the README le for the instructions.)

Introduction

1.2

How to run simulations using this agent?

Following is one of the simulation tcl script in which nodes run ZRP as a routing agent. You must be familiar with the most of the code if you have run some simulations in NS2. But one thing you should notice is - you need to write a following code-line in the tcl script to set the default zone radius value. "Agent/ZRP set radius_ 2" # ====================================================================== # 1. Dene options # ====================================================================== set val(chan) Channel/WirelessChannel ;Channel Type set val(prop) Propagation/TwoRayGround ;# radio-propagation model set val(netif) Phy/WirelessPhy ;# network interface type set val(mac) Mac/802_11 ;# MAC type set val(ifq) Queue/DropTail/PriQueue ;# interface queue type set val(ll) LL ;# link layer type set val(ant) Antenna/OmniAntenna ;# antenna model set val(ifqlen) 50 ;# max packet in ifq set val(nn) 25 ;# number of mobilenodes set val(rp) ZRP ;# routing protocol <-ZRP Agent set val(x) 600 ;# X dimension of the topography set val(y) 600 ;# Y dimension of the topography set val(stop) 30.0 ;# simulation time Agent/ZRP set radius_ 2 ;# Setting ZRP radius=2 # ====================================================================== # 2. Main Program # ====================================================================== # 2.0 Removing Packet Headers[Adding only necessary for ZRP]... remove-all-packet-headers add-packet-header Common Flags IP RTP ARP GAF LL LRWPAN Mac ZRP # 2.1 Initialize Global Variables... # 2.1.1 create simulator instance set ns_ [new Simulator] # 2.1.2 Use New trace format... $ns_ use-newtrace set tracefd [open Grid_TC1.tr w] $ns_ trace-all $tracefd set namtrace [open Grid_TC1.nam w] $ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

1.2 How to run simulations using this agent? # 2.1.3 set up topography object set topo [new Topography] # dene topology $topo load_atgrid $val(x) $val(y) # 2.1.4 Create God set god_ [create-god $val(nn)] # 2.2 All About Nodes [Node Cong + Location Info]... # 2.2.1 congure node, please note the change below. ;# [Originaly macTrace=ON] $ns_ node-cong -adhocRouting $val(rp) \ -llType $val(ll) \ -macType $val(mac) \ -ifqType $val(ifq) \ -ifqLen $val(ifqlen) \ -antType $val(ant) \ -propType $val(prop) \ -phyType $val(netif) \ -channelType $val(chan) \ -topoInstance $topo \ -agentTrace ON \ -routerTrace ON \ -macTrace OFF \ -movementTrace OFF \ # 2.2.2 Create the specied number of nodes [$val(nn)] and "attach" them to the channel. for {set i 0} {$i < $val(nn) } {incr i} { set node_($i) [$ns_ node] $node_($i) random-motion 0 ;# disable random motion } # 2.2.3 Node locations for {set i 0} {$i < 5} {incr i} { for {set j 0} {$j < 5} {incr j} { set id [expr $i5 + $j] set X [expr $j140+20] set Y [expr $i140+20] $node_($id) set X_ [expr $j140+20] $node_($id) set Y_ [expr $i140+20] $node_($id) set Z_ 0.0

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

4 puts "CO-ORD of Node $id = ($X, $Y)" } } # 2.3 Trafc Prole [Only One connection]... # You can dene trafc prole here # 2.4 Events... # 2.4.1 Tell nodes when the simulation ends for {set i 0} {$i < $val(nn) } {incr i} { $ns_ at $val(stop).0 "$node_($i) reset"; } $ns_ at $val(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt" puts $tracefd "M 0.0 nn $val(nn) x $val(x) y $val(y) rp $val(rp)" puts $tracefd "M 0.0 prop $val(prop) ant $val(ant)" proc stop {} { global ns_ tracefd $ns_ ush-trace close $tracefd } puts "Starting Simulation..." $ns_ run

Introduction

1.3

How to use this Manual?

This manual is organnized in two ways. First it represents the code in ve separate modules. Each module containes a component of ZRP. New reader is adviced to go through the module section rst to get the idea of ZRP implementation design. Second it represents the the code according to the class denitions and its detailed documentation in terms of its data and member functions.

1.4

Referrence Documents

Following are some of the documents which may help to understand the code better. 1. NS2 Documentation (Available at: http://www.isi.edu/nsnam/ns/ns-documentation.html) 2. ZRP IETF Drafts (Available at: http://tools.ietf.org/html/draft-ietf-manet-zone-zrp-04) 3. Creating agents in NS2 (Available at: http://masimum.inf.um.es/nsrt-howto/pdf/nsrt-howto.pdf)

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

Chapter 2

Module Index
2.1 Modules
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 12 13 15 17

Here is a list of all modules: Constants . NDP Agent IARP Agent IERP Agent ZRP Agent

Module Index

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

Chapter 3

Class Index
3.1 Class List
19 21 24 27 31 33 35 37 39 44 46 48 50 52 55 57 59 62 64 66 69 75 77 79 81 83 85 87

Here are the classes, structs, unions and interfaces with brief descriptions: DetectedQuery (It is a struct to hold single entry in the Detected Query Table ) . . . . . . . . . . DetectedQueryList (It keeps all the received route-requests for control ooding ) . . . . . . . . . hdr_zrp (It denes the ZRP Packet Header ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . IARPAgent (This class implements the IntrAzone Routing Protocol (IARP) ) . . . . . . . . . . IARPExpirationTimer (It implements a timer who checks periodically for the expiry of various entries in IARP tables ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . IARPPeriodicUpdateTimer (This class implements a timer who sends the IARP updates periodically ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . IARPUpdate (It is a struct to hold single entry in the Detected Update Table ) . . . . . . . . . . IARPUpdateDetectedList (This class implements Detected Update Table ) . . . . . . . . . . . . IERPAgent (This class implements the IntEr Routing Protocol (IERP) ) . . . . . . . . . . . . . IERPExpirationTimer (It implements a timer who checks periodically for the expiry of various entries in IERP tables ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . InnerRoute (It is a struct to hold single entry in the Route Table ) . . . . . . . . . . . . . . . . . InnerRouteList (This class implements the Routing Table ) . . . . . . . . . . . . . . . . . . . . LinkState (It is a struct to hold single entry in the Link State Table ) . . . . . . . . . . . . . . . LinkStateList (This class implements Topology (Link State) Table ) . . . . . . . . . . . . . . . LSU (It denes the Link-State-Update structure embedded in packet ) . . . . . . . . . . . . . . NDPAckTimer (This class implements a Acknoledgement TimeOut Timer, who checks that ACK is received or not for sent beacon ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . NDPAgent (This class implements the Neighbor Discovery Protocol (NDP) ) . . . . . . . . . . NDPBeaconTransmitTimer (This class implements a BEACON Transmit Timer, who periodically sends beacons to NEIGHBOR nodes ) . . . . . . . . . . . . . . . . . . . . . . . Neighbor (This class contains NEIGHBOR NODE information ) . . . . . . . . . . . . . . . . . NeighborList (It implements the Neighbor Table ) . . . . . . . . . . . . . . . . . . . . . . . . . PacketUtil (This class implements packet utilities needed by various classes ) . . . . . . . . . . PeripheralNode (It is a struct to hold single entry in the Peripheral Node Table ) . . . . . . . . . PeripheralNodeList (This class implements Peripheral Node Table ) . . . . . . . . . . . . . . . SendBuffer (This class implements the buffer to store the incoming packets from the upper layer ) SendBufferEntry (This class implements the struct to hold one send buffer entry ) . . . . . . . . SentQuery (It is a struct to hold single entry in the Sent Query Table ) . . . . . . . . . . . . . . SentQueryList (It keeps all the sent route-requests ) . . . . . . . . . . . . . . . . . . . . . . . . ZRPAgent (This class implements the Zone Routing Protocol (ZRP) ) . . . . . . . . . . . . . .

Class Index

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

Chapter 4

Module Documentation
4.1 Constants

This module denes various parameters by which ZRP can be tuned.

Denes
#dene DEBUG 0
This constant is to enable or disable the printing of various events and tables on the console.

#dene ROUTER_PORT 0xff


It is a default routing port for ZRP packets.

#dene TRUE 1
It is a logical TRUE. (Integer value 1).

#dene FALSE 0
It is a logical FALSE. (Integer value 0).

#dene LINKUP 1
It suggests link status UP. (Integer value 1).

#dene LINKDOWN 0
It suggests link status DOWN. (Integer value 0).

#dene DEFAULT_STARTUP_JITTER 1
This constant is for the startup jitter for starting various timers.

#dene DEFAULT_EXPIRATION_CHECK_PERIOD 1
This constant is for the time elapsed between two consecutive expiration check events.

#dene MAX_SEQUENCE_ID 1000000


This constant is for the range of sequence ids.

#dene IERP_TTL 50

10
This constant is for the bound on the ierp packet ttl.

Module Documentation

#dene DEFAULT_BEACON_PERIOD 3
This constant is for the inter beacon transmit time.

#dene DEFAULT_BEACON_PERIOD_JITTER 1
This constant is for the start time variations of beacon transmit timers for different nodes.

#dene DEFAULT_NEIGHBOR_ACK_TIMEOUT 2
This constant is for the verication of whether ACK is received or not after sending the beacon.

#dene DEFAULT_MAX_ACK_TIMEOUT 2
This constant is to decide after how many timeouts the neighbor should be marked down.

#dene DEFAULT_MIN_IARP_UPDATE_PERIOD 3
This constant is the time elapsed between two consecutive iarp update sent. Here, the update can be missed.

#dene DEFAULT_MAX_IARP_UPDATE_PERIOD 10
This constant is the time elapsed between two consecutive iarp update sent. Here, the update cannot be missed.

#dene DEFAULT_LINK_LIFETIME 10
This constant is for the value of the residence time of the linkstate in the linkstate list.

#dene DEFAULT_UPDATE_LIFETIME 30
This constant is for the value of the residence time of the update in the detected update list.

#dene DEFAULT_BRP_XMIT_POLICY 0
This constant is to decide which transmit policy should be applied to send the route request. (1: BRP_MULTICAST, 0: BRP_UNICAST).

#dene IERP_REPLY_SNOOP 1
This constant is to enable or disable the route reply message snooping.

#dene IERP_ERROR_SNOOP 1
This constant is to enable or disable the route error message snooping.

#dene IERP_XMIT_JITTER 1
This constant is for the calculating jitter for transmitting route request messages.

#dene DEFAULT_QUERY_LIFETIME 30
This constant is for the value of the residence time of the query in the detected query list.

#dene DEFAULT_QUERY_RETRY_TIME 5
This constant is for the value of the residence time of the query in the sent query list.

#dene DEFAULT_ROUTE_LIFETIME 120


This constant is for the value of the residence time of the route in the route table.

#dene DEFAULT_MAX_IERP_REPLY 3
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

4.1 Constants
This constant is the maximum allowed route replies from the destination.

11

#dene DEFAULT_ZONE_RADIUS 2
This constant is for the default value of zone radius.

#dene DEFAULT_SEND_BUFFER_SIZE 100


This constant is for the size of the send buffer.

#dene DEFAULT_PACKET_LIFETIME 20
This constant is for the value of the residence time of packet in send buffer.

#dene DEFAULT_INTERPKT_JITTER 1
The default value of the inter packet jitter is uniformly distributed value in [0,1).

Typedefs
typedef double Time
In NS2, the time is kept in a double variable.

typedef int32_t Query_ID


Query_ID is an integer variable.

Enumerations
enum ZRPTYPE { NDP_BEACON, NDP_BEACON_ACK, IARP_UPDATE, IARP_DATA, IERP_REPLY, IERP_REQUEST, IERP_ROUTE_ERROR, IERP_DATA }
This enumeration denes various ZRP packet types.

enum BRP_XMIT_POLICY { BRP_UNICAST, BRP_MULTICAST }


This enumeration denes two policies for Bordercasting - 1. using Unicast; 2. using multicast.

4.1.1

Detailed Description

This module denes various parameters by which ZRP can be tuned. This module denes following parameters of following categories: 1. General Constants 2. NDP Constants 3. IARP Constants 4. IERP Constants 5. ZRP Constants

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

12

Module Documentation

4.2

NDP Agent

This module implements the NDP Agent.

Classes
class Neighbor
This class contains NEIGHBOR NODE information.

class NeighborList
It implements the Neighbor Table.

class NDPBeaconTransmitTimer
This class implements a BEACON Transmit Timer, who periodically sends beacons to NEIGHBOR nodes.

class NDPAckTimer
This class implements a Acknoledgement TimeOut Timer, who checks that ACK is received or not for sent beacon.

class NDPAgent
This class implements the Neighbor Discovery Protocol (NDP).

4.2.1

Detailed Description

#) This module implements the NDP Agent. This module consists of following things: 1. Neighbor Table: It keeps a list of Neighbors with their link-status. 2. Beacon Transmit Timer: This timer broadcasts beacon messages periodically. 3. ACK Timeout Timer: This timer checks which neighbor(s) has not send the ACK in response to beacon. 4. NDP Agent: It implements the NDP Agent functionalities. #) Tables: 1. NEIGHBOR_TABLE: (Attributes are listed below) (a) (b) (c) (d) Node_ID Link_Status Last_ACK_Time ACK_TO_Count

#) Constants: 1. DEFAULT_BEACON_PERIOD 2. DEFAULT_BEACON_PERIOD_JITTER 3. DEFAULT_NEIGHBOR_ACK_TIMEOUT [Within this much time ACK should come to me] 4. DEFAULT_MAX_ACK_TIMEOUT [How many ACK Timeout is needed to declare a Neighbor DOWN]
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

4.3 IARP Agent

13

4.3

IARP Agent

This module implements the IARP Agent.

Classes
class LinkState
It is a struct to hold single entry in the Link State Table.

class LinkStateList
This class implements Topology (Link State) Table.

class PeripheralNode
It is a struct to hold single entry in the Peripheral Node Table.

class PeripheralNodeList
This class implements Peripheral Node Table.

class InnerRoute
It is a struct to hold single entry in the Route Table.

class InnerRouteList
This class implements the Routing Table.

class IARPUpdate
It is a struct to hold single entry in the Detected Update Table.

class IARPUpdateDetectedList
This class implements Detected Update Table.

class IARPPeriodicUpdateTimer
This class implements a timer who sends the IARP updates periodically.

class IARPExpirationTimer
It implements a timer who checks periodically for the expiry of various entries in IARP tables.

class IARPAgent
This class implements the IntrAzone Routing Protocol (IARP).

4.3.1

Detailed Description

#) This module implements the IARP Agent. This module consists of following things: 1. Link State Table: It keeps the view of network topology. 2. Peripheral Node Table: It keeps the list of peripheral nodes of the zone. 3. Routing Table: It implements the common routing table for both IARP and IERP. (Metric: Shortest path)
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

14

Module Documentation 4. Detected Update Cache: It keeps all received IARP_UPDATEs for control ooding. 5. Periodic Update Timer: It sends IARP_UPDATEs periodically to its zone. 6. Expiration Check Timer: It checks the expiration of the entries in various IARP tables. 7. IARP Agent: It implements the IARP Agent.

#) Tables: 1. LINK_STATE_TABLE: (Attributes are listed below) (a) Source (b) Dest (c) Seq (d) Link-Status (e) Expiry-Time 2. UPDATE_DETECT_TABLE: (Attributes are listed below) (a) Source (b) Seq (c) Expiry-Time 3. INNER_ROUTING_TABLE: (Attributes are listed below) (a) Destination (b) Next-Hop(Route) (c) Number-of-Hops 4. PERIPHERAL_NODE_TABLE: (Attributes are listed below) (a) Node-ID #) Constants: 1. DEFAULT_MIN_IARP_UPDATE_PERIOD [T_lsu] 2. DEFAULT_MAX_IARP_UPDATE_PERIOD [T_lsu] 3. DEFAULT_LINK_LIFETIME [For expiration of Link-states] 4. DEFAULT_UPDATE_LIFETIME [For Control Flooding-expiration of Detected-Updates] 5. DEFAULT_EXPIRATION_CHECK_PERIOD [Running the expiration-event]

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

4.4 IERP Agent

15

4.4

IERP Agent

This module implements the IERP Agent.

Classes
class DetectedQuery
It is a struct to hold single entry in the Detected Query Table.

class DetectedQueryList
It keeps all the received route-requests for control ooding.

class SentQuery
It is a struct to hold single entry in the Sent Query Table.

class SentQueryList
It keeps all the sent route-requests.

class IERPExpirationTimer
It implements a timer who checks periodically for the expiry of various entries in IERP tables.

class IERPAgent
This class implements the IntEr Routing Protocol (IERP).

4.4.1

Detailed Description

This module implements the IERP Agent. This module consists of following things: 1. Detected Request Table: It keeps all the received route-request for control ooding. 2. Sent Request Table: It keeps all sent route-requests. 3. Expiration Check Timer: It checks periodically for expired entries in different tables. 4. IERP Agent: It implements varoius functionalities associated with IERP Agent. #) Tables: 1. QUERY_DETECT_TABLE: (Attributes are listed below) (a) Source (b) Dest (c) QID (d) Covered-PN-List (e) Expiry-Time 2. QUERY_SENT_TABLE: (Attributes are listed below) (a) Source (b) Dest
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

16 (c) Expiry-Time #) Constants: 1. DEFAULT_BRP_XMIT_POLICY [1: MULTICAST, 0: UNICAST] 2. IERP_XMIT_JITTER [Uniformly distributed in interval [a,b)] 3. DEFAULT_QUERY_LIFETIME [For Control Flooding] 4. DEFAULT_ROUTE_LIFETIME [IERP Route Reliability]

Module Documentation

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

4.5 ZRP Agent

17

4.5

ZRP Agent

This module implements the ZRP Agent interface to the upper and lower layers.

Classes
struct hdr_zrp
It denes the ZRP Packet Header.

class LSU
It denes the Link-State-Update structure embedded in packet.

class PacketUtil
This class implements packet utilities needed by various classes.

class SendBufferEntry
This class implements the struct to hold one send buffer entry.

class SendBuffer
This class implements the buffer to store the incoming packets from the upper layer.

class ZRPAgent
This class implements the Zone Routing Protocol (ZRP).

4.5.1

Detailed Description

This module implements the ZRP Agent interface to the upper and lower layers. This module consists of following things: 1. Zrp Header Structure - It denes the Packet header of ZRP packet. 2. Packet Utility Class - It implements various Packet utility nctions. 3. Send Buffer - It implements the routing layer buffer for packets coming from upper-layer. 4. ZRP Agent - It implements the ZRP Agent. #) Tables: 1. SEND BUFFER: (Attributes are listed below) (a) Packet (b) Destination (c) Expiry #) Constants: 1. DEFAULT_ZONE_RADIUS 2. DEFAULT_SEND_BUFFER_SIZE 3. DEFAULT_PACKET_LIFETIME 4. DEFAULT_INTERPKT_JITTER
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

18

Module Documentation

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

Chapter 5

Class Documentation
5.1 DetectedQuery Class Reference

It is a struct to hold single entry in the Detected Query Table. #include <zrp.h>

Public Member Functions


DetectedQuery ()
Default Constructor.

DetectedQuery (nsaddr_t src, nsaddr_t dest, int queryID, Time expiry, PeripheralNodeList curPNLst)
This constructor initializes the detected query entry with passed parameter values.

Public Attributes
nsaddr_t src_
Source of the detected query.

nsaddr_t dest_
Destination of the detected query.

int queryID_
Query ID of the route-request.

Time expiry_
Expiry of this detected Entry.

PeripheralNodeList pnLst_
Query-Coverage Info (Not Used).

int querySentFlag_

20
Whether the query is Sent/Forwarded or Not.

Class Documentation

int totalReplySent_
How many replies has been sent for this query.

DetectedQuery next_
Pointer to Next detected query.

5.1.1

Detailed Description

It is a struct to hold single entry in the Detected Query Table. Denition at line 1222 of le zrp.h.

5.1.2
5.1.2.1

Constructor & Destructor Documentation


DetectedQuery::DetectedQuery () [inline]

Default Constructor. Never called from anywhere in the code. Initialized with invalid entries. Denition at line 1241 of le zrp.h. 5.1.2.2 DetectedQuery::DetectedQuery (nsaddr_t src, nsaddr_t dest, int queryID, Time expiry, PeripheralNodeList curPNLst) [inline]

This constructor initializes the detected query entry with passed parameter values. Parameters: src Source of the detected query. dest Destination of the detected query. queryID Query ID of the route-request. expiry Expiry of this detected Entry. curPNLst Pointer to current peripheral node list. Denition at line 1254 of le zrp.h. The documentation for this class was generated from the following le: zrp.h

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.2 DetectedQueryList Class Reference

21

5.2

DetectedQueryList Class Reference

It keeps all the received route-requests for control ooding. #include <zrp.h>

Public Member Functions


DetectedQueryList ()
Default Constructor.

void addQuery (nsaddr_t src, nsaddr_t dest, int queryID, Time expiry, PeripheralNodeList curPNLst)
It adds the query to the detected query table.

int ndQuery (nsaddr_t src, nsaddr_t dest, int queryID, DetectedQuery handle)
It nds the query with matching parameters from the detected query table.

void removeQuery (nsaddr_t src, nsaddr_t dest, int queryID)


It removes the query with matching parameters from the detected query table.

void purgeExpiredQueries ()
It removes all expired queries from the detected query table.

void freeList ()
It removes all queries from the detected query table.

Public Attributes
DetectedQuery head_
Head element in the linked list.

int numQueries_
Size of the list.

5.2.1

Detailed Description

It keeps all the received route-requests for control ooding. Denition at line 1278 of le zrp.h.

5.2.2
5.2.2.1

Constructor & Destructor Documentation


DetectedQueryList::DetectedQueryList () [inline]

Default Constructor. Initialized with default values. Denition at line 1291 of le zrp.h.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

22

Class Documentation

5.2.3
5.2.3.1

Member Function Documentation


void DetectedQueryList::addQuery (nsaddr_t src, nsaddr_t dest, int queryID, Time expiry, PeripheralNodeList curPNLst)

It adds the query to the detected query table. Parameters: src Source of the detected query. dest Destination of the detected query. queryID Query ID of the route-request. expiry Expiry of this detected Entry. curPNLst Pointer to current peripheral node list. Denition at line 1184 of le zrp.cc. 5.2.3.2 int DetectedQueryList::ndQuery (nsaddr_t src, nsaddr_t dest, int queryID, DetectedQuery handle)

It nds the query with matching parameters from the detected query table. And if found, returns 1)TRUE & 2) pointer to found entry; Else returns FALSE. Parameters: src Source of the detected query. dest Destination of the detected query. queryID Query ID of the route-request. handle Pointer to the found entry (If Found). Denition at line 1197 of le zrp.cc. 5.2.3.3 void DetectedQueryList::removeQuery (nsaddr_t src, nsaddr_t dest, int queryID)

It removes the query with matching parameters from the detected query table. Parameters: src Source of the detected query. dest Destination of the detected query. queryID Query ID of the route-request. Denition at line 1219 of le zrp.cc. 5.2.3.4 void DetectedQueryList::purgeExpiredQueries ()

It removes all expired queries from the detected query table. Denition at line 1251 of le zrp.cc.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.2 DetectedQueryList Class Reference 5.2.3.5 void DetectedQueryList::freeList ()

23

It removes all queries from the detected query table. Denition at line 1287 of le zrp.cc. The documentation for this class was generated from the following les: zrp.h zrp.cc

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

24

Class Documentation

5.3

hdr_zrp Struct Reference

It denes the ZRP Packet Header. #include <zrp.h>

Static Public Member Functions


static int & offset ()
Returns the offset value.

static hdr_zrp access (const Packet p)


Returns the pointer to the ZRP Header segment in the Packet.

Public Attributes
int zrptype_
Packet type - see ZRPTYPE enumeration.

Time pktsent_
Packet Sending time.

int radius_
Senders Zone Radius (Maybe Useful in Future).

int seq_
Sequence number of a packet.

int forwarded_
TRUE if forwarded before.

nsaddr_t src_
Source Node Address.

nsaddr_t dest_
Destination Node Address.

LSU links_
Pointer to link state list (Used in IARP_UPDATE).

int numlinks_
Number of links in packet (Used in IARP_UPDATE).

nsaddr_t mcLst_
List of addresses to relay(Multicast) the route-request query.

int mcLstSize_
Size of Multicast list.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.3 hdr_zrp Struct Reference

25

nsaddr_t lastbc_
Address of Last Bordercaster.

nsaddr_t route_
Pointer to Source Route.

int routelength_
Route Length of IERP route stored in route_.

int routeindex_
Pointer to a current route node in route_.

int queryID_
IERP query id.

int enc_dport_
Preserved dport of Upper-Layer packet.

int enc_daddr_
Preserved daddr of Upper-Layer packet.

packet_t enc_ptype_
Preserved ptype of Upper-Layer packet.

Static Public Attributes


static int offset_
Offset to the ZRP Header segment in the Packet.

5.3.1

Detailed Description

Denition at line 1690 of le zrp.h.

5.3.2
5.3.2.1

Member Function Documentation


static int & hdr_zrp::offset () [inline, static]

Returns the offset value. Denition at line 1727 of le zrp.h. 5.3.2.2 static hdr_zrp hdr_zrp::access (const Packet p) [inline, static]

Returns the pointer to the ZRP Header segment in the Packet. Denition at line 1734 of le zrp.h. The documentation for this struct was generated from the following les:
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

26 zrp.h zrp.cc

Class Documentation

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.4 IARPAgent Class Reference

27

5.4

IARPAgent Class Reference

This class implements the IntrAzone Routing Protocol (IARP). #include <zrp.h>

Public Member Functions


IARPAgent (ZRPAgent agent)
It initializes the attributes with the default values.

void startUp ()
This is called by ZRPAgent::startUp() method.

void buildRoutingTable ()
This function creates Inner-Route-List & Peripheral-Node-List based on Link-State-List.

void addRouteInPacket (nsaddr_t dest, Packet p)


This function adds the Inner-route for node dest in packet p if available.

void recv_IARP_UPDATE (Packet p)


This function is called whenever ZRP receives an IARP_UPDATE packet.

void recv_IARP_DATA (Packet p)


This function is called whenever ZRP receives an IARP_DATA packet.

void print_tables ()
This function prints Peripheral-Node-List & Inner-Route-List.

Public Attributes
ZRPAgent agent_
Pointer to ZRP-Agent.

int updateSendFlag_
Intialized with TRUE [periodic update is sent if this ag is TRUE; After sending each update, this ag is set FALSE].

LinkStateList lsLst_
Topology Table.

PeripheralNodeList pnLst_
Peripheral-Node Table.

InnerRouteList irLst_
Proactive-Routing Table.

IARPUpdateDetectedList upLst_
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

28
Detected-Update Cache.

Class Documentation

int linkLifeTime_
DEFAULT_LINK_LIFETIME.

int updateLifeTime_
DEFAULT_UPDATE_LIFETIME.

IARPPeriodicUpdateTimer PeriodicUpdateTimer_
Periodic Update Send Timer.

IARPExpirationTimer ExpirationTimer_
Expiration Check Timer.

int startup_jitter_
For starting the Timers.

5.4.1

Detailed Description

This class implements the IntrAzone Routing Protocol (IARP). Denition at line 1074 of le zrp.h.

5.4.2
5.4.2.1

Constructor & Destructor Documentation


IARPAgent::IARPAgent (ZRPAgent agent) [inline]

It initializes the attributes with the default values. Parameters: agent Pointer to the ZRP Agent. Denition at line 1100 of le zrp.h.

5.4.3
5.4.3.1

Member Function Documentation


void IARPAgent::startUp ()

This is called by ZRPAgent::startUp() method. It does following tasks: Starts the Periodic-Update-Timer & Expiration-Timer. Clears the LinkState-List, PeripheralNode-List, Inner-Route-List & Detected-Update-List. Denition at line 912 of le zrp.cc.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.4 IARPAgent Class Reference 5.4.3.2 void IARPAgent::buildRoutingTable ()

29

This function creates Inner-Route-List & Peripheral-Node-List based on Link-State-List. The following steps are performed. 1. Clear the existing Inner-Route-List & Peirpheral-Node-List. 2. Purge the expired links & DOWN links. 3. Generate a BFS tree from existing Link-State list. 4. Generate Inner-Routing-List based on that BFS tree. Insert all leaf nodes in Peripheral-Node-List. Denition at line 930 of le zrp.cc.

5.4.3.3

void IARPAgent::addRouteInPacket (nsaddr_t dest, Packet p)

This function adds the Inner-route for node dest in packet p if available. Parameters: dest Destination Address. p Pointer to the packet. Denition at line 988 of le zrp.cc.

5.4.3.4

void IARPAgent::recv_IARP_UPDATE (Packet p)

This function is called whenever ZRP receives an IARP_UPDATE packet. On receiving IARP_UPDATE, following tasks are performed If its a new iarp_update then, node updates its LINK_STATE_TABLE, If LINK_STATE_TABLE is changed then, it rebuilds the INNER_ROUTING_TABLE and PERIPHERAL_NODE_TABLE, caches this update in UPDATE_DETECT_TABLE for control ooding, re-broadcasts it if TTL is not equal to zero. If its an already received iarp_update then, node discards this update. Parameters: p Pointer to the packet. Denition at line 1009 of le zrp.cc.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

30 5.4.3.5 void IARPAgent::recv_IARP_DATA (Packet p)

Class Documentation

This function is called whenever ZRP receives an IARP_DATA packet. On receiving IARP_DATA, following tasks are performed If its destination matches with this node, send it to upper layer. Else forward it to along the route contained in the packet. Parameters: p Pointer to the packet. Denition at line 1079 of le zrp.cc. 5.4.3.6 void IARPAgent::print_tables ()

This function prints Peripheral-Node-List & Inner-Route-List. Denition at line 1130 of le zrp.cc. The documentation for this class was generated from the following les: zrp.h zrp.cc

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.5 IARPExpirationTimer Class Reference

31

5.5

IARPExpirationTimer Class Reference

It implements a timer who checks periodically for the expiry of various entries in IARP tables. #include <zrp.h>

Public Member Functions


IARPExpirationTimer (ZRPAgent agent)
It checks the expiration of entries in various tables.

void handle (Event )


In this routine, all the expired entries are removed.

void start (double thistime)


It starts the Expiration Timer.

Public Attributes
ZRPAgent agent_
Pointer to ZRP-Agent.

Event intr_
Event object.

int expiration_check_period_
Expiration-Check-Interval.

5.5.1

Detailed Description

It implements a timer who checks periodically for the expiry of various entries in IARP tables. Denition at line 1029 of le zrp.h.

5.5.2
5.5.2.1

Constructor & Destructor Documentation


IARPExpirationTimer::IARPExpirationTimer (ZRPAgent agent) [inline]

It checks the expiration of entries in various tables. Parameters: agent Pointer to the ZRP Agent. Denition at line 1044 of le zrp.h.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

32

Class Documentation

5.5.3
5.5.3.1

Member Function Documentation


void IARPExpirationTimer::handle (Event e)

In this routine, all the expired entries are removed. It also schedules the next expiration check event. Parameters: e Event object. Denition at line 886 of le zrp.cc. 5.5.3.2 void IARPExpirationTimer::start (double thistime)

It starts the Expiration Timer by scheduling the event. Parameters: thistime The delay from the current time after which the event is schedule. Denition at line 880 of le zrp.cc. The documentation for this class was generated from the following les: zrp.h zrp.cc

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.6 IARPPeriodicUpdateTimer Class Reference

33

5.6

IARPPeriodicUpdateTimer Class Reference

This class implements a timer who sends the IARP updates periodically. #include <zrp.h>

Public Member Functions


IARPPeriodicUpdateTimer (ZRPAgent agent)
It initializes the attributes with the default values.

void handle (Event )


It implements the code for transmiting iarp updates periodically.

void start (double thistime)


This function is called to start this Timer.

Public Attributes
ZRPAgent agent_
Pointer to ZRP-Agent.

Event intr_
Event object.

int min_iarp_update_period_
Min-Update Interval.

int max_iarp_update_period_
Max-Update Interval.

Time lastUpdateSent_
Last-Update Sent Time.

5.6.1

Detailed Description

This class implements a timer who sends the IARP updates periodically. Denition at line 973 of le zrp.h.

5.6.2
5.6.2.1

Constructor & Destructor Documentation


IARPPeriodicUpdateTimer::IARPPeriodicUpdateTimer (ZRPAgent agent) [inline]

It initializes the attributes with the default values. Parameters: agent Pointer to the ZRP Agent.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

34 Denition at line 990 of le zrp.h.

Class Documentation

5.6.3
5.6.3.1

Member Function Documentation


void IARPPeriodicUpdateTimer::handle (Event e)

It implements the code for transmiting iarp updates periodically. The following scheme is implemented: If any link-change is detected in last DEFAULT_MIN_IARP_UPDATE_PERIOD seconds then, node broadcasts an IARP_UPDATE to its zone (by keeping TTL = zoneradius-1). If no link-change is detected then, NO update is sent. If node has not sent any IARP_UPDATE in last DEFAULT_MAX_IARP_UPDATE_PERIOD seconds then, -it broadcasts an IARP_UPDATE to its zone. Here, IARP_UPDATE = Neighbor list with link-status. Parameters: e Event object. Denition at line 798 of le zrp.cc. 5.6.3.2 void IARPPeriodicUpdateTimer::start (double thistime)

This function is called to start this Timer. It schedules the rst transmit event. Parameters: thistime Delay after which this event should be scheduled. Denition at line 792 of le zrp.cc. The documentation for this class was generated from the following les: zrp.h zrp.cc

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.7 IARPUpdate Class Reference

35

5.7

IARPUpdate Class Reference

It is a struct to hold single entry in the Detected Update Table. #include <zrp.h>

Public Member Functions


IARPUpdate ()
Default Constructor.

IARPUpdate (nsaddr_t updateSrc, int seq, Time expiry)


This constructor initializes the iarp update entry with passed parameter values.

Public Attributes
nsaddr_t updateSrc_
Address of the sender.

int seq_
Sequence Number.

Time expiry_
Expiry Time.

IARPUpdate next_
Pointer to the Next Element.

5.7.1

Detailed Description

It is a struct to hold single entry in the Detected Update Table. Denition at line 878 of le zrp.h.

5.7.2
5.7.2.1

Constructor & Destructor Documentation


IARPUpdate::IARPUpdate () [inline]

Default Constructor. Never called from anywhere in the code. Initialized with invalid entries. Denition at line 893 of le zrp.h. 5.7.2.2 IARPUpdate::IARPUpdate (nsaddr_t updateSrc, int seq, Time expiry) [inline]

Parameters: updateSrc Update source. seq Sequence number.


Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

36 expiry Time of expiration. Denition at line 901 of le zrp.h. The documentation for this class was generated from the following le: zrp.h

Class Documentation

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.8 IARPUpdateDetectedList Class Reference

37

5.8

IARPUpdateDetectedList Class Reference

This class implements Detected Update Table. #include <zrp.h>

Public Member Functions


IARPUpdateDetectedList ()
Default Constructor.

void addUpdate (nsaddr_t updateSrc, int seq, Time expiry)


It adds the update to the detected update table.

int ndUpdate (nsaddr_t updateSrc, int seq)


It nds the update with matching parameters from the detected update table.

void purgeExpiredUpdates ()
It removes all expired updates from the detected update table.

void freeList ()
It removes all updates from the detected update table.

Public Attributes
IARPUpdate head_
Head element in the detected update list.

int numUpdates_
Total entries in the list.

5.8.1

Detailed Description

This class implements Detected Update Table. Denition at line 914 of le zrp.h.

5.8.2
5.8.2.1

Constructor & Destructor Documentation


IARPUpdateDetectedList::IARPUpdateDetectedList () [inline]

Default Constructor. Initialized with default values. Denition at line 927 of le zrp.h.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

38

Class Documentation

5.8.3
5.8.3.1

Member Function Documentation


void IARPUpdateDetectedList::addUpdate (nsaddr_t updateSrc, int seq, Time expiry)

It adds the update to the detected update table. Parameters: updateSrc Update source. seq Sequence number. expiry Time of expiration. Denition at line 704 of le zrp.cc. 5.8.3.2 int IARPUpdateDetectedList::ndUpdate (nsaddr_t updateSrc, int seq)

It nds the update with matching parameters from the detected update table. And if found, returns TRUE and FALSE otherwise. Parameters: updateSrc Update source. seq Sequence number. Denition at line 717 of le zrp.cc. 5.8.3.3 void IARPUpdateDetectedList::purgeExpiredUpdates ()

It removes all expired updates from the detected update table. Denition at line 733 of le zrp.cc. 5.8.3.4 void IARPUpdateDetectedList::freeList ()

It removes all updates from the detected update table. Denition at line 767 of le zrp.cc. The documentation for this class was generated from the following les: zrp.h zrp.cc

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.9 IERPAgent Class Reference

39

5.9

IERPAgent Class Reference

This class implements the IntEr Routing Protocol (IERP). #include <zrp.h>

Public Member Functions


IERPAgent (ZRPAgent agent)
It initializes the attributes with the default values.

void startUp ()
This is called when the node is initialized from the ZRPAgent::startUp() method.

void recv_IERP_ROUTE_REQUEST_UNI (Packet p)


It is called when node receives a route-request message.

void recv_IERP_ROUTE_REQUEST_MC (Packet p)


It is called when node receives a route-request message.

void recv_IERP_ROUTE_REPLY (Packet p)


It is called when node receives a route-reply message.

void recv_IERP_ROUTE_ERROR (Packet p)


It is called when node receives a route-error message.

void recv_IERP_DATA (Packet p)


It is called when the node receives a DATA packet.

int addLinkStateFromRoute (nsaddr_t route, int size)


This function is called when for extracting link-state information from the route-reply messages.

int removeLinkStateFromBrokenRoute (nsaddr_t lnkSrc, nsaddr_t lnkDest)


This function is called when for extracting broken link-state information from the route-error messages.

void print_tables ()
This prints all the IERP tables. (Not used).

Public Attributes
ZRPAgent agent_
Pointer to the ZRP Agent.

int brpXmitPolicy_
Bordercasting policy. (0: UNICAST, 1: MULTICAST).

DetectedQueryList dqLst_
Object of Detected Query Table.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

40

Class Documentation

SentQueryList sqLst_
Object of Sent Query Table.

int queryLifeTime_
Intialized with DEFAULT_QUERY_LIFETIME.

int routeLifeTime_
Intialized with DEFAULT_ROUTE_LIFETIME.

int queryRetryTime_
Intialized with DEFAULT_QUERY_RETRY_TIME.

IERPExpirationTimer ExpirationTimer_
Object of Expiration Timer.

int startup_jitter_
For starting the Timers.

5.9.1

Detailed Description

This class implements the IntEr Routing Protocol (IERP). It is used by ZRPAgent class. Denition at line 1499 of le zrp.h.

5.9.2
5.9.2.1

Constructor & Destructor Documentation


IERPAgent::IERPAgent (ZRPAgent agent) [inline]

It initializes the attributes with the default values. Parameters: agent Pointer to the ZRP Agent. Denition at line 1542 of le zrp.h.

5.9.3
5.9.3.1

Member Function Documentation


IERPAgent::startUp ()

This is called when the node is initialized from the ZRPAgent::startUp() method. It does the following things: Clears the detected query list. Clears the sent query list. Denition at line 1468 of le zrp.cc.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.9 IERPAgent Class Reference 5.9.3.2 void IERPAgent::recv_IERP_ROUTE_REQUEST_UNI (Packet p)

41

It is called when node receives a route-request message. On receiving route-request, It adds the query into the detected query table. If node itself is an intended destination then, it creates a ROUTE_REPLY and sends it back to route-request-originator. If destination lies in nodes zone then, it unicasts the route-request towards the destination. Node bordercasts the query by following steps: If this query is received before then Do Nothing & return. It generates a neighbor-set through which all peripheral nodes can be reached. It forwards the query to all these neighbors. [Multiple Messages] Parameters: p Pointer to the packet. Denition at line 1518 of le zrp.cc. 5.9.3.3 void IERPAgent::recv_IERP_ROUTE_REQUEST_MC (Packet p)

It is called when node receives a route-request message. On receiving route-request, It adds the query into the detected query table. If node itself is an intended destination then, it creates a ROUTE_REPLY and sends it back to route-request-originator. If destination lies in nodes zone then, it unicasts the route-request towards the destination. Node bordercasts the query by following steps: Mark all peripheral nodes covered by the query. If node is NOT in the MULTICAST_RECEIVER_LIST then, Do nothing and return. If node is in the MULTICAST_RECEIVER_LIST then, It generates a neighbor-set through which all uncovered-peripheral-nodes can be reached. It forwards the query to all these neighbors. [Single Message] Parameters: p Pointer to the packet.

5.9.3.4

void IERPAgent::recv_IERP_ROUTE_REPLY (Packet p)

It is called when node receives a route-reply message. On receiving route-reply, If node itself is an intended destination then, it fetches the route from the packet and adds into route table. Otherwise, it snoops the packet for stored route and updates its own route table and then it forwards the route-reply.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

42 Parameters: p Pointer to the packet. Denition at line 1956 of le zrp.cc.

Class Documentation

5.9.3.5

void IERPAgent::recv_IERP_ROUTE_ERROR (Packet p)

It is called when node receives a route-error message. On receiving route-error, If node itself is an intended destination then, it nds out which route is broken and removes it from the route-table. Otherwise, it snoops the packet for broken link info and updates its own routing table and then it forwards the route-error. Parameters: p Pointer to the packet. Denition at line 2015 of le zrp.cc.

5.9.3.6

void IERPAgent::recv_IERP_DATA (Packet p)

It is called when the node receives a DATA packet. On receving DATA_PACKET, If the node is destination then, it gives it to upper-layer. If the node is not destination then, It fetches next-hop from source-route in data_packet, and sends data_packet to next-hop. Parameters: p Pointer to the packet. Denition at line 2056 of le zrp.cc.

5.9.3.7

int IERPAgent::addLinkStateFromRoute (nsaddr_t route, int size)

This function is called when for extracting link-state information from the route-reply messages. The link-state information is extracted from the source route and added to the linkstate table. Parameters: route Pointer to the source route. size Size of the source route. Denition at line 1908 of le zrp.cc.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.9 IERPAgent Class Reference 5.9.3.8

43

int IERPAgent::removeLinkStateFromBrokenRoute (nsaddr_t lnkSrc, nsaddr_t lnkDest)

This function is called when for extracting broken link-state information from the route-error messages. The broken link-state information is extracted from the source route and added to the linkstate table. Parameters: lnkSrc Link Source address. lnkDest Link Destination address. Denition at line 1939 of le zrp.cc. The documentation for this class was generated from the following les: zrp.h zrp.cc

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

44

Class Documentation

5.10

IERPExpirationTimer Class Reference

It implements a timer who checks periodically for the expiry of various entries in IERP tables. #include <zrp.h>

Public Member Functions


IERPExpirationTimer (ZRPAgent agent)
It checks the expiration of entries in various tables.

void handle (Event )


In this routine, all the expired entries are removed.

void start (double thistime)


It starts the Expiration Timer.

Public Attributes
ZRPAgent agent_
Pointer to ZRP-Agent.

Event intr_
Object of Event.

int expiration_check_period_
Expiration check time period.

5.10.1

Detailed Description

It implements a timer who checks periodically for the expiry of various entries in IERP tables. Denition at line 1454 of le zrp.h.

5.10.2
5.10.2.1

Constructor & Destructor Documentation


IERPExpirationTimer::IERPExpirationTimer (ZRPAgent agent) [inline]

It checks the expiration of entries in various tables. Parameters: agent Pointer to the ZRP Agent. Denition at line 1469 of le zrp.h.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.10 IERPExpirationTimer Class Reference

45

5.10.3
5.10.3.1

Member Function Documentation


void IERPExpirationTimer::handle (Event )

In this routine, all the expired entries are removed. It also schedules the next expiration check event. Parameters: e Event object. Denition at line 1447 of le zrp.cc. 5.10.3.2 void IERPExpirationTimer::start (double thistime)

It starts the Expiration Timer by scheduling the event. Parameters: thistime The delay from the current time after which the event is schedule. Denition at line 1441 of le zrp.cc. The documentation for this class was generated from the following les: zrp.h zrp.cc

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

46

Class Documentation

5.11

InnerRoute Class Reference

It is a struct to hold single entry in the Route Table. #include <zrp.h>

Public Member Functions


InnerRoute ()
Default Constructor.

InnerRoute (nsaddr_t addr, nsaddr_t nextHop, InnerRoute predecessor, int numHops)


This constructor initializes the route table entry with passed parameter values.

Public Attributes
nsaddr_t addr_
Destination Address.

nsaddr_t nextHop_
Next hop to reach that destination.

int numHops_
Number of hops to the Destination.

InnerRoute next_
Next entry in the Routelist.

InnerRoute predecessor_
To construct bordercast tree.

5.11.1

Detailed Description

It is a struct to hold single entry in the Route Table. Denition at line 780 of le zrp.h.

5.11.2
5.11.2.1

Constructor & Destructor Documentation


InnerRoute::InnerRoute () [inline]

Default Constructor. Never called from anywhere in the code. Initialized with invalid entries. Denition at line 796 of le zrp.h.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.11 InnerRoute Class Reference 5.11.2.2

47

InnerRoute::InnerRoute (nsaddr_t addr, nsaddr_t nextHop, InnerRoute predecessor, int numHops) [inline]

This constructor initializes the route table entry with passed parameter values. Parameters: addr Destination Address. nextHop Route towards the destination. predecessor Predecessor in the route to this destinaion. numHops The route length. Denition at line 808 of le zrp.h. The documentation for this class was generated from the following le: zrp.h

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

48

Class Documentation

5.12

InnerRouteList Class Reference

This class implements the Routing Table. #include <zrp.h>

Public Member Functions


InnerRouteList ()
Default Constructor.

void addRoute (nsaddr_t addr, nsaddr_t nextHop, InnerRoute predecessor, int numHops)
It adds the route to the Routing table.

int ndRoute (nsaddr_t addr, InnerRoute handle)


It nds the route with matching parameters from the routing table.

void freeList ()
It removes all routes from the routing table.

Public Attributes
InnerRoute head_
Head element in the routing list.

int numRoutes_
Total routes in the list.

5.12.1

Detailed Description

This class implements the Routing Table. Denition at line 822 of le zrp.h.

5.12.2
5.12.2.1

Constructor & Destructor Documentation


InnerRouteList::InnerRouteList () [inline]

Default Constructor. Initialized with default values. Denition at line 837 of le zrp.h.

5.12.3
5.12.3.1

Member Function Documentation


void InnerRouteList::addRoute (nsaddr_t addr, nsaddr_t nextHop, InnerRoute predecessor, int numHops)

It adds the route to the Routing table.


Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.12 InnerRouteList Class Reference Parameters: addr Destination Address. nextHop Route towards the destination. predecessor Predecessor in the route to this destinaion. numHops The route length. Denition at line 631 of le zrp.cc. 5.12.3.2 int InnerRouteList::ndRoute (nsaddr_t addr, InnerRoute handle)

49

It nds the route with matching parameters from the routing table. And if found, returns 1)TRUE & 2) pointer to found entry; Else returns FALSE. Parameters: addr Destination Address. handle Handle to the route. (If found) Denition at line 651 of le zrp.cc. 5.12.3.3 void InnerRouteList::freeList ()

It removes all routes from the routing table. Denition at line 676 of le zrp.cc. The documentation for this class was generated from the following les: zrp.h zrp.cc

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

50

Class Documentation

5.13

LinkState Class Reference

It is a struct to hold single entry in the Link State Table. #include <zrp.h>

Public Member Functions


LinkState ()
Default Constructor.

LinkState (nsaddr_t src, nsaddr_t dest, int seq, int isup, Time expiry)
This constructor initializes the link state entry with passed parameter values.

Public Attributes
nsaddr_t src_
32 bits

nsaddr_t dest_
32 bits

int seq_
sequence number

int isup_
Link State LINKUP[1]/LINKDOWN[0].

Time expiry_
Link Expiry Time.

LinkState next_
Pointer to Next Element.

5.13.1

Detailed Description

It is a struct to hold single entry in the Link State Table. Denition at line 562 of le zrp.h.

5.13.2
5.13.2.1

Constructor & Destructor Documentation


LinkState::LinkState () [inline]

Default Constructor. Never called from anywhere in the code. Initialized with invalid entries. Denition at line 579 of le zrp.h.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.13 LinkState Class Reference 5.13.2.2 LinkState::LinkState (nsaddr_t src, nsaddr_t dest, int seq, int isup, Time expiry) [inline]

51

This constructor initializes the link state entry with passed parameter values. Parameters: src Source of link state dest Destination of link state seq Sequence number of link state isup Link status expiry Expiry time of the link state Denition at line 592 of le zrp.h. The documentation for this class was generated from the following le: zrp.h

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

52

Class Documentation

5.14

LinkStateList Class Reference

This class implements Topology (Link State) Table. #include <zrp.h>

Public Member Functions


LinkStateList ()
Default Constructor.

void addLink (nsaddr_t src, nsaddr_t dest, int seq, int isup, Time expiry)
It adds the link to the link state table.

int ndLink (nsaddr_t src, nsaddr_t dest, LinkState handle)


It nds the link with matching parameters from the link state table.

int isEmpty ()
It checks for whether the table is empty or not.

void removeLink (LinkState prev, LinkState toBeDeleted)


It removes the link from the linkstate table.

int purgeLinks ()
It removes all expired links from the link state table.

void printLinks ()
It prints all the links on the console.

void freeList ()
It removes all links from the link state table.

Public Attributes
LinkState head_
Head element in the linked list.

int numLinks_
Total links in the list.

5.14.1

Detailed Description

This class implements Topology (Link State) Table. Denition at line 607 of le zrp.h.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.14 LinkStateList Class Reference

53

5.14.2
5.14.2.1

Constructor & Destructor Documentation


LinkStateList::LinkStateList () [inline]

Default Constructor. Initialized with default values. Denition at line 620 of le zrp.h.

5.14.3
5.14.3.1

Member Function Documentation


void LinkStateList::addLink (nsaddr_t src, nsaddr_t dest, int seq, int isup, Time expiry)

It adds the link to the link state table. Parameters: src Source of link state dest Destination of link state seq Sequence number of link state isup Link status expiry Expiry time of the link state Denition at line 410 of le zrp.cc. 5.14.3.2 int LinkStateList::ndLink (nsaddr_t src, nsaddr_t dest, LinkState handle)

It nds the link with matching parameters from the link state table. And if found, returns 1)TRUE & 2) pointer to found entry; Else returns FALSE. Parameters: src Source of link state dest Destination of link state handle Handle to the link state (If found) Denition at line 423 of le zrp.cc. 5.14.3.3 int LinkStateList::isEmpty ()

It checks for whether the table is empty or not. Returns TRUE if empty, and returns FASLE otherwise. Denition at line 448 of le zrp.cc. 5.14.3.4 void LinkStateList::removeLink (LinkState prev, LinkState toBeDeleted)

It removes the link from the linkstate table. Parameters: prev Pointer to previous element in the list. toBeDeleted Pointer to the element that should be deleted. Denition at line 458 of le zrp.cc.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

54 5.14.3.5 int LinkStateList::purgeLinks ()

Class Documentation

It removes all expired links from the link state table. Denition at line 479 of le zrp.cc. 5.14.3.6 void LinkStateList::printLinks ()

It prints all the links on the console. Used for debugging purpose. Denition at line 519 of le zrp.cc. 5.14.3.7 void LinkStateList::freeList ()

It removes all links from the link state table. Denition at line 539 of le zrp.cc. The documentation for this class was generated from the following les: zrp.h zrp.cc

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.15 LSU Class Reference

55

5.15

LSU Class Reference

It denes the Link-State-Update structure embedded in packet. #include <zrp.h>

Public Member Functions


LSU ()
Default constructor. Never used directly in the code. Intialized with invalid entries.

LSU (nsaddr_t src, nsaddr_t dest, int isUp)


Parameterized constructor. Intialized the attributes with parameteres.

Public Attributes
nsaddr_t src_
Link Source Node Address.

nsaddr_t dest_
Link Destination Node Address.

int isUp_
Link Status.

5.15.1

Detailed Description

It denes the Link-State-Update structure embedded in packet. Denition at line 1744 of le zrp.h.

5.15.2
5.15.2.1

Constructor & Destructor Documentation


LSU::LSU () [inline]

Default constructor. Never used directly in the code. Intialized with invalid entries. Denition at line 1757 of le zrp.h. 5.15.2.2 LSU::LSU (nsaddr_t src, nsaddr_t dest, int isUp) [inline]

Parameterized constructor. Intialized the attributes with parameteres. Parameters: src Link Source Node Address. dest Link Destination Node Address. isUp Link Status.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

56 Denition at line 1767 of le zrp.h. The documentation for this class was generated from the following le: zrp.h

Class Documentation

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.16 NDPAckTimer Class Reference

57

5.16

NDPAckTimer Class Reference

This class implements a Acknoledgement TimeOut Timer, who checks that ACK is received or not for sent beacon. #include <zrp.h>

Public Member Functions


NDPAckTimer (ZRPAgent agent)
It initializes the attributes with the default values.

void handle (Event )


It implements the code for checking ACK timeout.

void start ()
This function is called to start this Timer.

Public Attributes
ZRPAgent agent_
Pointer to ZRP-Agent.

Event intr_
Event Object.

int neighbor_ack_timeout_
Time before a neighbor must send ACK.

5.16.1

Detailed Description

This class implements a Acknoledgement TimeOut Timer, who checks that ACK is received or not for sent beacon. Denition at line 399 of le zrp.h.

5.16.2
5.16.2.1

Constructor & Destructor Documentation


NDPAckTimer::NDPAckTimer (ZRPAgent agent) [inline]

It initializes the attributes with the default values. Parameters: agent Pointer to the ZRP Agent. Denition at line 413 of le zrp.h.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

58

Class Documentation

5.16.3
5.16.3.1

Member Function Documentation


void NDPAckTimer::handle (Event e)

It implements the code for checking ACK timeout. If node doesnt receive ACK from an existing neighbor within DEFAULT_NEIGHBOR_ACK_TIMEOUT seconds & DEFAULT_MAX_ACK_TIMEOUT times then, node removes(marks the linkstatus = LINKDOWN) the neighbor from its NEIGHBOR_TABLE and noties IARP to rebuild the INNER_ROUTING_TABLE and PERIPHERAL_NODE_TABLE. Parameters: e Event Object. Denition at line 222 of le zrp.cc. 5.16.3.2 void NDPAckTimer::start ()

This function is called to start this Timer. Denition at line 216 of le zrp.cc. The documentation for this class was generated from the following les: zrp.h zrp.cc

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.17 NDPAgent Class Reference

59

5.17

NDPAgent Class Reference

This class implements the Neighbor Discovery Protocol (NDP). #include <zrp.h>

Public Member Functions


NDPAgent (ZRPAgent agent)
It initializes the attributes with the default values.

void startUp ()
It does the start up tasks.

void recv_NDP_BEACON (Packet p)


This function is called whenever ZRP receives an NDP_BEACON packet.

void recv_NDP_BEACON_ACK (Packet p)


This function is called whenever ZRP receives an NDP_BEACON_ACK packet.

void print_tables ()
This function prints the neighbor table.

Public Attributes
ZRPAgent agent_
Pointer to ZRP agent.

NeighborList neighborLst_
Neighbor List.

NDPBeaconTransmitTimer BeaconTransmitTimer_
Beacon transmit timer.

NDPAckTimer AckTimer_
ACK timeout timer.

int startup_jitter_
For starting the timers.

5.17.1

Detailed Description

This class implements the Neighbor Discovery Protocol (NDP). It is used by ZRP Agent class. Denition at line 441 of le zrp.h.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

60

Class Documentation

5.17.2
5.17.2.1

Constructor & Destructor Documentation


NDPAgent::NDPAgent (ZRPAgent agent) [inline]

This constructor is called by the constructor of ZRP. It initializes different compenents in NDP. Parameters: agent Pointer to ZRP Agent. Denition at line 459 of le zrp.h.

5.17.3
5.17.3.1

Member Function Documentation


void NDPAgent::startUp ()

This is called by ZRPAgent::startUp() method. It does following tasks: 1) Starts the Beacon-Transmit-Timer. 2) Clears the Neighbor-List. This is called by ZRPAgent::startUp() method. It does following tasks: Starts the Beacon-Transmit-Timer. Clears the Neighbor-List. Denition at line 284 of le zrp.cc. 5.17.3.2 void NDPAgent::recv_NDP_BEACON (Packet p)

This function is called whenever ZRP receives an NDP_BEACON packet. On receving NDP_BEACON, node sends NDP_BEACON_ACK to the sender. But it does not add this neighbor, because node stores only symmetric links. Parameters: p Pointer to packet. Denition at line 298 of le zrp.cc. 5.17.3.3 void NDPAgent::recv_NDP_BEACON_ACK (Packet p)

This function is called whenever ZRP receives an NDP_BEACON_ACK packet. If its a new neighbor, node adds the neighbor to its NEIGHBOR_TABLE and noties IARP to rebuild the INNER_ROUTING_TABLE and PERIPHERAL_NODE_TABLE. If its an existing neighbor, it updates LAST_ACK_TIME for that neighbor. Parameters: p Pointer to packet. Denition at line 326 of le zrp.cc.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.17 NDPAgent Class Reference 5.17.3.4 void NDPAgent::print_tables ()

61

This function prints the Neighbor List. It also prints which Neighbors are UP and which are DOWN. Denition at line 374 of le zrp.cc. The documentation for this class was generated from the following les: zrp.h zrp.cc

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

62

Class Documentation

5.18

NDPBeaconTransmitTimer Class Reference

This class implements a BEACON Transmit Timer, who periodically sends beacons to NEIGHBOR nodes. #include <zrp.h>

Public Member Functions


NDPBeaconTransmitTimer (ZRPAgent agent)
It initializes the attributes with the default values.

void handle (Event )


It implements the code for transmiting beacons periodically.

void start (double thistime)


This function is called to start this Timer.

Public Attributes
ZRPAgent agent_
Pointer to ZRP-Agent.

Event intr_
Event object.

int beacon_period_
Inter-Beacon-Time.

int beacon_period_jitter_
Jitter added to Inter-Beacon-Time.

int neighbor_ack_timeout_
Used only for Logging.

5.18.1

Detailed Description

This class implements a BEACON Transmit Timer, who periodically sends beacons to NEIGHBOR nodes. Denition at line 351 of le zrp.h.

5.18.2
5.18.2.1

Constructor & Destructor Documentation


NDPBeaconTransmitTimer::NDPBeaconTransmitTimer (ZRPAgent agent) [inline]

It initializes the attributes with the default values.


Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.18 NDPBeaconTransmitTimer Class Reference Parameters: agent Pointer to the ZRP Agent. Denition at line 368 of le zrp.h.

63

5.18.3
5.18.3.1

Member Function Documentation


void NDPBeaconTransmitTimer::handle (Event e)

It implements the code for transmiting beacons periodically. It sends NDP_BEACON every DEFAULT_BEACON_PERIOD seconds. And it starts ACK_TIME_OUT Timer to verify neighbor-link-status after time-out event. Parameters: e Event Object. Denition at line 188 of le zrp.cc. 5.18.3.2 void NDPBeaconTransmitTimer::start (double thistime)

This function is called to start this Timer. It schedules the rst transmit event. Parameters: thistime Delay after which this event should be scheduled. Denition at line 182 of le zrp.cc. The documentation for this class was generated from the following les: zrp.h zrp.cc

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

64

Class Documentation

5.19

Neighbor Class Reference

This class contains NEIGHBOR NODE information. #include <zrp.h>

Public Member Functions


Neighbor ()
Default Constructor.

Neighbor (nsaddr_t addr, Time lastack, int linkStatus)


It initializes the neighbor with passed parameter values.

Public Attributes
nsaddr_t addr_
Neighbor Address.

Time lastack_
Last ACK received Time.

int linkStatus_
Link-Status with this neighbor.

int AckTOCount_
No-of-times ACK-TO has occurred with this neighbor.

Neighbor next_
Pointer to Next neighbor.

5.19.1

Detailed Description

This class contains NEIGHBOR NODE information. Denition at line 233 of le zrp.h.

5.19.2
5.19.2.1

Constructor & Destructor Documentation


Neighbor::Neighbor () [inline]

Default Constructor. Never called from anywhere in the code. Initializes with invalid entries. Denition at line 248 of le zrp.h.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.19 Neighbor Class Reference 5.19.2.2 Neighbor::Neighbor (nsaddr_t addr, Time lastack, int linkStatus) [inline]

65

It initializes the neighbor with passed parameter values. Parameters: addr Neighbor address. lastack Last ACK Time. linkStatus Link status with neighbor. Denition at line 259 of le zrp.h. The documentation for this class was generated from the following le: zrp.h

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

66

Class Documentation

5.20

NeighborList Class Reference

It implements the Neighbor Table. #include <zrp.h>

Public Member Functions


NeighborList ()
Default constructor. Initializes the list by startup values.

void addNeighbor (nsaddr_t addr, Time lastack, int linkStatus)


It adds the new neighbor in the neighbor table.

int ndNeighbor (nsaddr_t addr, Neighbor handle)


It nds the neighbor from the neighbor table.

int isEmpty ()
Checks if neighbor table is empty or not.

void removeNeighbor (Neighbor prev, Neighbor toBeDeleted)


It removes the neighbor from the neighbor table.

void purgeDownNeighbors ()
It removes all neighbors whose link status is LINKDOWN from the neighbor table.

void freeList ()
It removes all neighbors from the neighbor table.

void printNeighbors ()
It prints all neighbors in the neighbor table.

Public Attributes
Neighbor head_
Pointer to head element.

int numNeighbors_
Number of neighbors.

5.20.1

Detailed Description

It implements the Neighbor Table. This class is the linked-list of Neighbor class. Denition at line 269 of le zrp.h.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.20 NeighborList Class Reference

67

5.20.2
5.20.2.1

Constructor & Destructor Documentation


NeighborList::NeighborList () [inline]

Default constructor. Initializes the list by startup values. Denition at line 281 of le zrp.h.

5.20.3
5.20.3.1

Member Function Documentation


void NeighborList::addNeighbor (nsaddr_t addr, Time lastack, int linkStatus)

It adds the new neighbor in the neighbor table. It appends this newly created node at the head of the list. Parameters: addr Neighbor address. lastack Last ACK Time. linkStatus Link status with neighbor. Denition at line 23 of le zrp.cc. 5.20.3.2 int NeighborList::ndNeighbor (nsaddr_t addr, Neighbor handle)

It nds the neighbor from the neighbor table. If found, it returns 1) TRUE and 2) handle to found entry; Else it returns FALSE. Parameters: addr Neighbor address. handle Handle to found entry. (If found) Denition at line 36 of le zrp.cc. 5.20.3.3 int NeighborList::isEmpty ()

Checks if neighbor table is empty or not. Returns TRUE if empty; FALSE if not. Denition at line 61 of le zrp.cc. 5.20.3.4 void NeighborList::removeNeighbor (Neighbor prev, Neighbor toBeDeleted)

It removes the neighbor from the neighbor table. The pointer of the neighbor is passed as a parameter. The previous pointer must also be passed since it is a singly linked list. Parameters: prev Pointer to previous element in the list. toBeDeleted Pointer to the element who should be removed. Denition at line 71 of le zrp.cc.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

68 5.20.3.5 void NeighborList::purgeDownNeighbors ()

Class Documentation

It removes all neighbors whose link status is LINKDOWN. Denition at line 92 of le zrp.cc. 5.20.3.6 void NeighborList::freeList ()

It removes all neighbors from the neighbor table. Denition at line 125 of le zrp.cc. 5.20.3.7 void NeighborList::printNeighbors ()

It prints all neighbors in the neighbor table. Denition at line 143 of le zrp.cc. The documentation for this class was generated from the following les: zrp.h zrp.cc

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.21 PacketUtil Class Reference

69

5.21

PacketUtil Class Reference

This class implements packet utilities needed by various classes. #include <zrp.h>

Public Member Functions


PacketUtil (ZRPAgent agent)
This constructor passes the pointer to the agent.

Packet pkt_create (ZRPTYPE zrp_type, nsaddr_t addressee, int ttl)


Creates the packet giving default values to header attributes.

void pkt_copy (Packet pfrom, Packet pto)


Copies the packet from pfrom to pto.

void inc_seq ()
It increments the sequence number of the packet.

void pkt_send (Packet p, nsaddr_t addressee, Time delay)


Schedules the packet for transmission with delay specied by parameter.

void pkt_broadcast (Packet p, Time randomJitter)


Schedules the packet to broadcast with delay specied by parameter.

void pkt_add_LSU_space (Packet p, int size)


Alloactes the memory to hold the link-states.

void pkt_free_LSU_space (Packet p)


Frees the memory allocated to hold link-states.

void pkt_add_ROUTE_space (Packet p, int size)


Allocates memory to hold the source route.

void pkt_free_ROUTE_space (Packet p)


Frees the memory allocated to hold source route.

void pkt_add_ADDRESS_space (Packet p, int size)


Allocates memory to hold the multicast address list.

void pkt_free_ADDRESS_space (Packet p)


Frees the memory allocated to hold multicast address list.

int pkt_AmIMultiCastReciver (Packet p, nsaddr_t addressToCheck)


Checks for the address if it is in the Multicast address list or not.

int pkt_AmIOnTheRoute (Packet p, nsaddr_t addressToCheck)


Checks for the address if it is in the source route or not.

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

70 void pkt_print_links (Packet p)


Prints all links contained in the packet.

Class Documentation

void pkt_print_route (Packet p)


Prints the source route contained in the packet.

void pkt_drop (Packet p)


Drops the packet.

Public Attributes
int seq_
Sequence Number Counter.

ZRPAgent agent_
Pointer to the ZRP Agent.

int startup_jitter_
Startup Jitter (Not used, may be used for some timer in future).

5.21.1

Detailed Description

This class implements packet utilities needed by various classes. The utilities include Packet Creation and Deletion(Freeing) Packet Copy Packet Send/Broadcast Adding and freeing Link-State/Route/Multicast-list space Printing Route-data/Link-State-Data Denition at line 1785 of le zrp.h.

5.21.2
5.21.2.1

Constructor & Destructor Documentation


PacketUtil::PacketUtil (ZRPAgent agent) [inline]

This constructor passed the pointer to the agent. Parameters: agent Pointer to the ZRP Agent. Denition at line 1799 of le zrp.h.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.21 PacketUtil Class Reference

71

5.21.3
5.21.3.1

Member Function Documentation


Packet PacketUtil::pkt_create (ZRPTYPE zrp_type, nsaddr_t addressee, int ttl)

Creates the packet giving default values to header attributes. Parameters: zrp_type Type of ZRP packet - see ZRPTYPE enumeration. addressee The intended destination of the packet. ttl TTL value of the packet. Denition at line 2187 of le zrp.cc. 5.21.3.2 void PacketUtil::pkt_copy (Packet pfrom, Packet pto)

Copies the packet from pfrom to pto. Parameters: pfrom The source of copy. pto The destination of copy. Denition at line 2233 of le zrp.cc. 5.21.3.3 void PacketUtil::inc_seq () [inline]

It increments the sequence number of the packet. Denition at line 1827 of le zrp.h. 5.21.3.4 void PacketUtil::pkt_send (Packet p, nsaddr_t addressee, Time delay)

Schedules the packet for transmission with delay specied by parameter. Parameters: p Pointer to the Packet. addressee The destination. delay The delay after which the packet should be transmitted. Denition at line 2296 of le zrp.cc. 5.21.3.5 void PacketUtil::pkt_broadcast (Packet p, Time randomJitter)

Schedules the packet to broadcast with delay specied by parameter. Parameters: p Pointer to the Packet. randomJitter The delay after which the packet should be broadcasted. Denition at line 2312 of le zrp.cc.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

72 5.21.3.6 void PacketUtil::pkt_add_LSU_space (Packet p, int size)

Class Documentation

Alloactes the memory to hold the link-states. Parameters: p Pointer to packet. size Number of link-states to be hold. Denition at line 2325 of le zrp.cc. void PacketUtil::pkt_free_LSU_space (Packet p)

5.21.3.7

Frees the memory allocated to hold link-states. Parameters: p Pointer to the packet. Denition at line 2344 of le zrp.cc. void PacketUtil::pkt_add_ROUTE_space (Packet p, int size)

5.21.3.8

Allocates memory to hold the source route. Parameters: p Pointer to the packet. size Length of the source route. Denition at line 2355 of le zrp.cc. void PacketUtil::pkt_free_ROUTE_space (Packet p)

5.21.3.9

Frees the memory allocated to hold source route. Parameters: p Pointer to the packet. Denition at line 2374 of le zrp.cc. void PacketUtil::pkt_add_ADDRESS_space (Packet p, int size)

5.21.3.10

Parameters: p Pointer to the packet. size Size of multicast address list. Denition at line 2385 of le zrp.cc.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.21 PacketUtil Class Reference 5.21.3.11 void PacketUtil::pkt_free_ADDRESS_space (Packet p)

73

Frees the memory allocated to hold multicast address list. Parameters: p Pointer to the packet. Denition at line 2404 of le zrp.cc. int PacketUtil::pkt_AmIMultiCastReciver (Packet p, nsaddr_t addressToCheck)

5.21.3.12

Checks for the address if it is in the Multicast address list or not. Parameters: p Pointer to packet. addressToCheck The address to check. Denition at line 2415 of le zrp.cc. int PacketUtil::pkt_AmIOnTheRoute (Packet p, nsaddr_t addressToCheck)

5.21.3.13

Checks for the address if it is in the source route or not. Parameters: p Pointer to the packet. addressToCheck The address to check. Denition at line 2434 of le zrp.cc. void PacketUtil::pkt_print_links (Packet p)

5.21.3.14

Prints all links contained in the packet. Parameters: p Pointer to the packet. Denition at line 2452 of le zrp.cc. void PacketUtil::pkt_print_route (Packet p)

5.21.3.15

Prints the source route contained in the packet. Parameters: p Pointer the the packet. Denition at line 2471 of le zrp.cc.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

74 5.21.3.16 void PacketUtil::pkt_drop (Packet p)

Class Documentation

Drops the packet. Frees the packet memory. but not dynamically allocated attributes. Parameters: p Pointer the the packet. Denition at line 2490 of le zrp.cc. The documentation for this class was generated from the following les: zrp.h zrp.cc

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.22 PeripheralNode Class Reference

75

5.22

PeripheralNode Class Reference

It is a struct to hold single entry in the Peripheral Node Table. #include <zrp.h>

Public Member Functions


PeripheralNode ()
Default Constructor.

PeripheralNode (nsaddr_t addr, int coveredFlag)


This constructor initializes the peripheral node entry with passed parameter values.

Public Attributes
nsaddr_t addr_
Address of the Node.

int coveredFlag_
Only For IERP.

PeripheralNode next_
Pointer to the next element.

5.22.1

Detailed Description

It is a struct to hold single entry in the Peripheral Node Table. Denition at line 692 of le zrp.h.

5.22.2
5.22.2.1

Constructor & Destructor Documentation


PeripheralNode::PeripheralNode () [inline]

Default Constructor. Never called from anywhere in the code. Initialized with invalid entries. Denition at line 706 of le zrp.h. 5.22.2.2 PeripheralNode::PeripheralNode (nsaddr_t addr, int coveredFlag) [inline]

This constructor initializes the peripheral node entry with passed parameter values. Parameters: addr Address of the node. coveredFlag Only used for IERP query coverage info.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

76 Denition at line 715 of le zrp.h. The documentation for this class was generated from the following le: zrp.h

Class Documentation

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.23 PeripheralNodeList Class Reference

77

5.23

PeripheralNodeList Class Reference

This class implements Peripheral Node Table. #include <zrp.h>

Public Member Functions


PeripheralNodeList ()
Default Constructor.

void addPerNode (nsaddr_t addr, int coveredFlag)


It adds the node to the peripheral node table.

int ndPerNode (nsaddr_t addr)


It nds the node from the peripheral node table.

void copyList (PeripheralNodeList newList)


It copies the peripheral node list into newlist.

void freeList ()
It removes all nodes from the peripheral node table.

Public Attributes
PeripheralNode head_
Head element in the linked list.

int numPerNodes_
Total nodes in the list.

5.23.1

Detailed Description

Denition at line 722 of le zrp.h.

5.23.2
5.23.2.1

Constructor & Destructor Documentation


PeripheralNodeList::PeripheralNodeList () [inline]

Default Constructor. Initialized with default values. Denition at line 735 of le zrp.h.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

78

Class Documentation

5.23.3
5.23.3.1

Member Function Documentation


void PeripheralNodeList::addPerNode (nsaddr_t addr, int coveredFlag)

It adds the node to the peripheral node table. Parameters: addr Address of the node. coveredFlag Only used for IERP query coverage info. Denition at line 566 of le zrp.cc. 5.23.3.2 int PeripheralNodeList::ndPerNode (nsaddr_t addr)

It nds the node from the peripheral node table. It returns TRUE if found and FALSE otherwise. Parameters: addr Address of the node to be found. Denition at line 579 of le zrp.cc. 5.23.3.3 void PeripheralNodeList::copyList (PeripheralNodeList newList)

It copies the peripheral node list into newlist. Parameters: newList Pointer to the new peripheral node list. Denition at line 595 of le zrp.cc. 5.23.3.4 void PeripheralNodeList::freeList ()

It removes all nodes from the peripheral node table. Denition at line 606 of le zrp.cc. The documentation for this class was generated from the following les: zrp.h zrp.cc

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.24 SendBuffer Class Reference

79

5.24

SendBuffer Class Reference

This class implements the buffer to store the incoming packets from the upper layer. #include <zrp.h>

Public Member Functions


SendBuffer (ZRPAgent agent)
It initializes the the object with default values.

void addPacket (Packet pkt, nsaddr_t dest, Time expiry)


Adds packet to the head of the list.

void purgeExpiredPackets ()
It removes the expired entries from the buffer.

void freeList ()
It removes all the entries from the list.

Public Attributes
ZRPAgent agent_
Pointer to the ZRP Agent.

SendBufferEntry head_
Pointer to the head of the list(buffer).

int numPackets_
Size of send buffer.

5.24.1

Detailed Description

This class implements the buffer to store the incoming packets from the upper layer. If the route for incoming packet is not found then they are pushed into this buffer. It is implemented as singly linked-list. Denition at line 1981 of le zrp.h.

5.24.2
5.24.2.1

Constructor & Destructor Documentation


SendBuffer::SendBuffer (ZRPAgent agent) [inline]

It initializes the the object with default values. Parameters: agent Pointer to the ZRP Agent. Denition at line 1994 of le zrp.h.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

80

Class Documentation

5.24.3
5.24.3.1

Member Function Documentation


void SendBuffer::addPacket (Packet pkt, nsaddr_t dest, Time expiry)

Adds packet to the head of the list. Parameters: pkt Pointer to the packet. dest Address of the destination. expiry Expiration time of the entry. Denition at line 2513 of le zrp.cc. 5.24.3.2 void SendBuffer::purgeExpiredPackets ()

It removes the expired entries from the buffer. Denition at line 2526 of le zrp.cc. 5.24.3.3 void SendBuffer::freeList ()

It removes all the entries from the list. Denition at line 2568 of le zrp.cc. The documentation for this class was generated from the following les: zrp.h zrp.cc

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.25 SendBufferEntry Class Reference

81

5.25

SendBufferEntry Class Reference

This class implements the struct to hold one send buffer entry. #include <zrp.h>

Public Member Functions


SendBufferEntry ()
Default Constructor. Not called anywhere in the code.

SendBufferEntry (Packet pkt, nsaddr_t dest, Time expiry)


Parameterized constructor. Intializes the Send Buffer Entry with parameter values.

Public Attributes
Packet pkt_
Packet to Send from Upper-Layer.

nsaddr_t dest_
Address of Destination.

Time expiry_
Time to expire the packet.

SendBufferEntry next_
Link to next entry in the list.

5.25.1

Detailed Description

This class implements the struct to hold one send buffer entry. Denition at line 1949 of le zrp.h.

5.25.2
5.25.2.1

Constructor & Destructor Documentation


SendBufferEntry::SendBufferEntry () [inline]

Default Constructor. Not called anywhere in the code. Intialized with invalid entries. Denition at line 1962 of le zrp.h. SendBufferEntry::SendBufferEntry (Packet pkt, nsaddr_t dest, Time expiry) [inline]

5.25.2.2

Parameterized constructor. Intializes the Send Buffer Entry with parameter values.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

82 Parameters: pkt Pointer to the packet. dest Address of destination. expiry Expration time of the packet from sendbuffer. Denition at line 1972 of le zrp.h. The documentation for this class was generated from the following le: zrp.h

Class Documentation

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.26 SentQuery Class Reference

83

5.26

SentQuery Class Reference

It is a struct to hold single entry in the Sent Query Table. #include <zrp.h>

Public Member Functions


SentQuery ()
Default Constructor.

SentQuery (nsaddr_t src, nsaddr_t dest, Time expiry)


This constructor initializes the sent query entry with passed parameter values.

Public Attributes
nsaddr_t src_
Source of the Sent Query.

nsaddr_t dest_
Destination of the Sent Query.

Time expiry_
Expiry of this sent Entry.

SentQuery next_
Pointer to Next query.

5.26.1

Detailed Description

It is a struct to hold single entry in the Sent Query Table. Denition at line 1349 of le zrp.h.

5.26.2
5.26.2.1

Constructor & Destructor Documentation


SentQuery::SentQuery () [inline]

Default Constructor. Never called from anywhere in the code. Initialized with invalid entries. Denition at line 1364 of le zrp.h. 5.26.2.2 SentQuery::SentQuery (nsaddr_t src, nsaddr_t dest, Time expiry) [inline]

Parameters: src Source of the Sent Query. dest Destination of the Sent Query.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

84 expiry Expiry of this sent Entry. Denition at line 1372 of le zrp.h. The documentation for this class was generated from the following le: zrp.h

Class Documentation

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.27 SentQueryList Class Reference

85

5.27

SentQueryList Class Reference

It keeps all the sent route-requests. #include <zrp.h>

Public Member Functions


SentQueryList ()
Default Constructor.

void addQuery (nsaddr_t src, nsaddr_t dest, Time expiry)


It adds the sent query in the sent query table.

int ndQuery (nsaddr_t src, nsaddr_t dest, SentQuery handle)


It nds the query from the sent query table.

void removeQuery (nsaddr_t src, nsaddr_t dest)


It removes the query from the sent query table.

void purgeExpiredQueries ()
It removes all the expired queries from the sent query table.

void freeList ()
It removes all the queries from the sent query table.

Public Attributes
SentQuery head_
First element in the list.

int numQueries_
Size of the list.

5.27.1

Detailed Description

It keeps all the sent route-requests. These entries are removed when corresponding route-reply messages come OR they expire. Denition at line 1385 of le zrp.h.

5.27.2
5.27.2.1

Constructor & Destructor Documentation


SentQueryList::SentQueryList () [inline]

Default Constructor. Initialized with default values. Denition at line 1398 of le zrp.h.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

86

Class Documentation

5.27.3
5.27.3.1

Member Function Documentation


void SentQueryList::addQuery (nsaddr_t src, nsaddr_t dest, Time expiry)

It adds the sent query in the sent query table. Parameters: src Source of the Sent Query. dest Destination of the Sent Query. expiry Expiry of this sent Entry. Denition at line 1314 of le zrp.cc. 5.27.3.2 int SentQueryList::ndQuery (nsaddr_t src, nsaddr_t dest, SentQuery handle)

It nds the query from the sent query table. And if found, returns 1) TRUE & 2) handle to found entry; Else returns FALSE. Parameters: src Source of the Sent Query. dest Destination of the Sent Query. handle Pointer to the found entry (If Found). Denition at line 1328 of le zrp.cc. 5.27.3.3 void SentQueryList::removeQuery (nsaddr_t src, nsaddr_t dest)

It removes the query from the sent query table. Parameters: src Source of the Sent Query. dest Destination of the Sent Query. Denition at line 1350 of le zrp.cc. 5.27.3.4 void SentQueryList::purgeExpiredQueries ()

It removes all the expired queries from the sent query table. Denition at line 1380 of le zrp.cc. 5.27.3.5 void SentQueryList::freeList ()

It removes all the queries from the sent query table. Denition at line 1414 of le zrp.cc. The documentation for this class was generated from the following les: zrp.h zrp.cc

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.28 ZRPAgent Class Reference

87

5.28

ZRPAgent Class Reference

This class implements the Zone Routing Protocol (ZRP). #include <zrp.h>

Public Member Functions


ZRPAgent ()
It is just a default consturctor.

ZRPAgent (nsaddr_t id)


Through this constructor, the node address is passed to agent.

void startUp ()
This is called when the node is initialized.

int command (int argc, const char const argv)


It implements the interface to the tcl script.

void recv (Packet p, Handler )


It receives the packet.

void route_pkt (Packet p, nsaddr_t dest)


It routes the upper-layer packets.

void route_SendBuffer_pkt ()
It routes the packes in the sendbuffer if the route is available for respective destinations.

void sendPacketUsingIARPRoute (Packet p, nsaddr_t dest, Time delay)


This function adds the source route into the packet and routes it to the next hop.

int initialized () void print_tables ()


It calls the print_tables() functions of sub-agents (NDP, IARP, IERP).

void mac_failed (Packet p)


It reports a mac failure event for all the packets who couldnt be sent on MAC layer.

Packet Myallocpkt ()
Its just a wrapper function on Agent::allocpkt(). Basically, it allocates the memory for the packet.

void Mydrop (Packet p, const char s)


Its just a wrapper function on Agent::drop(Packet p, const char s). It drops the packet for the reason given in the parameter s.

void XmitPacket (Packet p, Time randomJitter)


It schedules the packet transmission with the delay given in the parameter.

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

88

Class Documentation

Public Attributes
char myid_ PriQueue ll_queue Trace tracetarget MobileNode node_ NsObject port_dmux_ nsaddr_t myaddr_
Its my own Node Address.

int radius_
Its my Zone Radius.

int tx_
It counts total packets transmitted by agent.

int rx_
It count total packets received by agent.

int queryID_
It is query-id counter.

SendBuffer sendBuf_
The packets from the upper-layer is kept in this buffer.

PacketUtil pktUtil_
All packet related functions are handled by this object.

NDPAgent ndpAgt_
Object of Neighbor Discovery Protocol.

IARPAgent iarpAgt_
Object of IntrAzone Routing Protocol.

IERPAgent ierpAgt_
Object of IntErzone Routing Protocol.

5.28.1

Detailed Description

This class implements the Zone Routing Protocol (ZRP). Notice that the ZRPAgent class is inherited from the Agent class. Denition at line 2032 of le zrp.h.

5.28.2
5.28.2.1

Constructor & Destructor Documentation


ZRPAgent::ZRPAgent ()

It is just a default consturctor. Denition at line 2597 of le zrp.cc.


Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.28 ZRPAgent Class Reference 5.28.2.2 ZRPAgent::ZRPAgent (nsaddr_t id)

89

Through this constructor, the node address is passed to agent. ZRP Agent is initialized with default values in this constructor. Dont forget the put the following line in the tcl script to initialize the zone radius for this node. Agent/ZRP set radius_ 2 [Here, Zone Radius is set to 2.] Parameters: id Address of the Node. Denition at line 2614 of le zrp.cc.

5.28.3
5.28.3.1

Member Function Documentation


ZRPAgent::startUp ()

This is called when the node is initialized. It does the following things. Clears the Send Buffer. Calls the startUp() methods for all sub-agents - NDP, IARP and IERP. Denition at line 2640 of le zrp.cc. 5.28.3.2 ZRPAgent::command (int argc, const char const argv)

It implements the interface to the tcl script. Parameters: argc contains the number of arguments passed. argv contains argument. Denition at line 2651 of le zrp.cc. 5.28.3.3 ZRPAgent::recv (Packet p, Handler h)

It receives the packet. Here, the packet is classied into following categories and sub-categories. Then, it is passed to appropriate function for handling it. 1. Upper Layer Packet [Passed to route_pkt(Packet p, nsaddr_t dest)] 2. ZRP Packet (a) NDP_BEACON [Passed to NDPAgent::recv_NDP_BEACON(Packet p)] (b) NDP_BEACON_ACK [Passed to NDPAgent::recv_NDP_BEACON_ACK(Packet p)] (c) IARP_UPDATE [Passed to IARPAgent::recv_IARP_UPDATE(Packet p)] (d) IARP_DATA [Passed to IARPAgent::recv_IARP_DATA(Packet p)] (e) IERP_REPLY [Passed to IERPAgent::recv_IERP_ROUTE_REPLY(Packet p)] (f) IERP_REQUEST [Passed to IERPAgent::recv_IERP_ROUTE_REQUEST_XXX(Packet p)]
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

90

Class Documentation (g) IERP_ROUTE_ERROR [Passed to IERPAgent::recv_IERP_ROUTE_ERROR(Packet p)] (h) IERP_DATA [Passed to IERPAgent::recv_IERP_DATA(Packet p)]

Parameters: p pointer to the packet. Denition at line 2766 of le zrp.cc. 5.28.3.4 ZRPAgent::route_pkt (Packet p, nsaddr_t dest)

It routes the upper-layer packets. If [the route to destination exists] It sends the packet using that route. Else It initiates the route-discovery process of IERP by sending route-requests. Parameters: p Packet from Upper Layer. dest Node address of the destination. Denition at line 2838 of le zrp.cc. 5.28.3.5 ZRPAgent::route_SendBuffer_pkt ()

It routes the packes in the sendbuffer if the route is available for respective destinations. This function is called whenever the Route Table is changed. So, if there are packets destined in Send Buffer towards newly discovered destination, then they are immediately sent using that new route. Denition at line 2902 of le zrp.cc. 5.28.3.6 ZRPAgent::sendPacketUsingIARPRoute (Packet p, nsaddr_t dest, Time delay)

This function adds the source route into the packet and routes it to the next hop. Parameters: p Pointer to the packet. dest Destination of the packet. delay The amount of time after which the packet should be sent. Denition at line 2943 of le zrp.cc. 5.28.3.7 ZRPAgent::print_tables ()

It calls the print_tables() functions of sub-agents (NDP, IARP, IERP). It can be used for debugging purpose. It prints the Neighbor table, Routing Table and Peripheral Node Table. Denition at line 3007 of le zrp.cc.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

5.28 ZRPAgent Class Reference 5.28.3.8 ZRPAgent::mac_failed (Packet p)

91

It reports a mac failure event for all the packets who couldnt be sent on MAC layer. Currently, this is used for reporting ROUTE-ERROR message towards the sender in case of any IERP_DATA packet is dropped. In future, it can be used for salvaging dropped ROUTE_REPLY packets and many other things. Parameters: p Pointer to the packet. Denition at line 3015 of le zrp.cc. 5.28.3.9 ZRPAgent::Myallocpkt () [inline]

Its just a wrapper function on Agent::allocpkt(). Basically, it allocates the memory for the packet. Denition at line 2167 of le zrp.h. 5.28.3.10 ZRPAgent::Mydrop (Packet p, const char s) [inline]

Its just a wrapper function on Agent::drop(Packet p, const char s). It drops the packet for the reason given in the parameter s. Parameters: p Pointer to the packet. s Reason of dropping the packet. Denition at line 2179 of le zrp.h. 5.28.3.11 ZRPAgent::XmitPacket (Packet p, Time randomJitter) [inline]

It schedules the packet transmission with the delay given in the parameter. Parameters: p Pointer to the Packet. randomJitter Delay after the packet should be scheduled. Denition at line 2190 of le zrp.h. The documentation for this class was generated from the following les: zrp.h zrp.cc

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

Index
access hdr_zrp, 25 addLink LinkStateList, 53 addLinkStateFromRoute IERPAgent, 42 addNeighbor NeighborList, 67 addPacket SendBuffer, 80 addPerNode PeripheralNodeList, 78 addQuery DetectedQueryList, 22 SentQueryList, 86 addRoute InnerRouteList, 48 addRouteInPacket IARPAgent, 29 addUpdate IARPUpdateDetectedList, 38 buildRoutingTable IARPAgent, 28 command ZRPAgent, 89 Constants, 9 copyList PeripheralNodeList, 78 DetectedQuery, 19 DetectedQuery, 20 DetectedQueryList, 21 addQuery, 22 DetectedQueryList, 21 ndQuery, 22 freeList, 22 purgeExpiredQueries, 22 removeQuery, 22 ndLink LinkStateList, 53 ndNeighbor NeighborList, 67 ndPerNode PeripheralNodeList, 78 ndQuery DetectedQueryList, 22 SentQueryList, 86 ndRoute InnerRouteList, 49 ndUpdate IARPUpdateDetectedList, 38 freeList DetectedQueryList, 22 IARPUpdateDetectedList, 38 InnerRouteList, 49 LinkStateList, 54 NeighborList, 68 PeripheralNodeList, 78 SendBuffer, 80 SentQueryList, 86 handle IARPExpirationTimer, 32 IARPPeriodicUpdateTimer, 34 IERPExpirationTimer, 45 NDPAckTimer, 58 NDPBeaconTransmitTimer, 63 hdr_zrp, 24 access, 25 offset, 25 IARP Agent, 13 IARPAgent, 27 addRouteInPacket, 29 buildRoutingTable, 28 IARPAgent, 28 print_tables, 30 recv_IARP_DATA, 29 recv_IARP_UPDATE, 29 startUp, 28 IARPExpirationTimer, 31 handle, 32 IARPExpirationTimer, 31 start, 32 IARPPeriodicUpdateTimer, 33 handle, 34 IARPPeriodicUpdateTimer, 33 start, 34

INDEX IARPUpdate, 35 IARPUpdate, 35 IARPUpdateDetectedList, 37 addUpdate, 38 ndUpdate, 38 freeList, 38 IARPUpdateDetectedList, 37 purgeExpiredUpdates, 38 IERP Agent, 15 IERPAgent, 39 addLinkStateFromRoute, 42 IERPAgent, 40 recv_IERP_DATA, 42 recv_IERP_ROUTE_ERROR, 42 recv_IERP_ROUTE_REPLY, 41 recv_IERP_ROUTE_REQUEST_MC, 41 recv_IERP_ROUTE_REQUEST_UNI, 40 removeLinkStateFromBrokenRoute, 42 startUp, 40 IERPExpirationTimer, 44 handle, 45 IERPExpirationTimer, 44 start, 45 inc_seq PacketUtil, 71 InnerRoute, 46 InnerRoute, 46 InnerRouteList, 48 addRoute, 48 ndRoute, 49 freeList, 49 InnerRouteList, 48 isEmpty LinkStateList, 53 NeighborList, 67 LinkState, 50 LinkState, 50 LinkStateList, 52 addLink, 53 ndLink, 53 freeList, 54 isEmpty, 53 LinkStateList, 53 printLinks, 54 purgeLinks, 53 removeLink, 53 LSU, 55 LSU, 55 mac_failed ZRPAgent, 90 Myallocpkt ZRPAgent, 91 Mydrop ZRPAgent, 91 NDP Agent, 12 NDPAckTimer, 57 handle, 58 NDPAckTimer, 57 start, 58 NDPAgent, 59 NDPAgent, 60 print_tables, 60 recv_NDP_BEACON, 60 recv_NDP_BEACON_ACK, 60 startUp, 60 NDPBeaconTransmitTimer, 62 handle, 63 NDPBeaconTransmitTimer, 62 start, 63 Neighbor, 64 Neighbor, 64 NeighborList, 66 addNeighbor, 67 ndNeighbor, 67 freeList, 68 isEmpty, 67 NeighborList, 67 printNeighbors, 68 purgeDownNeighbors, 67 removeNeighbor, 67 offset hdr_zrp, 25 PacketUtil, 69 inc_seq, 71 PacketUtil, 70 pkt_add_ADDRESS_space, 72 pkt_add_LSU_space, 71 pkt_add_ROUTE_space, 72 pkt_AmIMultiCastReciver, 73 pkt_AmIOnTheRoute, 73 pkt_broadcast, 71 pkt_copy, 71 pkt_create, 71 pkt_drop, 73 pkt_free_ADDRESS_space, 72 pkt_free_LSU_space, 72 pkt_free_ROUTE_space, 72 pkt_print_links, 73 pkt_print_route, 73 pkt_send, 71 PeripheralNode, 75 PeripheralNode, 75 PeripheralNodeList, 77

93

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

94 addPerNode, 78 copyList, 78 ndPerNode, 78 freeList, 78 PeripheralNodeList, 77 pkt_add_ADDRESS_space PacketUtil, 72 pkt_add_LSU_space PacketUtil, 71 pkt_add_ROUTE_space PacketUtil, 72 pkt_AmIMultiCastReciver PacketUtil, 73 pkt_AmIOnTheRoute PacketUtil, 73 pkt_broadcast PacketUtil, 71 pkt_copy PacketUtil, 71 pkt_create PacketUtil, 71 pkt_drop PacketUtil, 73 pkt_free_ADDRESS_space PacketUtil, 72 pkt_free_LSU_space PacketUtil, 72 pkt_free_ROUTE_space PacketUtil, 72 pkt_print_links PacketUtil, 73 pkt_print_route PacketUtil, 73 pkt_send PacketUtil, 71 print_tables IARPAgent, 30 NDPAgent, 60 ZRPAgent, 90 printLinks LinkStateList, 54 printNeighbors NeighborList, 68 purgeDownNeighbors NeighborList, 67 purgeExpiredPackets SendBuffer, 80 purgeExpiredQueries DetectedQueryList, 22 SentQueryList, 86 purgeExpiredUpdates IARPUpdateDetectedList, 38 purgeLinks LinkStateList, 53 recv ZRPAgent, 89 recv_IARP_DATA IARPAgent, 29 recv_IARP_UPDATE IARPAgent, 29 recv_IERP_DATA IERPAgent, 42 recv_IERP_ROUTE_ERROR IERPAgent, 42 recv_IERP_ROUTE_REPLY IERPAgent, 41 recv_IERP_ROUTE_REQUEST_MC IERPAgent, 41 recv_IERP_ROUTE_REQUEST_UNI IERPAgent, 40 recv_NDP_BEACON NDPAgent, 60 recv_NDP_BEACON_ACK NDPAgent, 60 removeLink LinkStateList, 53 removeLinkStateFromBrokenRoute IERPAgent, 42 removeNeighbor NeighborList, 67 removeQuery DetectedQueryList, 22 SentQueryList, 86 route_pkt ZRPAgent, 90 route_SendBuffer_pkt ZRPAgent, 90 SendBuffer, 79 addPacket, 80 freeList, 80 purgeExpiredPackets, 80 SendBuffer, 79 SendBufferEntry, 81 SendBufferEntry, 81 sendPacketUsingIARPRoute ZRPAgent, 90 SentQuery, 83 SentQuery, 83 SentQueryList, 85 addQuery, 86 ndQuery, 86 freeList, 86 purgeExpiredQueries, 86 removeQuery, 86 SentQueryList, 85 start IARPExpirationTimer, 32

INDEX

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

INDEX IARPPeriodicUpdateTimer, 34 IERPExpirationTimer, 45 NDPAckTimer, 58 NDPBeaconTransmitTimer, 63 startUp IARPAgent, 28 IERPAgent, 40 NDPAgent, 60 ZRPAgent, 89 XmitPacket ZRPAgent, 91 ZRP Agent, 17 ZRPAgent, 87 command, 89 mac_failed, 90 Myallocpkt, 91 Mydrop, 91 print_tables, 90 recv, 89 route_pkt, 90 route_SendBuffer_pkt, 90 sendPacketUsingIARPRoute, 90 startUp, 89 XmitPacket, 91 ZRPAgent, 88

95

Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen

You might also like