5. Chapter 1
Introduction
This document provides implementation documentation of ZRP agent for NS v2.33. It provides the answers
for following ’how to’ questions:
1. How to patch ZRP agent in the NS2?
2. How to run simulations using this agent?
3. How to use this Manual?
1.1 How to patch ZRP agent in the NS2?
In order to patch the ZRP agent, 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 so
that it should be placed in NS home directory.
3. patchmyZRP.sh
• Once you do the aforementioned tasks, then you need to rebuild the NS2. All these operations
are scripted in this shell script. So, for patching ZRP agent, only you need to do is run this shell
script in NS home directory. (Please go through the README file for the instructions.)
6. 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 be
familiar with the most of the code if you have run some simulations in NS2. But one thing you should
notice is - you need to write a following code-line in the tcl script to set the default zone radius value.
"Agent/ZRP set radius_ 2"
# ======================================================================
# 1. 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
7. 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
8. 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 module
containes a component of ZRP. New reader is adviced to go through the module section first to get the idea
of ZRP implementation design. Second it represents the the code according to the class definitions and its
detailed documentation in terms of its data and member functions.
1.4 Referrence Documents
Following are some of the documents which may help to understand the code better.
1. NS2 Documentation (Available at: http://www.isi.edu/nsnam/ns/ns-documentation.html)
2. ZRP IETF Drafts (Available at: http://tools.ietf.org/html/draft-ietf-manet-zone-zrp-04)
3. Creating agents in NS2 (Available at: http://masimum.inf.um.es/nsrt-howto/pdf/nsrt-howto.pdf)
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen
10. 6 Module Index
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen
11. 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 ) . . . . . . . . . . 19
DetectedQueryList (It keeps all the received route-requests for control flooding ) . . . . . . . . . 21
hdr_zrp (It defines the ZRP Packet Header ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
IARPAgent (This class implements the IntrAzone Routing Protocol (IARP) ) . . . . . . . . . . 27
IARPExpirationTimer (It implements a timer who checks periodically for the expiry of various
entries in IARP tables ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
IARPPeriodicUpdateTimer (This class implements a timer who sends the IARP updates period-
ically ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
IARPUpdate (It is a struct to hold single entry in the Detected Update Table ) . . . . . . . . . . 35
IARPUpdateDetectedList (This class implements Detected Update Table ) . . . . . . . . . . . . 37
IERPAgent (This class implements the IntEr Routing Protocol (IERP) ) . . . . . . . . . . . . . 39
IERPExpirationTimer (It implements a timer who checks periodically for the expiry of various
entries in IERP tables ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
InnerRoute (It is a struct to hold single entry in the Route Table ) . . . . . . . . . . . . . . . . . 46
InnerRouteList (This class implements the Routing Table ) . . . . . . . . . . . . . . . . . . . . 48
LinkState (It is a struct to hold single entry in the Link State Table ) . . . . . . . . . . . . . . . 50
LinkStateList (This class implements Topology (Link State) Table ) . . . . . . . . . . . . . . . 52
LSU (It defines the Link-State-Update structure embedded in packet ) . . . . . . . . . . . . . . 55
NDPAckTimer (This class implements a Acknoledgement TimeOut Timer, who checks that ACK
is received or not for sent beacon ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
NDPAgent (This class implements the Neighbor Discovery Protocol (NDP) ) . . . . . . . . . . 59
NDPBeaconTransmitTimer (This class implements a BEACON Transmit Timer, who periodi-
cally sends beacons to NEIGHBOR nodes ) . . . . . . . . . . . . . . . . . . . . . . . 62
Neighbor (This class contains NEIGHBOR NODE information ) . . . . . . . . . . . . . . . . . 64
NeighborList (It implements the Neighbor Table ) . . . . . . . . . . . . . . . . . . . . . . . . . 66
PacketUtil (This class implements packet utilities needed by various classes ) . . . . . . . . . . 69
PeripheralNode (It is a struct to hold single entry in the Peripheral Node Table ) . . . . . . . . . 75
PeripheralNodeList (This class implements Peripheral Node Table ) . . . . . . . . . . . . . . . 77
SendBuffer (This class implements the buffer to store the incoming packets from the upper layer ) 79
SendBufferEntry (This class implements the struct to hold one send buffer entry ) . . . . . . . . 81
SentQuery (It is a struct to hold single entry in the Sent Query Table ) . . . . . . . . . . . . . . 83
SentQueryList (It keeps all the sent route-requests ) . . . . . . . . . . . . . . . . . . . . . . . . 85
ZRPAgent (This class implements the Zone Routing Protocol (ZRP) ) . . . . . . . . . . . . . . 87
12. 8 Class Index
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen
13. Chapter 4
Module Documentation
4.1 Constants
This module defines various parameters by which ZRP can be tuned.
Defines
• #define DEBUG 0
This constant is to enable or disable the printing of various events and tables on the console.
• #define ROUTER_PORT 0xff
It is a default routing port for ZRP packets.
• #define TRUE 1
It is a logical TRUE. (Integer value 1).
• #define FALSE 0
It is a logical FALSE. (Integer value 0).
• #define LINKUP 1
It suggests link status UP. (Integer value 1).
• #define LINKDOWN 0
It suggests link status DOWN. (Integer value 0).
• #define DEFAULT_STARTUP_JITTER 1
This constant is for the startup jitter for starting various timers.
• #define DEFAULT_EXPIRATION_CHECK_PERIOD 1
This constant is for the time elapsed between two consecutive expiration check events.
• #define MAX_SEQUENCE_ID 1000000
This constant is for the range of sequence ids.
• #define IERP_TTL 50
14. 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 be
missed.
• #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
15. 4.1 Constants 11
This constant is the maximum allowed route replies from the destination.
• #define DEFAULT_ZONE_RADIUS 2
This constant is for the default value of zone radius.
• #define DEFAULT_SEND_BUFFER_SIZE 100
This constant is for the size of the send buffer.
• #define DEFAULT_PACKET_LIFETIME 20
This constant is for the value of the residence time of packet in send buffer.
• #define DEFAULT_INTERPKT_JITTER 1
The default value of the inter packet jitter is uniformly distributed value in [0,1).
Typedefs
• typedef double Time
In NS2, the time is kept in a double variable.
• typedef int32_t Query_ID
Query_ID is an integer variable.
Enumerations
• enum ZRPTYPE {
NDP_BEACON, NDP_BEACON_ACK, IARP_UPDATE, IARP_DATA,
IERP_REPLY, IERP_REQUEST, IERP_ROUTE_ERROR, IERP_DATA }
This enumeration 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
16. 12 Module Documentation
4.2 NDP Agent
This module implements the NDP Agent.
Classes
• class Neighbor
This class contains NEIGHBOR NODE information.
• class NeighborList
It implements the Neighbor Table.
• class NDPBeaconTransmitTimer
This class implements a BEACON Transmit Timer, who periodically sends beacons to NEIGHBOR nodes.
• class NDPAckTimer
This class implements a Acknoledgement TimeOut Timer, who checks that ACK is received or not for sent
beacon.
• class NDPAgent
This class implements the Neighbor Discovery Protocol (NDP).
4.2.1 Detailed Description
#) This module implements the NDP Agent. This module consists of following things:
1. Neighbor Table: It keeps a list of Neighbors with their link-status.
2. Beacon Transmit Timer: This timer broadcasts beacon messages periodically.
3. ACK Timeout Timer: This timer checks which neighbor(s) has not send the ACK in response to
beacon.
4. NDP Agent: It implements the NDP Agent functionalities.
#) Tables:
1. NEIGHBOR_TABLE: (Attributes are listed below)
(a) 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 Neighbor
DOWN]
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen
17. 4.3 IARP Agent 13
4.3 IARP Agent
This module implements the IARP Agent.
Classes
• class LinkState
It is a struct to hold single entry in the Link State Table.
• class LinkStateList
This class implements Topology (Link State) Table.
• class PeripheralNode
It is a struct to hold single entry in the Peripheral Node Table.
• class PeripheralNodeList
This class implements Peripheral Node Table.
• class InnerRoute
It is a struct to hold single entry in the Route Table.
• class InnerRouteList
This class implements the Routing Table.
• class IARPUpdate
It is a struct to hold single entry in the Detected Update Table.
• class IARPUpdateDetectedList
This class implements Detected Update Table.
• class IARPPeriodicUpdateTimer
This class implements a timer who sends the IARP updates periodically.
• class IARPExpirationTimer
It implements a timer who checks periodically for the expiry of various entries in IARP tables.
• class IARPAgent
This class implements the IntrAzone Routing Protocol (IARP).
4.3.1 Detailed Description
#) This module implements the IARP Agent. This module consists of following things:
1. Link State Table: It keeps the view of network topology.
2. Peripheral Node Table: It keeps the list of peripheral nodes of the zone.
3. Routing Table: It implements the common routing table for both IARP and IERP. (Metric: Shortest
path)
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen
18. 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
19. 4.4 IERP Agent 15
4.4 IERP Agent
This module implements the IERP Agent.
Classes
• class DetectedQuery
It is a struct to hold single entry in the Detected Query Table.
• class DetectedQueryList
It keeps all the received route-requests for control flooding.
• class SentQuery
It is a struct to hold single entry in the Sent Query Table.
• class SentQueryList
It keeps all the sent route-requests.
• class IERPExpirationTimer
It implements a timer who checks periodically for the expiry of various entries in IERP tables.
• class IERPAgent
This class implements the IntEr Routing Protocol (IERP).
4.4.1 Detailed Description
This module implements the IERP Agent. This module consists of following things:
1. Detected Request Table: It keeps all the received route-request for control 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
20. 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
21. 4.5 ZRP Agent 17
4.5 ZRP Agent
This module implements the ZRP Agent interface to the upper and lower layers.
Classes
• struct hdr_zrp
It defines the ZRP Packet Header.
• class LSU
It defines the Link-State-Update structure embedded in packet.
• class PacketUtil
This class implements packet utilities needed by various classes.
• class SendBufferEntry
This class implements the struct to hold one send buffer entry.
• class SendBuffer
This class implements the buffer to store the incoming packets from the upper layer.
• class ZRPAgent
This class implements the Zone Routing Protocol (ZRP).
4.5.1 Detailed Description
This module implements the ZRP Agent interface to the upper and lower layers. This module consists of
following things:
1. Zrp Header Structure - It 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
22. 18 Module Documentation
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen
23. 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_
24. 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
25. 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
26. 22 Class Documentation
5.2.3 Member Function Documentation
5.2.3.1 void DetectedQueryList::addQuery (nsaddr_t src, nsaddr_t dest, int queryID, Time
expiry, PeripheralNodeList ∗ curPNLst)
It adds the query to the detected query table.
Parameters:
src Source of the detected query.
dest Destination of the detected query.
queryID Query ID of the route-request.
expiry Expiry of this detected Entry.
curPNLst Pointer to current peripheral node list.
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
27. 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
28. 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
29. 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
30. 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
31. 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 set
FALSE].
• LinkStateList lsLst_
Topology Table.
• PeripheralNodeList pnLst_
Peripheral-Node Table.
• InnerRouteList irLst_
Proactive-Routing Table.
• IARPUpdateDetectedList upLst_
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen
32. 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
33. 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 following
steps are performed.
1. Clear the existing Inner-Route-List & Peirpheral-Node-List.
2. Purge the expired links & DOWN links.
3. Generate a BFS tree from existing Link-State list.
4. Generate Inner-Routing-List based on that BFS tree. Insert all leaf nodes in Peripheral-Node-List.
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
34. 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
35. 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
36. 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
37. 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
38. 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 list
with 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
39. 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
40. 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
41. 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
42. 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 TRUE
and 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
43. 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
44. 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 following
things:
• 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
45. 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 to
route-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 to
route-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 route
table.
• Otherwise, it snoops the packet for stored route and updates its own route table and then it forwards
the route-reply.
Generated on Tue Apr 21 16:25:45 2009 for ZRP Agent for NS2 (NS-2 v2.33) by Doxygen
46. 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 from
the route-table.
• Otherwise, it snoops the packet for broken link info and updates its own routing table and then it
forwards the route-error.
Parameters:
p Pointer to the packet.
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. The
link-state information is extracted from the source route and added to the linkstate table.
Parameters:
route Pointer to the source route.
size Size of the source route.
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
47. 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
48. 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
49. 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
50. 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
51. 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
52. 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
53. 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
54. 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
55. 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
56. 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
57. 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 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 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 state
dest Destination of link state
handle 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
58. 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
59. 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
60. 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
61. 5.16 NDPAckTimer Class Reference 57
5.16 NDPAckTimer Class Reference
This class implements a Acknoledgement TimeOut Timer, who checks that ACK is received or not for sent
beacon.
#include <zrp.h>
Public Member Functions
• NDPAckTimer (ZRPAgent ∗agent)
It initializes the attributes with the default values.
• void handle (Event ∗)
It implements the code for checking ACK timeout.
• void start ()
This function is called to start this Timer.
Public Attributes
• ZRPAgent ∗ agent_
Pointer to ZRP-Agent.
• Event intr_
Event Object.
• int neighbor_ack_timeout_
Time before a neighbor must send ACK.
5.16.1 Detailed Description
This class implements a Acknoledgement TimeOut Timer, who checks that ACK is received or not for sent
beacon.
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
62. 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
63. 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
64. 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 stores
only 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 to
rebuild 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
65. 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
66. 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
67. 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 after
time-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
68. 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
69. 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
70. 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
71. 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. The
previous pointer must also be passed since it is a singly linked list.
Parameters:
prev Pointer to previous element in the list.
toBeDeleted Pointer to the element who should be removed.
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
72. 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
73. 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
74. 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
75. 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
76. 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