forest-net
an overlay networks for large-scale virtual worlds
|
Class that implements a table of information on comtrees. More...
#include <ComtreeTable.h>
Classes | |
struct | ClnkInfo |
comtree link information comtree table entry More... | |
struct | ComtLinkInfo |
struct | Entry |
struct | TblEntry |
Public Member Functions | |
ComtreeTable (int, int) | |
Constructor for ComtreeTable, allocates space and initializes table. More... | |
~ComtreeTable () | |
Destructor for ComtreeTable, frees dynamic storage. | |
bool | validComtree (comt_t) const |
Determine if the table has an entry for a given comtree. More... | |
bool | validCtx (int) const |
Determine if a comtree index is being used in this table. More... | |
bool | validClnk (int, int) const |
Determine if a comtree link number is being used by a given comtree. More... | |
bool | checkEntry (int) const |
Perform consistency check on table entry. More... | |
bool | inCore (int) const |
Determine if "this node" is in the core of the comtree. More... | |
bool | isLink (int, int) const |
Determine if a given link is part of a given comtree. More... | |
bool | isRtrLink (int, int) const |
Determine if a given comtree link connects to another router. More... | |
bool | isCoreLink (int, int) const |
Determine if a given comtree link connects to a core node. More... | |
int | firstComt () const |
Get the first comtree index. More... | |
int | nextComt (int) const |
Get the next comtree index. More... | |
int | firstComtLink (int) const |
Get a list of comtrees that use a specified link. More... | |
int | nextComtLink (int, int) const |
Get the next comtree link number for a given comtree. More... | |
int | firstRtrLink (int) const |
Get the first comtree link number going to a router. More... | |
int | nextRtrLink (int, int) const |
Get the next comtree link number going to a router. More... | |
int | firstCoreLink (int) const |
Get the first comtree link number going to a core router. More... | |
int | nextCoreLink (int, int) const |
Get the next comtree link number going to a router. More... | |
int | getComtIndex (comt_t) const |
Get the comtree index, based on the comtree number. More... | |
Entry & | getEntry (int) const |
Get the comtree table entry for a given comtree, using its index. More... | |
comt_t | getComtree (int) const |
Get the comtree number for a given table entry. More... | |
int | getLink (int, int) const |
Get the link number for a given comtree link. More... | |
int | getPlink (int) const |
Get the parent link for a comtree. More... | |
int | getPClink (int) const |
Get the comtree link number for the parent link in a comtree. More... | |
int | getLinkCount (int) const |
Get the number of links that belong to this comtree. More... | |
int | getClnkNum (int, int) const |
Get the comtree link number for a given (comtree, link) pair. More... | |
ClnkInfo & | getClnkInfo (int, int) const |
Get the comtree link info for a specfic comtree link. More... | |
int | getLinkQ (int, int) const |
Get the queue identifier for a given comtree link. More... | |
fAdr_t | getDest (int, int) const |
Get the allowed destination for packets received on a given comtree link. More... | |
RateSpec & | getRates (int, int) const |
Get the rate spec for a given comtree link. More... | |
const Dlist & | getComtList (int) const |
int | addEntry (comt_t) |
Add a new entry to the table. More... | |
bool | removeEntry (int) |
Remove a table entry. More... | |
bool | addLink (int, int, bool, bool) |
Add a link to the set of links for a comtree. More... | |
bool | removeLink (int, int) |
Remove a comtree link from the set of valid links for a comtree. More... | |
void | setCoreFlag (int, bool) |
Set the core flag for a given table entry. More... | |
void | setPlink (int, int) |
Set the parent link for a given table entry. More... | |
void | setLinkQ (int, int, int) |
Set the queue number for a comtree link. More... | |
void | purgeLink (int) |
Remove a link from all comtrees that currently use it. More... | |
bool | read (istream &) |
Read comtree table entries from an input stream. More... | |
string | toString () const |
Create a string representation of the table. More... | |
string | entry2string (int) const |
Create a string representing a table entry. More... | |
ComtreeTable (int, int, LinkTable *) | |
Constructor for ComtreeTable, allocates space and initializes table. More... | |
bool | validComtree (comt_t) const |
bool | validComtIndex (int) const |
Determine if a comtree index is being used in this table. More... | |
bool | validComtLink (int) const |
Determine if a comtree link number is in use in this table. More... | |
bool | checkEntry (int) const |
bool | inCore (int) const |
bool | isLink (int, int) const |
bool | isRtrLink (int, int) const |
bool | isRtrLink (int) const |
Determine if a given comtree link connects to another router. More... | |
bool | isCoreLink (int, int) const |
bool | isCoreLink (int) const |
Determine if a given comtree link connects to a core node. More... | |
bool | isLocked (int) const |
Determine if a given comtree is locked. More... | |
int | firstComtIndex () const |
Get the first comtree index. More... | |
int | nextComtIndex (int) const |
Get the next comtree index. More... | |
int | getComtIndex (comt_t) const |
comt_t | getComtree (int) const |
int | getLink (int) const |
Get the link number for a given comtree link. More... | |
int | getPlink (int) const |
int | getLinkCount (int) const |
int | getComtLink (int, int) const |
Get the comtree link number for a given (comtree, link) pair. More... | |
int | getPCLink (int) const |
Get the comtree link number for the parent link in a comtree. More... | |
int | getLinkQ (int) const |
Get the queue identifier for a given comtree link. More... | |
fAdr_t | getDest (int) const |
Get the allowed destination for packets received on a given comtree link. More... | |
pktx | getPrunePkt (int) const |
RateSpec & | getUpperBoundRates (int) const |
Get the rate spec for a given comtree link. More... | |
RateSpec & | getRates (int) const |
Get the rate spec for a given comtree link. More... | |
set< int > & | getLinks (int) const |
Get a reference to the set of comtree links for a comtree. More... | |
set< int > & | getRtrLinks (int) const |
Get a reference to the set of comtree links leading to another router. More... | |
set< int > & | getCoreLinks (int) const |
Get a reference to the set of comtree links leading to a core router. More... | |
set< int > & | getRteSet (int) const |
Get a reference to the set of routes registered with a comtree link. More... | |
vector< pktx > & | getPktNums (int) const |
Get a reference to the set of comtree links leading to a core router. More... | |
int | addEntry (comt_t) |
bool | removeEntry (int) |
bool | addLink (int, int, bool, bool) |
bool | removeLink (int, int) |
void | setCoreFlag (int, bool) |
void | setPlink (int, int) |
void | setLock (int, int) |
Set the lock bit for a comtree. More... | |
void | setPrunePkt (int, pktx) |
Set the prune request packet number for a comtree. More... | |
void | addRequest (int, pktx) |
Register a route with a given comtree link. More... | |
void | removeRequest (int, pktx) |
Deegister a route with a given comtree link. More... | |
void | setUpperBoundRates (int, RateSpec &) |
void | setLinkQ (int, int) |
Set the queue number for a comtree link. More... | |
void | registerRte (int, int) |
Set the incoming bit rate for a comtree link. More... | |
void | deregisterRte (int, int) |
Deegister a route with a given comtree link. More... | |
void | cleanPktNums (int) |
bool | read (istream &) |
string & | toString (string &) const |
Create a string representation of the table. More... | |
string & | entry2string (int, string &) const |
Write a table entry to an output stream. More... | |
Private Member Functions | |
bool | readEntry (istream &) |
helper functions More... | |
void | readLinks (istream &, set< int > &) |
Read a list of links from an input stream. More... | |
string | links2string (int) const |
uint64_t | key (comt_t) const |
helper functions More... | |
uint64_t | key (comt_t, int) const |
Compute key for use with clMap. More... | |
bool | readEntry (istream &) |
void | readLinks (istream &, set< int > &) |
string & | links2string (int, string &) const |
Private Attributes | |
int | maxLnk |
maximum link number | |
int | maxCtx |
maximum comtree index More... | |
HashMap< comt_t, Entry, Hash::u32 > * | comtMap |
maps comtree number to table entry | |
Dlist * | comtList |
comtList[lnk] lists all comtrees More... | |
int | maxComtLink |
largest comtLink | |
TblEntry * | tbl |
IdMap * | comtMap |
maps comtree numbers to indices | |
ComtLinkInfo * | clTbl |
cLnkTbl[cl] has info on comtLink cl | |
IdMap * | clMap |
maps (comtree,link)->comtLink | |
LinkTable * | lt |
Class that implements a table of information on comtrees.
Table entries are accessed using a "comtree index", which can be obtained using the getCtx() method.
Information about the use of a link in a comtree can be accessed using a comtree link number. For example, using the comtree link number, you can get the queue identifier that is used for packets in a given comtree that are sent on on the link. Comtree link numbers can be obtained using the getClnkInfo() method.
Table entries are accessed using a "comtree index", which can be obtained using the getComtIndex() method.
Information about the use of a link in a comtree can be accessed using a comtree link number. For example, using the comtree link number, you can get the queue identifier that is used for packets in a given comtree that are sent on on the link. Comtree link numbers can be obtained using the getComtLink() method.
Definition at line 36 of file ComtreeTable.h.
forest::ComtreeTable::ComtreeTable | ( | int | maxLnk1, |
int | maxCtx1 | ||
) |
Constructor for ComtreeTable, allocates space and initializes table.
maxCtx | is the maximum number of entries |
lt1 | is a pointer to the router's link table |
Definition at line 17 of file ComtreeTable.cpp.
forest::ComtreeTable::ComtreeTable | ( | int | maxCtx1, |
int | maxComtLink1, | ||
LinkTable * | lt1 | ||
) |
Constructor for ComtreeTable, allocates space and initializes table.
Definition at line 15 of file ComtreeTable.cpp.
int forest::ComtreeTable::addEntry | ( | comt_t | comt) |
Add a new entry to the table.
Attempts to add a new table entry. Can fail if the specified comtree number is already in use, or if the table has run out of space.
comt | is the number of the comtree for which an entry is to be added |
Definition at line 80 of file ComtreeTable.cpp.
bool forest::ComtreeTable::addLink | ( | int | ctx, |
int | lnk, | ||
bool | rflg, | ||
bool | cflg | ||
) |
Add a link to the set of links for a comtree.
Add the link to the set of links for a comtree.
ctx | is comtree index of the comtree to be modified |
link | is the number of the link to add |
rflg | is true if far end of link is another router |
cflg | is true if far end of link is a core router for this comtree |
ctx | is comtree index of the comtree to be modified |
link | is the number of the link to add |
rflg | is true if far end of link is another router |
cflg | is true if far end of link is a core router for this comtree |
Definition at line 37 of file ComtreeTable.cpp.
|
inline |
Register a route with a given comtree link.
cLnk | is a valid comtree link number |
rtx | is an integer that is presumed to be a route index |
Definition at line 514 of file ComtreeTableFeng.h.
bool forest::ComtreeTable::checkEntry | ( | int | ctx) | const |
Perform consistency check on table entry.
ctx | is the number of the entry to be checked |
Definition at line 144 of file ComtreeTable.cpp.
|
inline |
Deegister a route with a given comtree link.
cLnk | is a valid comtree link number |
rtx | is an integer that is presumed to be a route index |
Definition at line 506 of file ComtreeTableFeng.h.
string & forest::ComtreeTable::entry2string | ( | int | ctx, |
string & | s | ||
) | const |
Write a table entry to an output stream.
ctx | is the comtree index of the comtree to be written |
s | is a reference to a string in which result is returned |
Definition at line 255 of file ComtreeTable.cpp.
string forest::ComtreeTable::entry2string | ( | int | ctx) | const |
Create a string representing a table entry.
ctx | is the comtree index of the comtree to be written |
Definition at line 249 of file ComtreeTable.cpp.
|
inline |
Get the first comtree index.
This method is used to iterate through all the comtrees. The order of the comtree indices is arbitrary.
Definition at line 286 of file ComtreeTable.h.
|
inline |
Get the first comtree index.
This method is used to iterate through all the comtrees. The order of the comtree indices is arbitrary.
Definition at line 242 of file ComtreeTableFeng.h.
|
inline |
Get a list of comtrees that use a specified link.
lnk | is a link number |
ctx | is a comtree index |
Definition at line 425 of file ComtreeTable.h.
|
inline |
Get the first comtree link number going to a core router.
ctx | is a comtree index |
Definition at line 459 of file ComtreeTable.h.
|
inline |
Get the first comtree link number going to a router.
ctx | is a comtree index |
Definition at line 442 of file ComtreeTable.h.
|
inline |
Get the comtree link info for a specfic comtree link.
ctx | is a comtree index |
cLnk | is a comtree link number for comtree ctx |
Definition at line 353 of file ComtreeTable.h.
|
inline |
Get the comtree link number for a given (comtree, link) pair.
comt | is a comtree number |
lnk | is a link number |
Definition at line 340 of file ComtreeTable.h.
|
inline |
Get the comtree index, based on the comtree number.
comt | is the comtree number |
comt | is the comtree number |
Definition at line 321 of file ComtreeTable.h.
|
inline |
Get the comtree link number for a given (comtree, link) pair.
comt | is a comtree number |
lnk | is a link number |
Definition at line 287 of file ComtreeTableFeng.h.
|
inline |
Get the comtree number for a given table entry.
ctx | is the comtree index |
Definition at line 305 of file ComtreeTable.h.
|
inline |
Get a reference to the set of comtree links leading to a core router.
This method is provided to allow the client program to iterate through all the "core links" in the comtree. It must not be used to modify the set of links.
ctx | is a comtree index |
Definition at line 381 of file ComtreeTableFeng.h.
|
inline |
Get the allowed destination for packets received on a given comtree link.
cLnk | is a comtree link number |
Definition at line 337 of file ComtreeTableFeng.h.
|
inline |
Get the allowed destination for packets received on a given comtree link.
ctx | is a comtree index |
cLnk | is a comtree link number |
Definition at line 400 of file ComtreeTable.h.
|
inline |
Get the comtree table entry for a given comtree, using its index.
cts | is the comtree index |
Definition at line 313 of file ComtreeTable.h.
|
inline |
Get the link number for a given comtree link.
cLnk | is a comtree link number |
Definition at line 320 of file ComtreeTableFeng.h.
|
inline |
Get the link number for a given comtree link.
ctx | is a comtree index |
cLnk | is a comtree link number |
Definition at line 380 of file ComtreeTable.h.
|
inline |
Get the number of links that belong to this comtree.
ctx | is the comtree index |
Definition at line 329 of file ComtreeTable.h.
|
inline |
Get the queue identifier for a given comtree link.
cLnk | is a comtree link number |
Definition at line 328 of file ComtreeTableFeng.h.
|
inline |
Get the queue identifier for a given comtree link.
ctx | is a comtree index |
cLnk | is a comtree link number |
Definition at line 390 of file ComtreeTable.h.
|
inline |
Get a reference to the set of comtree links for a comtree.
This method is provided to allow the client program to iterate through all the links in the comtree. It must not be used to modify the set of links.
ctx | is a comtree index |
Definition at line 357 of file ComtreeTableFeng.h.
|
inline |
Get the comtree link number for the parent link in a comtree.
ctx | is the comtree index |
Definition at line 305 of file ComtreeTableFeng.h.
|
inline |
Get the comtree link number for the parent link in a comtree.
ctx | is the comtree index |
Definition at line 371 of file ComtreeTable.h.
|
inline |
Get a reference to the set of comtree links leading to a core router.
This method is provided to allow the client program to iterate through all the "core links" in the comtree. It must not be used to modify the set of links.
ctx | is a comtree index |
Definition at line 393 of file ComtreeTableFeng.h.
|
inline |
Get the parent link for a comtree.
ctx | is the comtree index |
Definition at line 363 of file ComtreeTable.h.
|
inline |
Get the rate spec for a given comtree link.
cLnk | is a comtree link number |
Definition at line 345 of file ComtreeTableFeng.h.
|
inline |
Get the rate spec for a given comtree link.
ctx | is a comtree index |
cLnk | is a comtree link number |
Definition at line 409 of file ComtreeTable.h.
|
inline |
Get a reference to the set of routes registered with a comtree link.
This method is provided to allow the client program to iterate through all the routes that use a comtree link. It must not be used to modify the set of routes.
cLnk | is a comtree link number |
Definition at line 409 of file ComtreeTableFeng.h.
|
inline |
Get a reference to the set of comtree links leading to another router.
This method is provided to allow the client program to iterate through all the "router links" in the comtree. It must not be used to modify the set of links.
ctx | is a comtree index |
Definition at line 369 of file ComtreeTableFeng.h.
|
inline |
Get the rate spec for a given comtree link.
cLnk | is a comtree link number |
Definition at line 312 of file ComtreeTableFeng.h.
|
inline |
Determine if "this node" is in the core of the comtree.
ctx | is a comtree index |
Definition at line 243 of file ComtreeTable.h.
|
inline |
Determine if a given comtree link connects to a core node.
cLnk | is the comtree link number |
Definition at line 217 of file ComtreeTableFeng.h.
|
inline |
Determine if a given comtree link connects to a core node.
Determine if a given link connects to a core node.
ctx | is the comtree index |
cLnk | is the comtree link number |
ctx | is the comtree index |
lnk | is the link number |
Definition at line 274 of file ComtreeTable.h.
|
inline |
Determine if a given link is part of a given comtree.
entry | is the comtree index |
lnk | is the link number |
Definition at line 252 of file ComtreeTable.h.
|
inline |
Determine if a given comtree is locked.
ctx | is the comtree number |
Definition at line 227 of file ComtreeTableFeng.h.
|
inline |
Determine if a given comtree link connects to another router.
cLnk | is the comtree index |
Definition at line 197 of file ComtreeTableFeng.h.
|
inline |
Determine if a given comtree link connects to another router.
Determine if a given link connects to another router.
ctx | is the comtree index of the relevant comtree |
cLnk | is the comtree link index |
ctx | is the comtree index |
lnk | is the link number |
Definition at line 263 of file ComtreeTable.h.
|
inlineprivate |
helper functions
Set the outgoing packet rate for a comtree link.
cLnk | is a comtree link number |
pr | is a packet rate inline void ComtreeTable::setOutPktRate(int cLnk, int pr) { if (validComtLink(cLnk)) clTbl[cLnk].outPktRate = pr; }Compute key for use with comtMap. |
comt | is a comtree number |
Definition at line 547 of file ComtreeTableFeng.h.
|
inlineprivate |
Compute key for use with clMap.
comt | is a comtree number |
lnk | is a link number |
Definition at line 556 of file ComtreeTableFeng.h.
|
inline |
Get the next comtree index.
This method is used to iterate through all the comtrees. The order of the comtree indices is arbitrary.
ctx | is a comtree index |
Definition at line 297 of file ComtreeTable.h.
|
inline |
Get the next comtree index.
This method is used to iterate through all the comtrees. The order of the comtree indices is arbitrary.
ctx | is a comtree index |
Definition at line 253 of file ComtreeTableFeng.h.
|
inline |
Get the next comtree link number for a given comtree.
ctx | is a comtree index |
cLnk | is a comtree link that is defined for the comtree |
Definition at line 434 of file ComtreeTable.h.
|
inline |
Get the next comtree link number going to a router.
ctx | is a comtree index |
cLnk | is a comtree link that is defined for the comtree |
Definition at line 468 of file ComtreeTable.h.
|
inline |
Get the next comtree link number going to a router.
ctx | is a comtree index |
cLnk | is a comtree link that is defined for the comtree |
Definition at line 451 of file ComtreeTable.h.
void forest::ComtreeTable::purgeLink | ( | int | lnk) |
Remove a link from all comtrees that currently use it.
Caller is assumed to hold locks on the ComtreeTable.
lnk | is the number of the link to be purged |
Definition at line 115 of file ComtreeTable.cpp.
bool forest::ComtreeTable::read | ( | istream & | in) |
Read comtree table entries from an input stream.
The first line of the input must contain an integer, giving the number of entries to be read. The input may include blank lines and comment lines (any text starting with '#'). The operation may fail if the input is misformatted or if an entry does not pass some basic sanity checks. In this case, an error message is printed that identifies the entry on which a problem was detected
in | is an open input stream |
Definition at line 230 of file ComtreeTable.cpp.
|
private |
helper functions
Read an entry from an input stream and initialize its table entry.
The entry must be on a line by itself (possibly with a trailing comment). An entry consists of a comtree number, a core flag (0 or 1), the link number of the link leading to the parent, and two comma-separated lists of links.
in | is an open input stream |
Definition at line 182 of file ComtreeTable.cpp.
|
private |
Read a list of links from an input stream.
The list consists of integers separated by commas. The first number that is not immediately followed by a comma is assumed to be the last one on the list.
in | is an open input stream |
links | is a reference to a set of integers; on return, it will contain the list of link numbers read from the input |
Definition at line 172 of file ComtreeTable.cpp.
|
inline |
Set the incoming bit rate for a comtree link.
cLnk | is a comtree link number |
br | is a bit rate inline void ComtreeTable::setInBitRate(int cLnk, int br) { if (validComtLink(cLnk)) clTbl[cLnk].inBitRate = br; } Set the incoming packet rate for a comtree link. |
cLnk | is a comtree link number |
pr | is a packet rate inline void ComtreeTable::setInPktRate(int cLnk, int pr) { if (validComtLink(cLnk)) clTbl[cLnk].inPktRate = pr; } Set the outgoing bit rate for a comtree link. |
cLnk | is a comtree link number |
br | is a bit rate inline void ComtreeTable::setOutBitRate(int cLnk, int br) { if (validComtLink(cLnk)) clTbl[cLnk].outBitRate = br; }Register a route with a given comtree link. |
cLnk | is a valid comtree link number |
rtx | is an integer that is presumed to be a route index |
Definition at line 498 of file ComtreeTableFeng.h.
bool forest::ComtreeTable::removeEntry | ( | int | ctx) |
Remove a table entry.
This method removes all comtree links from the comtree, before removing the comtree itself. This requires that the comtree links have previously had all their routes removed.
ctx | is the index of the entry to be deleted |
This method requires that all links have been previously removed from the comtree;
ctx | is the index of the entry to be deleted |
Definition at line 93 of file ComtreeTable.cpp.
bool forest::ComtreeTable::removeLink | ( | int | ctx, |
int | cLnk | ||
) |
Remove a comtree link from the set of valid links for a comtree.
ctx | is comtree index of the comtree to be modified |
cLnk | is the number of the comtree link to removed |
return | true on success, false on failure |
This method requires that there are no multicast routes registered with this comtree.
ctx | is comtree index of the comtree to be modified |
cLnk | is the number of the comtree link to removed |
return | true on success, false on failure |
Definition at line 56 of file ComtreeTable.cpp.
|
inline |
Deegister a route with a given comtree link.
cLnk | is a valid comtree link number |
rtx | is an integer that is presumed to be a route index |
Definition at line 530 of file ComtreeTableFeng.h.
|
inline |
Set the core flag for a given table entry.
ctx | is the comtree index |
f | is the new value of the core flag for this entry |
Definition at line 490 of file ComtreeTable.h.
|
inline |
Set the queue number for a comtree link.
cLnk | is a comtree link number |
q | is a queue number |
Definition at line 466 of file ComtreeTableFeng.h.
|
inline |
Set the queue number for a comtree link.
ctx | is a comtree index |
cLnk | is a comtree link number |
q | is a queue number |
Definition at line 499 of file ComtreeTable.h.
|
inline |
Set the lock bit for a comtree.
ctx | is the comtree index |
lock | is the lock bit, 1 means the comtree is locked |
Definition at line 439 of file ComtreeTableFeng.h.
|
inline |
Set the parent link for a given table entry.
ctx | is the comtree index |
plink | is the number of the link to this router's parent in the comtree |
Definition at line 477 of file ComtreeTable.h.
|
inline |
Set the prune request packet number for a comtree.
ctx | is the comtree index |
Definition at line 450 of file ComtreeTableFeng.h.
string & forest::ComtreeTable::toString | ( | string & | s) | const |
Create a string representation of the table.
s | is a reference to a string in which the result is returned |
Definition at line 285 of file ComtreeTable.cpp.
string forest::ComtreeTable::toString | ( | ) | const |
Create a string representation of the table.
Definition at line 262 of file ComtreeTable.cpp.
|
inline |
Determine if a comtree link number is being used by a given comtree.
ctx | is a comtree index |
cLnk | is a comtree link number |
Definition at line 234 of file ComtreeTable.h.
|
inline |
Determine if a comtree index is being used in this table.
cts | is a comtree index |
Definition at line 154 of file ComtreeTableFeng.h.
|
inline |
Determine if a comtree link number is in use in this table.
cLnk | is a comtree link number |
Definition at line 163 of file ComtreeTableFeng.h.
|
inline |
Determine if the table has an entry for a given comtree.
comt | is a comtree number |
Definition at line 216 of file ComtreeTable.h.
|
inline |
Determine if a comtree index is being used in this table.
ctx | is a comtree index |
Definition at line 224 of file ComtreeTable.h.
|
private |
|
private |