forest-net
an overlay networks for large-scale virtual worlds
|
Maintains a set of routes. More...
#include <RouteTable.h>
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 | |
ComtreeTable * | ctt |
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 |
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.
forest::RouteTable::RouteTable | ( | int | maxRtx1, |
fAdr_t | myAdr1, | ||
ComtreeTable * | ctt1 | ||
) |
Constructor for RouteTable, allocates space and initializes table.
maxRtx1 | is the maximum number of entries in the table |
myAdr1 | is the forest of the address of the router |
maxRtx1 | is the maximum number of entries in the table |
myAdr1 | is the forest of the address of the router |
ctt1 | is 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.
|
inline |
Add a subscriber link to a multicast route.
rtx | is the route number |
cLnk | is the comtree link number for the new subscriber |
Definition at line 197 of file RouteTable.h.
Add a new route to the table.
comt | is the comtree number for the route |
adr | is the destination address for the route |
cLnk | is 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 |
Definition at line 35 of file RouteTable.cpp.
|
inlineprivate |
key for clMap
Compute a key for use in the comtree link map.
comt | is a comtree number |
cLnk | is a comtree link number |
Definition at line 275 of file RouteTable.h.
string & forest::RouteTable::entry2string | ( | int | rtx) | const |
Create a string representing a table entry.
rtx | is the route index for the route to be written |
s | is a reference to a string in which result is returned |
Definition at line 151 of file RouteTable.cpp.
|
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.
Definition at line 140 of file RouteTable.h.
|
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.
Definition at line 121 of file RouteTable.h.
|
inline |
Get the destination address for a given route.
rtx | is a route index |
Definition at line 178 of file RouteTable.h.
|
inline |
Get the comtree number for a given route.
rtx | is a route index |
Definition at line 169 of file RouteTable.h.
|
inline |
Get the number of links used by a route.
rtx | is a route index |
Definition at line 188 of file RouteTable.h.
Get the route index for a given comtree and destination address.
comt | is a comtree number |
adr | is a forest address |
Definition at line 161 of file RouteTable.h.
|
inline |
Determine if a comtree link is in a multicast route.
rtx | is a route index |
cLnk | is a comtree link number |
Definition at line 103 of file RouteTable.h.
|
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.
rtx | is a route index |
cLnk | is a comtree link number |
Definition at line 152 of file RouteTable.h.
|
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.
rtx | is a route index |
Definition at line 131 of file RouteTable.h.
|
inline |
Determine if a multicast route has no links.
Definition at line 111 of file RouteTable.h.
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.
comt | is a comtree number |
cLnk | is a comtree link number for comt |
Definition at line 75 of file RouteTable.cpp.
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.
in | is an open input stream |
Definition at line 132 of file RouteTable.cpp.
|
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.
in | is an open input stream |
Definition at line 98 of file RouteTable.cpp.
|
inline |
Remove a subscriber link from a multicast route.
rtx | is the route number |
cLnk | is the comtree link number for the link to be removed |
Definition at line 217 of file RouteTable.h.
void forest::RouteTable::removeRoute | ( | int | rtx) |
Remove a route from the table.
rtx | is the route index of the route to be removed. |
Definition at line 56 of file RouteTable.cpp.
key for rteMap
Compute a key for use in the route map.
comt | is a comtree number |
adr | is a forest address |
Definition at line 263 of file RouteTable.h.
|
inline |
Set the link for a unicast route.
rtx | is the route number |
cLnk | is the comtree link number for the new outgoing link |
Definition at line 235 of file RouteTable.h.
string & forest::RouteTable::toString | ( | ) | const |
Create a string representing the table.
s | is a reference to a string in which result is returned |
Definition at line 170 of file RouteTable.cpp.
|
inline |
Verify that a route index is valid.
rtx | is an index into the routing table |
Definition at line 92 of file RouteTable.h.