Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

RequestTable Class Reference

#include <requesttable.h>

Collaboration diagram for RequestTable:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 RequestTable (int size=30)
 ~RequestTable ()
void insert (const ID &net_id, int req_num)
void insert (const ID &net_id, const ID &MAC_id, int req_num)
int get (const ID &id) const
EntrygetEntry (const ID &id)

Private Member Functions

int find (const ID &net_id, const ID &MAC_id) const

Private Attributes

Entrytable
int size
int ptr

Constructor & Destructor Documentation

RequestTable::RequestTable int  size = 30  ) 
 

Definition at line 38 of file requesttable.cc.

References ptr, size, and table.

00038                                : size(s)
00039 {
00040   table = new Entry[size];
00041   size = size;
00042   ptr = 0;
00043 }

RequestTable::~RequestTable  ) 
 

Definition at line 45 of file requesttable.cc.

References table.

00046 {
00047   delete[] table;
00048 }


Member Function Documentation

int RequestTable::find const ID net_id,
const ID MAC_id
const [private]
 

Definition at line 51 of file requesttable.cc.

References Entry::MAC_id, Entry::net_id, size, and table.

Referenced by get(), getEntry(), and insert().

00052 {
00053   for (int c = 0 ; c < size ; c++)
00054           if (table[c].net_id == net_id || table[c].MAC_id == MAC_id)
00055                   return c;
00056   return size;
00057 }

int RequestTable::get const ID id  )  const
 

Definition at line 60 of file requesttable.cc.

References find(), Entry::req_num, size, and table.

Referenced by DSRAgent::ignoreRouteRequestp().

00061 {
00062   int existing_entry = find(id, id);
00063 
00064   if (existing_entry >= size)    
00065     {
00066       return 0;
00067     }
00068   return table[existing_entry].req_num;
00069 }

Here is the call graph for this function:

Entry * RequestTable::getEntry const ID id  ) 
 

Definition at line 73 of file requesttable.cc.

References find(), ptr, rt_rq_period, size, and table.

Referenced by DSRAgent::acceptRouteReply(), and DSRAgent::getRouteForPacket().

00074 {
00075   int existing_entry = find(id, id);
00076 
00077   if (existing_entry >= size)    
00078     {
00079       table[ptr].MAC_id = ::invalid_addr;
00080       table[ptr].net_id = id;
00081       table[ptr].req_num = 0;
00082       table[ptr].last_arp = 0.0;
00083       table[ptr].rt_reqs_outstanding = 0;
00084       table[ptr].last_rt_req = -(rt_rq_period + 1.0);
00085       existing_entry = ptr;
00086       ptr = (ptr+1)%size;
00087     }
00088   return &(table[existing_entry]);
00089 }

Here is the call graph for this function:

void RequestTable::insert const ID net_id,
const ID MAC_id,
int  req_num
 

Definition at line 99 of file requesttable.cc.

References find(), Entry::MAC_id, ptr, Entry::req_num, rt_rq_period, size, and table.

00100 {
00101   int existing_entry = find(net_id, MAC_id);
00102 
00103   if (existing_entry < size)
00104     {
00105       if (table[existing_entry].MAC_id == ::invalid_addr)
00106         table[existing_entry].MAC_id = MAC_id; // handle creations by getEntry
00107       table[existing_entry].req_num = req_num;
00108       return;
00109     }
00110 
00111   // otherwise add it in
00112   table[ptr].MAC_id = MAC_id;
00113   table[ptr].net_id = net_id;
00114   table[ptr].req_num = req_num;
00115   table[ptr].last_arp = 0.0;
00116   table[ptr].rt_reqs_outstanding = 0;
00117   table[ptr].last_rt_req = -(rt_rq_period + 1.0);
00118   ptr = (ptr+1)%size;
00119 }

Here is the call graph for this function:

void RequestTable::insert const ID net_id,
int  req_num
 

Definition at line 92 of file requesttable.cc.

References invalid_addr.

Referenced by DSRAgent::handlePacketReceipt(), and DSRAgent::handleRouteRequest().

00093 {
00094   insert(net_id,::invalid_addr,req_num);
00095 }


Member Data Documentation

int RequestTable::ptr [private]
 

Definition at line 58 of file requesttable.h.

Referenced by getEntry(), insert(), and RequestTable().

int RequestTable::size [private]
 

Definition at line 57 of file requesttable.h.

Referenced by find(), get(), getEntry(), insert(), and RequestTable().

Entry* RequestTable::table [private]
 

Definition at line 56 of file requesttable.h.

Referenced by find(), get(), getEntry(), insert(), RequestTable(), and ~RequestTable().


The documentation for this class was generated from the following files:
Generated on Tue Apr 20 13:15:11 2004 for NS2.26SourcesOriginal by doxygen 1.3.3