99
ZRP Agent for NS2 (NS-2 v2.33) (Implementation Documentation) By Brijesh Patel MAGNeT Group, DA-IICT, Gandhinagar April 2009

Zrp manual 2

Embed Size (px)

DESCRIPTION

zrp manual book instalation

Citation preview

Page 1: Zrp manual 2

ZRP Agent for NS2 (NS-2 v2.33)

(Implementation Documentation)

By Brijesh PatelMAGNeT Group,

DA-IICT, Gandhinagar

April 2009

Page 2: Zrp manual 2
Page 3: Zrp manual 2

Contents

1 Introduction 1

1.1 How to patch ZRP agent in the NS2? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.2 How to run simulations using this agent? . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.3 How to use this Manual? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.4 Referrence Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Module Index 5

2.1 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

3 Class Index 7

3.1 Class List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

4 Module Documentation 9

4.1 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

4.2 NDP Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

4.3 IARP Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

4.4 IERP Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

4.5 ZRP Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

5 Class Documentation 19

5.1 DetectedQuery Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

5.2 DetectedQueryList Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

5.3 hdr_zrp Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

5.4 IARPAgent Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

5.5 IARPExpirationTimer Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

5.6 IARPPeriodicUpdateTimer Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . 33

5.7 IARPUpdate Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

5.8 IARPUpdateDetectedList Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . 37

5.9 IERPAgent Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

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

Page 4: Zrp manual 2

ii CONTENTS

5.11 InnerRoute Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

5.12 InnerRouteList Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

5.13 LinkState Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

5.14 LinkStateList Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

5.15 LSU Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

5.16 NDPAckTimer Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

5.17 NDPAgent Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

5.18 NDPBeaconTransmitTimer Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . 62

5.19 Neighbor Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

5.20 NeighborList Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

5.21 PacketUtil Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

5.22 PeripheralNode Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

5.23 PeripheralNodeList Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

5.24 SendBuffer Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

5.25 SendBufferEntry Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

5.26 SentQuery Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

5.27 SentQueryList Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

5.28 ZRPAgent Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

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

Page 5: Zrp manual 2

Chapter 1

Introduction

This document provides implementation documentation of ZRP agent for NS v2.33. It provides the answersfor 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, first you must have following files with you.

1. PatchZRP.patch

• This file contains the changes needed for ZRP agent in the following NS files.

(a) ∼/tcl/lib/ns-agent.tcl(b) ∼/tcl/lib/ns-default.tcl(c) ∼/tcl/lib/ns-lib.tcl(d) ∼/tcl/lib/ns-packet.tcl(e) ∼/common/packet.h(f) ∼/trace/cmu-trace.h(g) ∼/trace/cmu-trace.cc(h) ∼/Makefile

2. ns-allinone-2.33_ZRP.tar.gz

• This zip file contains the actual code of the ZRP Agent. It must be unzipped in such a way sothat 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 operationsare scripted in this shell script. So, for patching ZRP agent, only you need to do is run this shellscript in NS home directory. (Please go through the README file for the instructions.)

Page 6: Zrp manual 2

2 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 befamiliar with the most of the code if you have run some simulations in NS2. But one thing you shouldnotice 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. Define 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

Page 7: Zrp manual 2

1.2 How to run simulations using this agent? 3

# 2.1.3 set up topography object

set topo [new Topography]

# define topology

$topo load_flatgrid $val(x) $val(y)

# 2.1.4 Create God

set god_ [create-god $val(nn)]

# 2.2 All About Nodes [Node Config + Location Info]...

# 2.2.1 configure node, please note the change below. ;# [Originaly macTrace=ON]

$ns_ node-config -adhocRouting $val(rp) \

-llType $val(ll) \

-macType $val(mac) \

-ifqType $val(ifq) \

-ifqLen $val(ifqlen) \

-antType $val(ant) \

-propType $val(prop) \

-phyType $val(netif) \

-channelType $val(chan) \

-topoInstance $topo \

-agentTrace ON \

-routerTrace ON \

-macTrace OFF \

-movementTrace OFF \

# 2.2.2 Create the specified 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 $i∗5 + $j]

set X [expr $j∗140+20]

set Y [expr $i∗140+20]

$node_($id) set X_ [expr $j∗140+20]

$node_($id) set Y_ [expr $i∗140+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

Page 8: Zrp manual 2

4 Introduction

puts "CO-ORD of Node $id = ($X, $Y)"

}

}

# 2.3 Traffic Profile [Only One connection]...

# You can define traffic profile 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_ flush-trace

close $tracefd

}

puts "Starting Simulation..."

$ns_ run

1.3 How to use this Manual?

This manual is organnized in two ways. First it represents the code in five separate modules. Each modulecontaines a component of ZRP. New reader is adviced to go through the module section first to get the ideaof ZRP implementation design. Second it represents the the code according to the class definitions and itsdetailed 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

Page 9: Zrp manual 2

Chapter 2

Module Index

2.1 Modules

Here is a list of all modules:

Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9NDP Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12IARP Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13IERP Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15ZRP Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

Page 10: Zrp manual 2

6 Module Index

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

Page 11: Zrp manual 2

Chapter 3

Class Index

3.1 Class List

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 ) . . . . . . . . . . 19DetectedQueryList (It keeps all the received route-requests for control flooding ) . . . . . . . . . 21hdr_zrp (It defines the ZRP Packet Header ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24IARPAgent (This class implements the IntrAzone Routing Protocol (IARP) ) . . . . . . . . . . 27IARPExpirationTimer (It implements a timer who checks periodically for the expiry of various

entries in IARP tables ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31IARPPeriodicUpdateTimer (This class implements a timer who sends the IARP updates period-

ically ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33IARPUpdate (It is a struct to hold single entry in the Detected Update Table ) . . . . . . . . . . 35IARPUpdateDetectedList (This class implements Detected Update Table ) . . . . . . . . . . . . 37IERPAgent (This class implements the IntEr Routing Protocol (IERP) ) . . . . . . . . . . . . . 39IERPExpirationTimer (It implements a timer who checks periodically for the expiry of various

entries in IERP tables ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44InnerRoute (It is a struct to hold single entry in the Route Table ) . . . . . . . . . . . . . . . . . 46InnerRouteList (This class implements the Routing Table ) . . . . . . . . . . . . . . . . . . . . 48LinkState (It is a struct to hold single entry in the Link State Table ) . . . . . . . . . . . . . . . 50LinkStateList (This class implements Topology (Link State) Table ) . . . . . . . . . . . . . . . 52LSU (It defines the Link-State-Update structure embedded in packet ) . . . . . . . . . . . . . . 55NDPAckTimer (This class implements a Acknoledgement TimeOut Timer, who checks that ACK

is received or not for sent beacon ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57NDPAgent (This class implements the Neighbor Discovery Protocol (NDP) ) . . . . . . . . . . 59NDPBeaconTransmitTimer (This class implements a BEACON Transmit Timer, who periodi-

cally sends beacons to NEIGHBOR nodes ) . . . . . . . . . . . . . . . . . . . . . . . 62Neighbor (This class contains NEIGHBOR NODE information ) . . . . . . . . . . . . . . . . . 64NeighborList (It implements the Neighbor Table ) . . . . . . . . . . . . . . . . . . . . . . . . . 66PacketUtil (This class implements packet utilities needed by various classes ) . . . . . . . . . . 69PeripheralNode (It is a struct to hold single entry in the Peripheral Node Table ) . . . . . . . . . 75PeripheralNodeList (This class implements Peripheral Node Table ) . . . . . . . . . . . . . . . 77SendBuffer (This class implements the buffer to store the incoming packets from the upper layer ) 79SendBufferEntry (This class implements the struct to hold one send buffer entry ) . . . . . . . . 81SentQuery (It is a struct to hold single entry in the Sent Query Table ) . . . . . . . . . . . . . . 83SentQueryList (It keeps all the sent route-requests ) . . . . . . . . . . . . . . . . . . . . . . . . 85ZRPAgent (This class implements the Zone Routing Protocol (ZRP) ) . . . . . . . . . . . . . . 87

Page 12: Zrp manual 2

8 Class Index

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

Page 13: Zrp manual 2

Chapter 4

Module Documentation

4.1 Constants

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

Defines

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

• #define ROUTER_PORT 0xffIt is a default routing port for ZRP packets.

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

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

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

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

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

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

• #define MAX_SEQUENCE_ID 1000000This constant is for the range of sequence ids.

• #define IERP_TTL 50

Page 14: Zrp manual 2

10 Module Documentation

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

• #define DEFAULT_BEACON_PERIOD 3

This constant is for the inter beacon transmit time.

• #define DEFAULT_BEACON_PERIOD_JITTER 1

This constant is for the start time variations of beacon transmit timers for different nodes.

• #define DEFAULT_NEIGHBOR_ACK_TIMEOUT 2

This constant is for the verification of whether ACK is received or not after sending the beacon.

• #define DEFAULT_MAX_ACK_TIMEOUT 2

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

• #define DEFAULT_MIN_IARP_UPDATE_PERIOD 3

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

• #define DEFAULT_MAX_IARP_UPDATE_PERIOD 10

This constant is the time elapsed between two consecutive iarp update sent. Here, the update cannot bemissed.

• #define DEFAULT_LINK_LIFETIME 10

This constant is for the value of the residence time of the linkstate in the linkstate list.

• #define DEFAULT_UPDATE_LIFETIME 30

This constant is for the value of the residence time of the update in the detected update list.

• #define 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).

• #define IERP_REPLY_SNOOP 1

This constant is to enable or disable the route reply message snooping.

• #define IERP_ERROR_SNOOP 1

This constant is to enable or disable the route error message snooping.

• #define IERP_XMIT_JITTER 1

This constant is for the calculating jitter for transmitting route request messages.

• #define DEFAULT_QUERY_LIFETIME 30

This constant is for the value of the residence time of the query in the detected query list.

• #define DEFAULT_QUERY_RETRY_TIME 5

This constant is for the value of the residence time of the query in the sent query list.

• #define DEFAULT_ROUTE_LIFETIME 120

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

• #define 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

Page 15: Zrp manual 2

4.1 Constants 11

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

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

• #define DEFAULT_SEND_BUFFER_SIZE 100This constant is for the size of the send buffer.

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

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

Typedefs

• typedef double TimeIn NS2, the time is kept in a double variable.

• typedef int32_t Query_IDQuery_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 defines various ZRP packet types.

• enum BRP_XMIT_POLICY { BRP_UNICAST, BRP_MULTICAST }This enumeration defines two policies for Bordercasting - 1. using Unicast; 2. using multicast.

4.1.1 Detailed Description

This module defines various parameters by which ZRP can be tuned. This module defines following pa-rameters 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

Page 16: Zrp manual 2

12 Module Documentation

4.2 NDP Agent

This module implements the NDP Agent.

Classes

• class NeighborThis class contains NEIGHBOR NODE information.

• class NeighborListIt implements the Neighbor Table.

• class NDPBeaconTransmitTimerThis class implements a BEACON Transmit Timer, who periodically sends beacons to NEIGHBOR nodes.

• class NDPAckTimerThis class implements a Acknoledgement TimeOut Timer, who checks that ACK is received or not for sentbeacon.

• class NDPAgentThis 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 tobeacon.

4. NDP Agent: It implements the NDP Agent functionalities.

#) Tables:

1. NEIGHBOR_TABLE: (Attributes are listed below)

(a) Node_ID(b) Link_Status(c) Last_ACK_Time(d) 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 NeighborDOWN]

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

Page 17: Zrp manual 2

4.3 IARP Agent 13

4.3 IARP Agent

This module implements the IARP Agent.

Classes

• class LinkStateIt is a struct to hold single entry in the Link State Table.

• class LinkStateListThis class implements Topology (Link State) Table.

• class PeripheralNodeIt is a struct to hold single entry in the Peripheral Node Table.

• class PeripheralNodeListThis class implements Peripheral Node Table.

• class InnerRouteIt is a struct to hold single entry in the Route Table.

• class InnerRouteListThis class implements the Routing Table.

• class IARPUpdateIt is a struct to hold single entry in the Detected Update Table.

• class IARPUpdateDetectedListThis class implements Detected Update Table.

• class IARPPeriodicUpdateTimerThis class implements a timer who sends the IARP updates periodically.

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

• class IARPAgentThis 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: Shortestpath)

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

Page 18: Zrp manual 2

14 Module Documentation

4. Detected Update Cache: It keeps all received IARP_UPDATEs for control flooding.

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

Page 19: Zrp manual 2

4.4 IERP Agent 15

4.4 IERP Agent

This module implements the IERP Agent.

Classes

• class DetectedQueryIt is a struct to hold single entry in the Detected Query Table.

• class DetectedQueryListIt keeps all the received route-requests for control flooding.

• class SentQueryIt is a struct to hold single entry in the Sent Query Table.

• class SentQueryListIt keeps all the sent route-requests.

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

• class IERPAgentThis 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 flooding.

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

Page 20: Zrp manual 2

16 Module Documentation

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

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

Page 21: Zrp manual 2

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_zrpIt defines the ZRP Packet Header.

• class LSUIt defines the Link-State-Update structure embedded in packet.

• class PacketUtilThis class implements packet utilities needed by various classes.

• class SendBufferEntryThis class implements the struct to hold one send buffer entry.

• class SendBufferThis class implements the buffer to store the incoming packets from the upper layer.

• class ZRPAgentThis 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 offollowing things:

1. Zrp Header Structure - It defines the Packet header of ZRP packet.

2. Packet Utility Class - It implements various Packet utility finctions.

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

Page 22: Zrp manual 2

18 Module Documentation

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

Page 23: Zrp manual 2

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_

Page 24: Zrp manual 2

20 Class Documentation

Whether the query is Sent/Forwarded or Not.

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

Definition at line 1222 of file zrp.h.

5.1.2 Constructor & Destructor Documentation

5.1.2.1 DetectedQuery::DetectedQuery () [inline]

Default Constructor. Never called from anywhere in the code. Initialized with invalid entries.

Definition at line 1241 of file 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.

Definition at line 1254 of file zrp.h.

The documentation for this class was generated from the following file:

• zrp.h

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

Page 25: Zrp manual 2

5.2 DetectedQueryList Class Reference 21

5.2 DetectedQueryList Class Reference

It keeps all the received route-requests for control flooding.

#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 findQuery (nsaddr_t src, nsaddr_t dest, int queryID, DetectedQuery ∗∗handle)It finds 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 flooding.

Definition at line 1278 of file zrp.h.

5.2.2 Constructor & Destructor Documentation

5.2.2.1 DetectedQueryList::DetectedQueryList () [inline]

Default Constructor. Initialized with default values.

Definition at line 1291 of file zrp.h.

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

Page 26: Zrp manual 2

22 Class Documentation

5.2.3 Member Function Documentation

5.2.3.1 void DetectedQueryList::addQuery (nsaddr_t src, nsaddr_t dest, int queryID, Timeexpiry, 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.

Definition at line 1184 of file zrp.cc.

5.2.3.2 int DetectedQueryList::findQuery (nsaddr_t src, nsaddr_t dest, int queryID,DetectedQuery ∗∗ handle)

It finds 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).

Definition at line 1197 of file 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.

Definition at line 1219 of file zrp.cc.

5.2.3.4 void DetectedQueryList::purgeExpiredQueries ()

It removes all expired queries from the detected query table.

Definition at line 1251 of file zrp.cc.

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

Page 27: Zrp manual 2

5.2 DetectedQueryList Class Reference 23

5.2.3.5 void DetectedQueryList::freeList ()

It removes all queries from the detected query table.

Definition at line 1287 of file zrp.cc.

The documentation for this class was generated from the following files:

• zrp.h• zrp.cc

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

Page 28: Zrp manual 2

24 Class Documentation

5.3 hdr_zrp Struct Reference

It defines 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_

Sender’s 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

Page 29: Zrp manual 2

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

Definition at line 1690 of file zrp.h.

5.3.2 Member Function Documentation

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

Returns the offset value.

Definition at line 1727 of file 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.

Definition at line 1734 of file zrp.h.

The documentation for this struct was generated from the following files:

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

Page 30: Zrp manual 2

26 Class Documentation

• zrp.h• zrp.cc

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

Page 31: Zrp manual 2

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 flag is TRUE; After sending each update, this flag is setFALSE].

• 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

Page 32: Zrp manual 2

28 Class Documentation

Detected-Update Cache.

• 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).

Definition at line 1074 of file zrp.h.

5.4.2 Constructor & Destructor Documentation

5.4.2.1 IARPAgent::IARPAgent (ZRPAgent ∗ agent) [inline]

It initializes the attributes with the default values.

Parameters:

agent Pointer to the ZRP Agent.

Definition at line 1100 of file zrp.h.

5.4.3 Member Function Documentation

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

Definition at line 912 of file zrp.cc.

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

Page 33: Zrp manual 2

5.4 IARPAgent Class Reference 29

5.4.3.2 void IARPAgent::buildRoutingTable ()

This function creates Inner-Route-List & Peripheral-Node-List based on Link-State-List. The followingsteps 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.

Definition at line 930 of file 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.

Definition at line 988 of file 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 it’s 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 flooding,

– re-broadcasts it if TTL is not equal to zero.

• If it’s an already received iarp_update then,

– node discards this update.

Parameters:

p Pointer to the packet.

Definition at line 1009 of file zrp.cc.

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

Page 34: Zrp manual 2

30 Class Documentation

5.4.3.5 void IARPAgent::recv_IARP_DATA (Packet ∗ p)

This function is called whenever ZRP receives an IARP_DATA packet. On receiving IARP_DATA, fol-lowing tasks are performed -

• If it’s 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.

Definition at line 1079 of file zrp.cc.

5.4.3.6 void IARPAgent::print_tables ()

This function prints Peripheral-Node-List & Inner-Route-List.

Definition at line 1130 of file zrp.cc.

The documentation for this class was generated from the following files:

• zrp.h• zrp.cc

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

Page 35: Zrp manual 2

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.

Definition at line 1029 of file zrp.h.

5.5.2 Constructor & Destructor Documentation

5.5.2.1 IARPExpirationTimer::IARPExpirationTimer (ZRPAgent ∗ agent) [inline]

It checks the expiration of entries in various tables.

Parameters:

agent Pointer to the ZRP Agent.

Definition at line 1044 of file zrp.h.

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

Page 36: Zrp manual 2

32 Class Documentation

5.5.3 Member Function Documentation

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

Definition at line 886 of file 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.

Definition at line 880 of file zrp.cc.

The documentation for this class was generated from the following files:

• zrp.h• zrp.cc

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

Page 37: Zrp manual 2

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.

Definition at line 973 of file zrp.h.

5.6.2 Constructor & Destructor Documentation

5.6.2.1 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

Page 38: Zrp manual 2

34 Class Documentation

Definition at line 990 of file zrp.h.

5.6.3 Member Function Documentation

5.6.3.1 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 listwith link-status.

Parameters:

e Event object.

Definition at line 798 of file zrp.cc.

5.6.3.2 void IARPPeriodicUpdateTimer::start (double thistime)

This function is called to start this Timer. It schedules the first transmit event.

Parameters:

thistime Delay after which this event should be scheduled.

Definition at line 792 of file zrp.cc.

The documentation for this class was generated from the following files:

• zrp.h• zrp.cc

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

Page 39: Zrp manual 2

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.

Definition at line 878 of file zrp.h.

5.7.2 Constructor & Destructor Documentation

5.7.2.1 IARPUpdate::IARPUpdate () [inline]

Default Constructor. Never called from anywhere in the code. Initialized with invalid entries.

Definition at line 893 of file 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

Page 40: Zrp manual 2

36 Class Documentation

expiry Time of expiration.

Definition at line 901 of file zrp.h.

The documentation for this class was generated from the following file:

• zrp.h

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

Page 41: Zrp manual 2

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 findUpdate (nsaddr_t updateSrc, int seq)

It finds 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.

Definition at line 914 of file zrp.h.

5.8.2 Constructor & Destructor Documentation

5.8.2.1 IARPUpdateDetectedList::IARPUpdateDetectedList () [inline]

Default Constructor. Initialized with default values.

Definition at line 927 of file zrp.h.

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

Page 42: Zrp manual 2

38 Class Documentation

5.8.3 Member Function Documentation

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

Definition at line 704 of file zrp.cc.

5.8.3.2 int IARPUpdateDetectedList::findUpdate (nsaddr_t updateSrc, int seq)

It finds the update with matching parameters from the detected update table. And if found, returns TRUEand FALSE otherwise.

Parameters:

updateSrc Update source.

seq Sequence number.

Definition at line 717 of file zrp.cc.

5.8.3.3 void IARPUpdateDetectedList::purgeExpiredUpdates ()

It removes all expired updates from the detected update table.

Definition at line 733 of file zrp.cc.

5.8.3.4 void IARPUpdateDetectedList::freeList ()

It removes all updates from the detected update table.

Definition at line 767 of file zrp.cc.

The documentation for this class was generated from the following files:

• zrp.h• zrp.cc

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

Page 43: Zrp manual 2

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

Page 44: Zrp manual 2

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.

Definition at line 1499 of file zrp.h.

5.9.2 Constructor & Destructor Documentation

5.9.2.1 IERPAgent::IERPAgent (ZRPAgent ∗ agent) [inline]

It initializes the attributes with the default values.

Parameters:

agent Pointer to the ZRP Agent.

Definition at line 1542 of file zrp.h.

5.9.3 Member Function Documentation

5.9.3.1 IERPAgent::startUp ()

This is called when the node is initialized from the ZRPAgent::startUp() method. It does the followingthings:

• Clears the detected query list.

• Clears the sent query list.

Definition at line 1468 of file zrp.cc.

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

Page 45: Zrp manual 2

5.9 IERPAgent Class Reference 41

5.9.3.2 void IERPAgent::recv_IERP_ROUTE_REQUEST_UNI (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 toroute-request-originator.

• If destination lies in node’s 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.

Definition at line 1518 of file 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 toroute-request-originator.

• If destination lies in node’s 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 routetable.

• Otherwise, it snoops the packet for stored route and updates its own route table and then it forwardsthe route-reply.

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

Page 46: Zrp manual 2

42 Class Documentation

Parameters:

p Pointer to the packet.

Definition at line 1956 of file zrp.cc.

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 finds out which route is broken and removes it fromthe route-table.

• Otherwise, it snoops the packet for broken link info and updates its own routing table and then itforwards the route-error.

Parameters:

p Pointer to the packet.

Definition at line 2015 of file 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.

Definition at line 2056 of file 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. Thelink-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.

Definition at line 1908 of file zrp.cc.

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

Page 47: Zrp manual 2

5.9 IERPAgent Class Reference 43

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

Definition at line 1939 of file zrp.cc.

The documentation for this class was generated from the following files:

• zrp.h• zrp.cc

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

Page 48: Zrp manual 2

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.

Definition at line 1454 of file zrp.h.

5.10.2 Constructor & Destructor Documentation

5.10.2.1 IERPExpirationTimer::IERPExpirationTimer (ZRPAgent ∗ agent) [inline]

It checks the expiration of entries in various tables.

Parameters:

agent Pointer to the ZRP Agent.

Definition at line 1469 of file zrp.h.

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

Page 49: Zrp manual 2

5.10 IERPExpirationTimer Class Reference 45

5.10.3 Member Function Documentation

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

Definition at line 1447 of file 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.

Definition at line 1441 of file zrp.cc.

The documentation for this class was generated from the following files:

• zrp.h• zrp.cc

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

Page 50: Zrp manual 2

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.

Definition at line 780 of file zrp.h.

5.11.2 Constructor & Destructor Documentation

5.11.2.1 InnerRoute::InnerRoute () [inline]

Default Constructor. Never called from anywhere in the code. Initialized with invalid entries.

Definition at line 796 of file zrp.h.

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

Page 51: Zrp manual 2

5.11 InnerRoute Class Reference 47

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

Definition at line 808 of file zrp.h.

The documentation for this class was generated from the following file:

• zrp.h

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

Page 52: Zrp manual 2

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 findRoute (nsaddr_t addr, InnerRoute ∗∗handle)It finds 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.

Definition at line 822 of file zrp.h.

5.12.2 Constructor & Destructor Documentation

5.12.2.1 InnerRouteList::InnerRouteList () [inline]

Default Constructor. Initialized with default values.

Definition at line 837 of file zrp.h.

5.12.3 Member Function Documentation

5.12.3.1 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

Page 53: Zrp manual 2

5.12 InnerRouteList Class Reference 49

Parameters:

addr Destination Address.

nextHop Route towards the destination.

predecessor Predecessor in the route to this destinaion.

numHops The route length.

Definition at line 631 of file zrp.cc.

5.12.3.2 int InnerRouteList::findRoute (nsaddr_t addr, InnerRoute ∗∗ handle)

It finds 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)

Definition at line 651 of file zrp.cc.

5.12.3.3 void InnerRouteList::freeList ()

It removes all routes from the routing table.

Definition at line 676 of file zrp.cc.

The documentation for this class was generated from the following files:

• zrp.h• zrp.cc

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

Page 54: Zrp manual 2

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.

Definition at line 562 of file zrp.h.

5.13.2 Constructor & Destructor Documentation

5.13.2.1 LinkState::LinkState () [inline]

Default Constructor. Never called from anywhere in the code. Initialized with invalid entries.

Definition at line 579 of file zrp.h.

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

Page 55: Zrp manual 2

5.13 LinkState Class Reference 51

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

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

Definition at line 592 of file zrp.h.

The documentation for this class was generated from the following file:

• zrp.h

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

Page 56: Zrp manual 2

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 findLink (nsaddr_t src, nsaddr_t dest, LinkState ∗∗handle)

It finds 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.

Definition at line 607 of file zrp.h.

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

Page 57: Zrp manual 2

5.14 LinkStateList Class Reference 53

5.14.2 Constructor & Destructor Documentation

5.14.2.1 LinkStateList::LinkStateList () [inline]

Default Constructor. Initialized with default values.

Definition at line 620 of file zrp.h.

5.14.3 Member Function Documentation

5.14.3.1 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 statedest Destination of link stateseq Sequence number of link stateisup Link statusexpiry Expiry time of the link state

Definition at line 410 of file zrp.cc.

5.14.3.2 int LinkStateList::findLink (nsaddr_t src, nsaddr_t dest, LinkState ∗∗ handle)

It finds 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 statedest Destination of link statehandle Handle to the link state (If found)

Definition at line 423 of file 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.

Definition at line 448 of file 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.

Definition at line 458 of file zrp.cc.

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

Page 58: Zrp manual 2

54 Class Documentation

5.14.3.5 int LinkStateList::purgeLinks ()

It removes all expired links from the link state table.

Definition at line 479 of file zrp.cc.

5.14.3.6 void LinkStateList::printLinks ()

It prints all the links on the console. Used for debugging purpose.

Definition at line 519 of file zrp.cc.

5.14.3.7 void LinkStateList::freeList ()

It removes all links from the link state table.

Definition at line 539 of file zrp.cc.

The documentation for this class was generated from the following files:

• zrp.h• zrp.cc

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

Page 59: Zrp manual 2

5.15 LSU Class Reference 55

5.15 LSU Class Reference

It defines 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 defines the Link-State-Update structure embedded in packet.

Definition at line 1744 of file zrp.h.

5.15.2 Constructor & Destructor Documentation

5.15.2.1 LSU::LSU () [inline]

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

Definition at line 1757 of file 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

Page 60: Zrp manual 2

56 Class Documentation

Definition at line 1767 of file zrp.h.

The documentation for this class was generated from the following file:

• zrp.h

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

Page 61: Zrp manual 2

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

#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 sentbeacon.

Definition at line 399 of file zrp.h.

5.16.2 Constructor & Destructor Documentation

5.16.2.1 NDPAckTimer::NDPAckTimer (ZRPAgent ∗ agent) [inline]

It initializes the attributes with the default values.

Parameters:

agent Pointer to the ZRP Agent.

Definition at line 413 of file zrp.h.

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

Page 62: Zrp manual 2

58 Class Documentation

5.16.3 Member Function Documentation

5.16.3.1 void NDPAckTimer::handle (Event ∗ e)

It implements the code for checking ACK timeout. If node doesn’t receive ACK from an existing neigh-bor 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 notifies IARP to rebuild the ’INNER_ROUTING_TABLE’ and ’PERIPHERAL_NODE_-TABLE’.

Parameters:

e Event Object.

Definition at line 222 of file zrp.cc.

5.16.3.2 void NDPAckTimer::start ()

This function is called to start this Timer.

Definition at line 216 of file zrp.cc.

The documentation for this class was generated from the following files:

• zrp.h• zrp.cc

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

Page 63: Zrp manual 2

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.

Definition at line 441 of file zrp.h.

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

Page 64: Zrp manual 2

60 Class Documentation

5.17.2 Constructor & Destructor Documentation

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

Definition at line 459 of file zrp.h.

5.17.3 Member Function Documentation

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

Definition at line 284 of file 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 storesonly symmetric links.

Parameters:

p Pointer to packet.

Definition at line 298 of file 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 it’s a new neighbor, node adds the neighbor to its ’NEIGHBOR_TABLE’ and notifies IARP torebuild the ’INNER_ROUTING_TABLE’ and ’PERIPHERAL_NODE_TABLE’.

• If it’s an existing neighbor, it updates ’LAST_ACK_TIME’ for that neighbor.

Parameters:

p Pointer to packet.

Definition at line 326 of file zrp.cc.

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

Page 65: Zrp manual 2

5.17 NDPAgent Class Reference 61

5.17.3.4 void NDPAgent::print_tables ()

This function prints the Neighbor List. It also prints which Neighbors are UP and which are DOWN.

Definition at line 374 of file zrp.cc.

The documentation for this class was generated from the following files:

• zrp.h• zrp.cc

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

Page 66: Zrp manual 2

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.

Definition at line 351 of file zrp.h.

5.18.2 Constructor & Destructor Documentation

5.18.2.1 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

Page 67: Zrp manual 2

5.18 NDPBeaconTransmitTimer Class Reference 63

Parameters:

agent Pointer to the ZRP Agent.

Definition at line 368 of file zrp.h.

5.18.3 Member Function Documentation

5.18.3.1 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 aftertime-out event.

Parameters:

e Event Object.

Definition at line 188 of file zrp.cc.

5.18.3.2 void NDPBeaconTransmitTimer::start (double thistime)

This function is called to start this Timer. It schedules the first transmit event.

Parameters:

thistime Delay after which this event should be scheduled.

Definition at line 182 of file zrp.cc.

The documentation for this class was generated from the following files:

• zrp.h• zrp.cc

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

Page 68: Zrp manual 2

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.

Definition at line 233 of file zrp.h.

5.19.2 Constructor & Destructor Documentation

5.19.2.1 Neighbor::Neighbor () [inline]

Default Constructor. Never called from anywhere in the code. Initializes with invalid entries.

Definition at line 248 of file zrp.h.

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

Page 69: Zrp manual 2

5.19 Neighbor Class Reference 65

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

It initializes the neighbor with passed parameter values.

Parameters:

addr Neighbor address.

lastack Last ACK Time.

linkStatus Link status with neighbor.

Definition at line 259 of file zrp.h.

The documentation for this class was generated from the following file:

• zrp.h

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

Page 70: Zrp manual 2

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 findNeighbor (nsaddr_t addr, Neighbor ∗∗handle)

It finds 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.

Definition at line 269 of file zrp.h.

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

Page 71: Zrp manual 2

5.20 NeighborList Class Reference 67

5.20.2 Constructor & Destructor Documentation

5.20.2.1 NeighborList::NeighborList () [inline]

Default constructor. Initializes the list by startup values.

Definition at line 281 of file zrp.h.

5.20.3 Member Function Documentation

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

Definition at line 23 of file zrp.cc.

5.20.3.2 int NeighborList::findNeighbor (nsaddr_t addr, Neighbor ∗∗ handle)

It finds 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)

Definition at line 36 of file zrp.cc.

5.20.3.3 int NeighborList::isEmpty ()

Checks if neighbor table is empty or not. Returns TRUE if empty; FALSE if not.

Definition at line 61 of file 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. Theprevious 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.

Definition at line 71 of file zrp.cc.

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

Page 72: Zrp manual 2

68 Class Documentation

5.20.3.5 void NeighborList::purgeDownNeighbors ()

It removes all neighbors whose link status is LINKDOWN.

Definition at line 92 of file zrp.cc.

5.20.3.6 void NeighborList::freeList ()

It removes all neighbors from the neighbor table.

Definition at line 125 of file zrp.cc.

5.20.3.7 void NeighborList::printNeighbors ()

It prints all neighbors in the neighbor table.

Definition at line 143 of file zrp.cc.

The documentation for this class was generated from the following files:

• zrp.h• zrp.cc

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

Page 73: Zrp manual 2

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 specified by parameter.

• void pkt_broadcast (Packet ∗p, Time randomJitter)Schedules the packet to broadcast with delay specified 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

Page 74: Zrp manual 2

70 Class Documentation

• void pkt_print_links (Packet ∗p)

Prints all links contained in the packet.

• 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

Definition at line 1785 of file zrp.h.

5.21.2 Constructor & Destructor Documentation

5.21.2.1 PacketUtil::PacketUtil (ZRPAgent ∗ agent) [inline]

This constructor passed the pointer to the agent.

Parameters:

agent Pointer to the ZRP Agent.

Definition at line 1799 of file zrp.h.

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

Page 75: Zrp manual 2

5.21 PacketUtil Class Reference 71

5.21.3 Member Function Documentation

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

Definition at line 2187 of file 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.

Definition at line 2233 of file zrp.cc.

5.21.3.3 void PacketUtil::inc_seq () [inline]

It increments the sequence number of the packet.

Definition at line 1827 of file zrp.h.

5.21.3.4 void PacketUtil::pkt_send (Packet ∗ p, nsaddr_t addressee, Time delay)

Schedules the packet for transmission with delay specified by parameter.

Parameters:

p Pointer to the Packet.addressee The destination.delay The delay after which the packet should be transmitted.

Definition at line 2296 of file zrp.cc.

5.21.3.5 void PacketUtil::pkt_broadcast (Packet ∗ p, Time randomJitter)

Schedules the packet to broadcast with delay specified by parameter.

Parameters:

p Pointer to the Packet.randomJitter The delay after which the packet should be broadcasted.

Definition at line 2312 of file zrp.cc.

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

Page 76: Zrp manual 2

72 Class Documentation

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

Alloactes the memory to hold the link-states.

Parameters:

p Pointer to packet.

size Number of link-states to be hold.

Definition at line 2325 of file zrp.cc.

5.21.3.7 void PacketUtil::pkt_free_LSU_space (Packet ∗ p)

Frees the memory allocated to hold link-states.

Parameters:

p Pointer to the packet.

Definition at line 2344 of file zrp.cc.

5.21.3.8 void PacketUtil::pkt_add_ROUTE_space (Packet ∗ p, int size)

Allocates memory to hold the source route.

Parameters:

p Pointer to the packet.

size Length of the source route.

Definition at line 2355 of file zrp.cc.

5.21.3.9 void PacketUtil::pkt_free_ROUTE_space (Packet ∗ p)

Frees the memory allocated to hold source route.

Parameters:

p Pointer to the packet.

Definition at line 2374 of file zrp.cc.

5.21.3.10 void PacketUtil::pkt_add_ADDRESS_space (Packet ∗ p, int size)

Parameters:

p Pointer to the packet.

size Size of multicast address list.

Definition at line 2385 of file zrp.cc.

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

Page 77: Zrp manual 2

5.21 PacketUtil Class Reference 73

5.21.3.11 void PacketUtil::pkt_free_ADDRESS_space (Packet ∗ p)

Frees the memory allocated to hold multicast address list.

Parameters:

p Pointer to the packet.

Definition at line 2404 of file zrp.cc.

5.21.3.12 int PacketUtil::pkt_AmIMultiCastReciver (Packet ∗ p, nsaddr_t addressToCheck)

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

Parameters:

p Pointer to packet.

addressToCheck The address to check.

Definition at line 2415 of file zrp.cc.

5.21.3.13 int PacketUtil::pkt_AmIOnTheRoute (Packet ∗ p, nsaddr_t addressToCheck)

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

Parameters:

p Pointer to the packet.

addressToCheck The address to check.

Definition at line 2434 of file zrp.cc.

5.21.3.14 void PacketUtil::pkt_print_links (Packet ∗ p)

Prints all links contained in the packet.

Parameters:

p Pointer to the packet.

Definition at line 2452 of file zrp.cc.

5.21.3.15 void PacketUtil::pkt_print_route (Packet ∗ p)

Prints the source route contained in the packet.

Parameters:

p Pointer the the packet.

Definition at line 2471 of file zrp.cc.

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

Page 78: Zrp manual 2

74 Class Documentation

5.21.3.16 void PacketUtil::pkt_drop (Packet ∗ p)

Drops the packet. Frees the packet memory. but not dynamically allocated attributes.

Parameters:

p Pointer the the packet.

Definition at line 2490 of file zrp.cc.

The documentation for this class was generated from the following files:

• zrp.h• zrp.cc

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

Page 79: Zrp manual 2

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.

Definition at line 692 of file zrp.h.

5.22.2 Constructor & Destructor Documentation

5.22.2.1 PeripheralNode::PeripheralNode () [inline]

Default Constructor. Never called from anywhere in the code. Initialized with invalid entries.

Definition at line 706 of file 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

Page 80: Zrp manual 2

76 Class Documentation

Definition at line 715 of file zrp.h.

The documentation for this class was generated from the following file:

• zrp.h

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

Page 81: Zrp manual 2

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 findPerNode (nsaddr_t addr)

It finds 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

Definition at line 722 of file zrp.h.

5.23.2 Constructor & Destructor Documentation

5.23.2.1 PeripheralNodeList::PeripheralNodeList () [inline]

Default Constructor. Initialized with default values.

Definition at line 735 of file zrp.h.

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

Page 82: Zrp manual 2

78 Class Documentation

5.23.3 Member Function Documentation

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

Definition at line 566 of file zrp.cc.

5.23.3.2 int PeripheralNodeList::findPerNode (nsaddr_t addr)

It finds the node from the peripheral node table. It returns TRUE if found and FALSE otherwise.

Parameters:

addr Address of the node to be found.

Definition at line 579 of file 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.

Definition at line 595 of file zrp.cc.

5.23.3.4 void PeripheralNodeList::freeList ()

It removes all nodes from the peripheral node table.

Definition at line 606 of file zrp.cc.

The documentation for this class was generated from the following files:

• zrp.h• zrp.cc

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

Page 83: Zrp manual 2

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 forincoming packet is not found then they are pushed into this buffer. It is implemented as singly linked-list.

Definition at line 1981 of file zrp.h.

5.24.2 Constructor & Destructor Documentation

5.24.2.1 SendBuffer::SendBuffer (ZRPAgent ∗ agent) [inline]

It initializes the the object with default values.

Parameters:

agent Pointer to the ZRP Agent.

Definition at line 1994 of file zrp.h.

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

Page 84: Zrp manual 2

80 Class Documentation

5.24.3 Member Function Documentation

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

Definition at line 2513 of file zrp.cc.

5.24.3.2 void SendBuffer::purgeExpiredPackets ()

It removes the expired entries from the buffer.

Definition at line 2526 of file zrp.cc.

5.24.3.3 void SendBuffer::freeList ()

It removes all the entries from the list.

Definition at line 2568 of file zrp.cc.

The documentation for this class was generated from the following files:

• zrp.h• zrp.cc

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

Page 85: Zrp manual 2

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.

Definition at line 1949 of file zrp.h.

5.25.2 Constructor & Destructor Documentation

5.25.2.1 SendBufferEntry::SendBufferEntry () [inline]

Default Constructor. Not called anywhere in the code. Intialized with invalid entries.

Definition at line 1962 of file zrp.h.

5.25.2.2 SendBufferEntry::SendBufferEntry (Packet ∗ pkt, nsaddr_t dest, Time expiry)[inline]

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

Page 86: Zrp manual 2

82 Class Documentation

Parameters:

pkt Pointer to the packet.

dest Address of destination.

expiry Expration time of the packet from sendbuffer.

Definition at line 1972 of file zrp.h.

The documentation for this class was generated from the following file:

• zrp.h

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

Page 87: Zrp manual 2

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.

Definition at line 1349 of file zrp.h.

5.26.2 Constructor & Destructor Documentation

5.26.2.1 SentQuery::SentQuery () [inline]

Default Constructor. Never called from anywhere in the code. Initialized with invalid entries.

Definition at line 1364 of file 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

Page 88: Zrp manual 2

84 Class Documentation

expiry Expiry of this sent Entry.

Definition at line 1372 of file zrp.h.

The documentation for this class was generated from the following file:

• zrp.h

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

Page 89: Zrp manual 2

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 findQuery (nsaddr_t src, nsaddr_t dest, SentQuery ∗∗handle)It finds 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 messagescome OR they expire.

Definition at line 1385 of file zrp.h.

5.27.2 Constructor & Destructor Documentation

5.27.2.1 SentQueryList::SentQueryList () [inline]

Default Constructor. Initialized with default values.

Definition at line 1398 of file zrp.h.

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

Page 90: Zrp manual 2

86 Class Documentation

5.27.3 Member Function Documentation

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

Definition at line 1314 of file zrp.cc.

5.27.3.2 int SentQueryList::findQuery (nsaddr_t src, nsaddr_t dest, SentQuery ∗∗ handle)

It finds 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).

Definition at line 1328 of file 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.

Definition at line 1350 of file zrp.cc.

5.27.3.4 void SentQueryList::purgeExpiredQueries ()

It removes all the expired queries from the sent query table.

Definition at line 1380 of file zrp.cc.

5.27.3.5 void SentQueryList::freeList ()

It removes all the queries from the sent query table.

Definition at line 1414 of file zrp.cc.

The documentation for this class was generated from the following files:

• zrp.h• zrp.cc

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

Page 91: Zrp manual 2

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 couldn’t be sent on MAC layer.

• Packet ∗Myallocpkt ()

It’s just a wrapper function on Agent::allocpkt(). Basically, it allocates the memory for the packet.

• void Mydrop (Packet ∗p, const char ∗s)

It’s just a wrapper function on Agent::drop(Packet ∗p, const char ∗s). It drops the packet for the reasongiven 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

Page 92: Zrp manual 2

88 Class Documentation

Public Attributes

• char ∗ myid_• PriQueue ∗ ll_queue• Trace ∗ tracetarget• MobileNode ∗ node_• NsObject ∗ port_dmux_• nsaddr_t myaddr_

It’s my own Node Address.

• int radius_It’s 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 fromthe ’Agent’ class.

Definition at line 2032 of file zrp.h.

5.28.2 Constructor & Destructor Documentation

5.28.2.1 ZRPAgent::ZRPAgent ()

It is just a default consturctor.

Definition at line 2597 of file zrp.cc.

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

Page 93: Zrp manual 2

5.28 ZRPAgent Class Reference 89

5.28.2.2 ZRPAgent::ZRPAgent (nsaddr_t id)

Through this constructor, the node address is passed to agent. ZRP Agent is initialized with default valuesin this constructor. Don’t forget the put the following line in the tcl script to initialize the zone radius forthis node.

Agent/ZRP set radius_ 2 [Here, Zone Radius is set to 2.]

Parameters:

id Address of the Node.

Definition at line 2614 of file zrp.cc.

5.28.3 Member Function Documentation

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

Definition at line 2640 of file 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.

Definition at line 2651 of file zrp.cc.

5.28.3.3 ZRPAgent::recv (Packet ∗ p, Handler ∗ h)

It receives the packet. Here, the packet is classified into following categories and sub-categories. Then, itis 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

Page 94: Zrp manual 2

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.

Definition at line 2766 of file 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.

Definition at line 2838 of file 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 iscalled whenever the Route Table is changed. So, if there are packets destined in Send Buffer towards newlydiscovered destination, then they are immediately sent using that new route.

Definition at line 2902 of file 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.

Definition at line 2943 of file 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.

Definition at line 3007 of file zrp.cc.

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

Page 95: Zrp manual 2

5.28 ZRPAgent Class Reference 91

5.28.3.8 ZRPAgent::mac_failed (Packet ∗ p)

It reports a mac failure event for all the packets who couldn’t be sent on MAC layer. Currently, this is usedfor 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.

Definition at line 3015 of file zrp.cc.

5.28.3.9 ZRPAgent::Myallocpkt () [inline]

It’s just a wrapper function on Agent::allocpkt(). Basically, it allocates the memory for the packet.

Definition at line 2167 of file zrp.h.

5.28.3.10 ZRPAgent::Mydrop (Packet ∗ p, const char ∗ s) [inline]

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

Parameters:

p Pointer to the packet.

s Reason of dropping the packet.

Definition at line 2179 of file 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.

Definition at line 2190 of file zrp.h.

The documentation for this class was generated from the following files:

• zrp.h• zrp.cc

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

Page 96: Zrp manual 2

Index

accesshdr_zrp, 25

addLinkLinkStateList, 53

addLinkStateFromRouteIERPAgent, 42

addNeighborNeighborList, 67

addPacketSendBuffer, 80

addPerNodePeripheralNodeList, 78

addQueryDetectedQueryList, 22SentQueryList, 86

addRouteInnerRouteList, 48

addRouteInPacketIARPAgent, 29

addUpdateIARPUpdateDetectedList, 38

buildRoutingTableIARPAgent, 28

commandZRPAgent, 89

Constants, 9copyList

PeripheralNodeList, 78

DetectedQuery, 19DetectedQuery, 20

DetectedQueryList, 21addQuery, 22DetectedQueryList, 21findQuery, 22freeList, 22purgeExpiredQueries, 22removeQuery, 22

findLinkLinkStateList, 53

findNeighborNeighborList, 67

findPerNode

PeripheralNodeList, 78findQuery

DetectedQueryList, 22SentQueryList, 86

findRouteInnerRouteList, 49

findUpdateIARPUpdateDetectedList, 38

freeListDetectedQueryList, 22IARPUpdateDetectedList, 38InnerRouteList, 49LinkStateList, 54NeighborList, 68PeripheralNodeList, 78SendBuffer, 80SentQueryList, 86

handleIARPExpirationTimer, 32IARPPeriodicUpdateTimer, 34IERPExpirationTimer, 45NDPAckTimer, 58NDPBeaconTransmitTimer, 63

hdr_zrp, 24access, 25offset, 25

IARP Agent, 13IARPAgent, 27

addRouteInPacket, 29buildRoutingTable, 28IARPAgent, 28print_tables, 30recv_IARP_DATA, 29recv_IARP_UPDATE, 29startUp, 28

IARPExpirationTimer, 31handle, 32IARPExpirationTimer, 31start, 32

IARPPeriodicUpdateTimer, 33handle, 34IARPPeriodicUpdateTimer, 33start, 34

Page 97: Zrp manual 2

INDEX 93

IARPUpdate, 35IARPUpdate, 35

IARPUpdateDetectedList, 37addUpdate, 38findUpdate, 38freeList, 38IARPUpdateDetectedList, 37purgeExpiredUpdates, 38

IERP Agent, 15IERPAgent, 39

addLinkStateFromRoute, 42IERPAgent, 40recv_IERP_DATA, 42recv_IERP_ROUTE_ERROR, 42recv_IERP_ROUTE_REPLY, 41recv_IERP_ROUTE_REQUEST_MC, 41recv_IERP_ROUTE_REQUEST_UNI, 40removeLinkStateFromBrokenRoute, 42startUp, 40

IERPExpirationTimer, 44handle, 45IERPExpirationTimer, 44start, 45

inc_seqPacketUtil, 71

InnerRoute, 46InnerRoute, 46

InnerRouteList, 48addRoute, 48findRoute, 49freeList, 49InnerRouteList, 48

isEmptyLinkStateList, 53NeighborList, 67

LinkState, 50LinkState, 50

LinkStateList, 52addLink, 53findLink, 53freeList, 54isEmpty, 53LinkStateList, 53printLinks, 54purgeLinks, 53removeLink, 53

LSU, 55LSU, 55

mac_failedZRPAgent, 90

MyallocpktZRPAgent, 91

MydropZRPAgent, 91

NDP Agent, 12NDPAckTimer, 57

handle, 58NDPAckTimer, 57start, 58

NDPAgent, 59NDPAgent, 60print_tables, 60recv_NDP_BEACON, 60recv_NDP_BEACON_ACK, 60startUp, 60

NDPBeaconTransmitTimer, 62handle, 63NDPBeaconTransmitTimer, 62start, 63

Neighbor, 64Neighbor, 64

NeighborList, 66addNeighbor, 67findNeighbor, 67freeList, 68isEmpty, 67NeighborList, 67printNeighbors, 68purgeDownNeighbors, 67removeNeighbor, 67

offsethdr_zrp, 25

PacketUtil, 69inc_seq, 71PacketUtil, 70pkt_add_ADDRESS_space, 72pkt_add_LSU_space, 71pkt_add_ROUTE_space, 72pkt_AmIMultiCastReciver, 73pkt_AmIOnTheRoute, 73pkt_broadcast, 71pkt_copy, 71pkt_create, 71pkt_drop, 73pkt_free_ADDRESS_space, 72pkt_free_LSU_space, 72pkt_free_ROUTE_space, 72pkt_print_links, 73pkt_print_route, 73pkt_send, 71

PeripheralNode, 75PeripheralNode, 75

PeripheralNodeList, 77

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

Page 98: Zrp manual 2

94 INDEX

addPerNode, 78copyList, 78findPerNode, 78freeList, 78PeripheralNodeList, 77

pkt_add_ADDRESS_spacePacketUtil, 72

pkt_add_LSU_spacePacketUtil, 71

pkt_add_ROUTE_spacePacketUtil, 72

pkt_AmIMultiCastReciverPacketUtil, 73

pkt_AmIOnTheRoutePacketUtil, 73

pkt_broadcastPacketUtil, 71

pkt_copyPacketUtil, 71

pkt_createPacketUtil, 71

pkt_dropPacketUtil, 73

pkt_free_ADDRESS_spacePacketUtil, 72

pkt_free_LSU_spacePacketUtil, 72

pkt_free_ROUTE_spacePacketUtil, 72

pkt_print_linksPacketUtil, 73

pkt_print_routePacketUtil, 73

pkt_sendPacketUtil, 71

print_tablesIARPAgent, 30NDPAgent, 60ZRPAgent, 90

printLinksLinkStateList, 54

printNeighborsNeighborList, 68

purgeDownNeighborsNeighborList, 67

purgeExpiredPacketsSendBuffer, 80

purgeExpiredQueriesDetectedQueryList, 22SentQueryList, 86

purgeExpiredUpdatesIARPUpdateDetectedList, 38

purgeLinksLinkStateList, 53

recvZRPAgent, 89

recv_IARP_DATAIARPAgent, 29

recv_IARP_UPDATEIARPAgent, 29

recv_IERP_DATAIERPAgent, 42

recv_IERP_ROUTE_ERRORIERPAgent, 42

recv_IERP_ROUTE_REPLYIERPAgent, 41

recv_IERP_ROUTE_REQUEST_MCIERPAgent, 41

recv_IERP_ROUTE_REQUEST_UNIIERPAgent, 40

recv_NDP_BEACONNDPAgent, 60

recv_NDP_BEACON_ACKNDPAgent, 60

removeLinkLinkStateList, 53

removeLinkStateFromBrokenRouteIERPAgent, 42

removeNeighborNeighborList, 67

removeQueryDetectedQueryList, 22SentQueryList, 86

route_pktZRPAgent, 90

route_SendBuffer_pktZRPAgent, 90

SendBuffer, 79addPacket, 80freeList, 80purgeExpiredPackets, 80SendBuffer, 79

SendBufferEntry, 81SendBufferEntry, 81

sendPacketUsingIARPRouteZRPAgent, 90

SentQuery, 83SentQuery, 83

SentQueryList, 85addQuery, 86findQuery, 86freeList, 86purgeExpiredQueries, 86removeQuery, 86SentQueryList, 85

startIARPExpirationTimer, 32

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

Page 99: Zrp manual 2

INDEX 95

IARPPeriodicUpdateTimer, 34IERPExpirationTimer, 45NDPAckTimer, 58NDPBeaconTransmitTimer, 63

startUpIARPAgent, 28IERPAgent, 40NDPAgent, 60ZRPAgent, 89

XmitPacketZRPAgent, 91

ZRP Agent, 17ZRPAgent, 87

command, 89mac_failed, 90Myallocpkt, 91Mydrop, 91print_tables, 90recv, 89route_pkt, 90route_SendBuffer_pkt, 90sendPacketUsingIARPRoute, 90startUp, 89XmitPacket, 91ZRPAgent, 88

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