forest-net
an overlay networks for large-scale virtual worlds
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
forest::RouteTable Class Reference

Maintains a set of routes. More...

#include <RouteTable.h>

Collaboration diagram for forest::RouteTable:

Public Member Functions

 RouteTable (int, fAdr_t, ComtreeTable *)
 Constructor for RouteTable, allocates space and initializes table. More...
 
 ~RouteTable ()
 Destructor for RouteTable, frees dynamic storage. More...
 
bool validRtx (int) const
 Verify that a route index is valid. More...
 
bool isLink (int, int) const
 Determine if a comtree link is in a multicast route. More...
 
bool noLinks (int) const
 Determine if a multicast route has no links. More...
 
int firstRtx () const
 Get the first route index. More...
 
int nextRtx (int) const
 Get the next route index following a given route index. More...
 
int firstComtLink (int) const
 Get the first comtree link for a given route. More...
 
int nextComtLink (int, int) const
 Get the next comtree link following a given comtree link. More...
 
int getRtx (comt_t, fAdr_t) const
 Get the route index for a given comtree and destination address. More...
 
comt_t getComtree (int) const
 Get the comtree number for a given route. More...
 
fAdr_t getAddress (int) const
 Get the destination address for a given route. More...
 
int getLinkCount (int) const
 Get the number of links used by a route. More...
 
bool addLink (int, int)
 Add a subscriber link to a multicast route. More...
 
void removeLink (int, int)
 Remove a subscriber link from a multicast route. More...
 
int addRoute (comt_t, fAdr_t, int)
 Add a new route to the table. More...
 
void removeRoute (int)
 Remove a route from the table. More...
 
void purge (comt_t, int)
 Remove a comtree link from all routes that use it. More...
 
void setLink (int, int)
 Set the link for a unicast route. More...
 
bool read (istream &)
 Read routing table entries from input stream. More...
 
string toString () const
 Create a string representing the table. More...
 
string entry2string (int) const
 Create a string representing a table entry. More...
 

Private Types

typedef HashSet< int32_t,
Hash::s32 > 
Vset
 

Private Member Functions

uint64_t rmKey (comt_t, fAdr_t) const
 key for rteMap More...
 
uint64_t cmKey (comt_t, int32_t) const
 key for clMap More...
 
bool readRoute (istream &)
 Read an entry from an input stream and add a routing table entry for it. More...
 

Private Attributes

int maxRtx
 max number of table entries
 
int myAdr
 address of this router
 
ComtreeTablectt
 pointer to comtree table
 
HashMap< uint64_t, Vset,
Hash::u64 > * 
rteMap
 map (comtree,adr) pair to list of cLnks
 
HashMap< uint64_t, Vset,
Hash::u64 > * 
clMap
 

Detailed Description

Maintains a set of routes.

A unicast route is a triple (comtree, address, comtreeLink) where comtree is the comtree number associated with the route, address is a unicast address and comtreeLink is the comtree link number for some link in the comtree (comtree link numbers are maintained by the ComtreeTable).

A multicast route is similar, except in this case the address is a multicast address and comtreeLink is replaced by a list of comtree link numbers that represents the subscribers to the multicast address.

The data for a route is accessed using its "route index", which can be obtained using the getRtx() method.

Definition at line 35 of file RouteTable.h.

Constructor & Destructor Documentation

forest::RouteTable::RouteTable ( int  maxRtx1,
fAdr_t  myAdr1,
ComtreeTable ctt1 
)

Constructor for RouteTable, allocates space and initializes table.

Parameters
maxRtx1is the maximum number of entries in the table
myAdr1is the forest of the address of the router
maxRtx1is the maximum number of entries in the table
myAdr1is the forest of the address of the router
ctt1is a pointer to the comtree table

Definition at line 18 of file RouteTable.cpp.

forest::RouteTable::~RouteTable ( )

Destructor for RouteTable, frees dynamic storage.

Definition at line 25 of file RouteTable.cpp.

Member Function Documentation

bool forest::RouteTable::addLink ( int  rtx,
int  cLnk 
)
inline

Add a subscriber link to a multicast route.

Parameters
rtxis the route number
cLnkis the comtree link number for the new subscriber
Returns
true on success, false on failure

Definition at line 197 of file RouteTable.h.

Here is the call graph for this function:

Here is the caller graph for this function:

int forest::RouteTable::addRoute ( comt_t  comt,
fAdr_t  adr,
int  cLnk 
)

Add a new route to the table.

Parameters
comtis the comtree number for the route
adris the destination address for the route
cLnkis a comtree link number for a link in the comtree; for multicast routes, this designates an initial subscriber link; if cLnk=0, there is no initial subscriber link
Returns
the index of the new route, or 0 if the operation fails

Definition at line 35 of file RouteTable.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

uint64_t forest::RouteTable::cmKey ( comt_t  comt,
int32_t  cLnk 
) const
inlineprivate

key for clMap

Compute a key for use in the comtree link map.

Parameters
comtis a comtree number
cLnkis a comtree link number
Returns
a 64 bit integer suitable for use as a lookup key

Definition at line 275 of file RouteTable.h.

Here is the caller graph for this function:

string & forest::RouteTable::entry2string ( int  rtx) const

Create a string representing a table entry.

Parameters
rtxis the route index for the route to be written
sis a reference to a string in which result is returned
Returns
a reference to s

Definition at line 151 of file RouteTable.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int forest::RouteTable::firstComtLink ( int  rtx) const
inline

Get the first comtree link for a given route.

This method is used to iterate through all the links in the route. The order of comtree links is arbitrary.

Returns
the first route index, or 0 if there are none

Definition at line 140 of file RouteTable.h.

int forest::RouteTable::firstRtx ( ) const
inline

Get the first route index.

This method is used to iterate through all the routes in the table. The order of routes is arbitrary.

Returns
the first route index, or 0 if there are none

Definition at line 121 of file RouteTable.h.

Here is the caller graph for this function:

fAdr_t forest::RouteTable::getAddress ( int  rtx) const
inline

Get the destination address for a given route.

Parameters
rtxis a route index
Returns
the address that the route was defined for

Definition at line 178 of file RouteTable.h.

Here is the caller graph for this function:

comt_t forest::RouteTable::getComtree ( int  rtx) const
inline

Get the comtree number for a given route.

Parameters
rtxis a route index
Returns
the comtree that the route was defined for

Definition at line 169 of file RouteTable.h.

Here is the caller graph for this function:

int forest::RouteTable::getLinkCount ( int  rtx) const
inline

Get the number of links used by a route.

Parameters
rtxis a route index
Returns
the number of outgoing links used by this route; for unicast routes, this should always be 1.

Definition at line 188 of file RouteTable.h.

int forest::RouteTable::getRtx ( comt_t  comt,
fAdr_t  adr 
) const
inline

Get the route index for a given comtree and destination address.

Parameters
comtis a comtree number
adris a forest address
Returns
the associated comtree index or 0 if there is none

Definition at line 161 of file RouteTable.h.

Here is the call graph for this function:

bool forest::RouteTable::isLink ( int  rtx,
int  cLnk 
) const
inline

Determine if a comtree link is in a multicast route.

Parameters
rtxis a route index
cLnkis a comtree link number
Returns
true if the route with index rtx if lnk is one of the links in the multicast route Assumes rtx is a valid index that refers to a multicast route

Definition at line 103 of file RouteTable.h.

Here is the caller graph for this function:

int forest::RouteTable::nextComtLink ( int  rtx,
int  cLnk 
) const
inline

Get the next comtree link following a given comtree link.

This method is used to iterate through all the links in a route. The order of comtree links is arbitrary.

Parameters
rtxis a route index
cLnkis a comtree link number
Returns
the next comtree link number for the given route following cLnk, or 0 if there is no next comtree link

Definition at line 152 of file RouteTable.h.

int forest::RouteTable::nextRtx ( int  rtx) const
inline

Get the next route index following a given route index.

This method is used to iterate through all the routes in the table. The order of routes is arbitrary.

Parameters
rtxis a route index
Returns
the next route index following rtx, or 0 if there is none

Definition at line 131 of file RouteTable.h.

Here is the caller graph for this function:

bool forest::RouteTable::noLinks ( int  rtx) const
inline

Determine if a multicast route has no links.

Returns
true if the route has no links, else false

Definition at line 111 of file RouteTable.h.

Here is the caller graph for this function:

void forest::RouteTable::purge ( comt_t  comt,
int  cLnk 
)

Remove a comtree link from all routes that use it.

This method also removes routes for which the given cLnk is the only one used by the route.

Parameters
comtis a comtree number
cLnkis a comtree link number for comt

Definition at line 75 of file RouteTable.cpp.

Here is the call graph for this function:

bool forest::RouteTable::read ( istream &  in)

Read routing table entries from input stream.

The first input line must contain an integer, giving the number of entries to be read.

Parameters
inis an open input stream

Definition at line 132 of file RouteTable.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool forest::RouteTable::readRoute ( istream &  in)
private

Read an entry from an input stream and add a routing table entry for it.

An entry consists of a comtree number, a forest address and either a single link number, or a comma-separated list of links. The forest address may be a unicast address in dotted decimal notation, or a multicast address, which is a single negative integer. An entry must appear on one line. Lines may contain comments, which start with a # sign and continue to the end of the line.

Parameters
inis an open input stream
Returns
true on success, false on failure

Definition at line 98 of file RouteTable.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void forest::RouteTable::removeLink ( int  rtx,
int  cLnk 
)
inline

Remove a subscriber link from a multicast route.

Parameters
rtxis the route number
cLnkis the comtree link number for the link to be removed
Returns
true on success, false on failure

Definition at line 217 of file RouteTable.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void forest::RouteTable::removeRoute ( int  rtx)

Remove a route from the table.

Parameters
rtxis the route index of the route to be removed.

Definition at line 56 of file RouteTable.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

uint64_t forest::RouteTable::rmKey ( comt_t  comt,
fAdr_t  adr 
) const
inlineprivate

key for rteMap

Compute a key for use in the route map.

Parameters
comtis a comtree number
adris a forest address
Returns
a 64 bit integer suitable for use as a lookup key

Definition at line 263 of file RouteTable.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void forest::RouteTable::setLink ( int  rtx,
int  cLnk 
)
inline

Set the link for a unicast route.

Parameters
rtxis the route number
cLnkis the comtree link number for the new outgoing link

Definition at line 235 of file RouteTable.h.

Here is the call graph for this function:

Here is the caller graph for this function:

string & forest::RouteTable::toString ( ) const

Create a string representing the table.

Parameters
sis a reference to a string in which result is returned
Returns
a reference to s

Definition at line 170 of file RouteTable.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool forest::RouteTable::validRtx ( int  rtx) const
inline

Verify that a route index is valid.

Parameters
rtxis an index into the routing table
Returns
true if rtx corresponds to a valid route, else false

Definition at line 92 of file RouteTable.h.

Here is the caller graph for this function:


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