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

Public Member Functions

 Router (const RouterInfo &)
 Constructor for Router, initializes key parameters and allocates space. More...
 
bool readTables (const RouterInfo &)
 Read router configuration tables from files. More...
 
bool setup ()
 Setup router after tables and interfaces have been configured. More...
 
bool setupIface (int)
 Setup an interface. More...
 
bool setupAllIfaces ()
 Setup interfaces specified in the interface table. More...
 
void run ()
 
void dump (ostream &os)
 Write the contents of all router tables to an output stream. More...
 

Private Member Functions

bool setupIfaces ()
 
bool setupLeafAddresses ()
 Allocate addresses to peers specified in the initial link table. More...
 
bool setupQueues ()
 Setup queues as needed to support initial comtree configuration. More...
 
bool checkTables ()
 Check all router tables for mutual consistency. More...
 
bool setAvailRates ()
 Set available rates for interfaces and links. More...
 
void addLocalRoutes ()
 Add routes to neighboring leaf nodes and to routers in foreign zip codes. More...
 
fAdr_t allocLeafAdr ()
 Allocate a new leaf address. More...
 
bool allocLeafAdr (fAdr_t)
 Allocate a specified leaf address. More...
 
void freeLeafAdr (fAdr_t)
 De-allocate a leaf address. More...
 
bool validLeafAdr (fAdr_t) const
 Determine if a given address is currently assigned. More...
 
bool isFreeLeafAdr (fAdr_t) const
 Determine if a given address is currently unassigned. More...
 
uint64_t nextSeqNum ()
 Get the next sequence number. More...
 

Private Attributes

ipa_t bootIp
 IP address used during booting.
 
bool booting
 true while booting
 
fAdr_t myAdr
 forest address of this router
 
ipa_t nmIp
 IP address of the netMgr.
 
fAdr_t nmAdr
 forest address of the netMgr
 
fAdr_t ccAdr
 address of comtree controller
 
seconds runLength
 

of seconds for router to run


 
high_resolution_clock::time_point tZero
 router start time
 
uint64_t seqNum
 sequence number for ctl packets
 
mutex snLock
 lock for sequence number
 
fAdr_t firstLeafAdr
 first leaf address
 
fAdr_t lastLeafAdr
 last leaf address
 
ListPair * leafAdr
 offsets for leaf addresses
 
Quu< int > xferQ
 XferQ used to transfer packets from input thread to output thread.
 
IfaceTableift
 table defining interfaces
 
LinkTablelt
 table defining links
 
ComtreeTablectt
 table of comtrees
 
RouteTablert
 table of routes
 
PacketStoreps
 packet buffers and headers
 
StatsModulesm
 class for recording statistics
 
PacketLogpktLog
 log for recording sample of packets
 
QuManagerqm
 queues and link schedulers
 
mutex iftMtx
 lock for iface table
 
mutex ltMtx
 lock for link table
 
mutex cttMtx
 lock for comtree table
 
mutex rtMtx
 lock for routing table
 
int * sock
 vector of socket numbers
 
int maxSockNum
 largest socket number used
 
RouterInProcrip
 
RouterOutProcrop
 

Friends

class RouterInProc
 
class RouterOutProc
 
class RouterControl
 

Detailed Description

Definition at line 70 of file Router.h.

Constructor & Destructor Documentation

forest::Router::Router ( const RouterInfo config)

Constructor for Router, initializes key parameters and allocates space.

Parameters
configis a RouterInfo structure which has been initialized to specify various router parameters

Definition at line 114 of file Router.cpp.

Member Function Documentation

void forest::Router::addLocalRoutes ( )
private

Add routes to neighboring leaf nodes and to routers in foreign zip codes.

Routes are added in all comtrees.

Definition at line 536 of file Router.cpp.

Here is the call graph for this function:

fAdr_t forest::Router::allocLeafAdr ( )
inlineprivate

Allocate a new leaf address.

Caller is assumed to hold the LinkTable lock.

Returns
a previously unused address in the range of assignable leaf addresses for this router, or 0 if all addresses are in use

Definition at line 152 of file Router.h.

bool forest::Router::allocLeafAdr ( fAdr_t  adr)
inlineprivate

Allocate a specified leaf address.

Caller is assumed to hold the LinkTable lock.

Parameters
adris an address in the range of assignable addresses
Returns
true of the adr is available for use and was successfully allocated, else false

Definition at line 165 of file Router.h.

bool forest::Router::checkTables ( )
private

Check all router tables for mutual consistency.

Sends error messages to cerr if inconsistencies are found. This does not verify the consistency of interface, link and comtree rates. That is left to the setAvailRates() method.

Returns
true on success, false on failure

Definition at line 347 of file Router.cpp.

Here is the call graph for this function:

void forest::Router::dump ( ostream &  out)

Write the contents of all router tables to an output stream.

Parameters
outis an open output stream

Definition at line 557 of file Router.cpp.

void forest::Router::freeLeafAdr ( fAdr_t  adr)
inlineprivate

De-allocate a leaf address.

Caller is assumed to hold the LinkTable lock.

Parameters
adris a previously allocated address.

Definition at line 176 of file Router.h.

bool forest::Router::isFreeLeafAdr ( fAdr_t  adr) const
inlineprivate

Determine if a given address is currently unassigned.

Caller is assumed to hold the LinkTable lock.

Parameters
adris a forest unicast address
Returns
true if adr is not currently assigned.

Definition at line 198 of file Router.h.

uint64_t forest::Router::nextSeqNum ( )
private

Get the next sequence number.

Definition at line 170 of file Router.cpp.

Here is the caller graph for this function:

bool forest::Router::readTables ( const RouterInfo config)

Read router configuration tables from files.

This method reads initial router configuration files (if present) and configures router tables as specified.

Parameters
configis a RouterInfo structure which has been initialized to specify various router parameters

Definition at line 182 of file Router.cpp.

Here is the caller graph for this function:

bool forest::Router::setAvailRates ( )
private

Set available rates for interfaces and links.

Sends error messages to cerr if specified rates lead to over-subscription.

Returns
true on success, false if specified rates oversubscribe an interface or link

Definition at line 474 of file Router.cpp.

Here is the call graph for this function:

bool forest::Router::setup ( )

Setup router after tables and interfaces have been configured.

Invokes several setup and verification methods to ensure that the initial configuration is fully consistent.

Definition at line 235 of file Router.cpp.

Here is the caller graph for this function:

bool forest::Router::setupAllIfaces ( )

Setup interfaces specified in the interface table.

This involves opening a separate UDP socket for each interface.

Returns
true on success, false on failure

Definition at line 251 of file Router.cpp.

bool forest::Router::setupIface ( int  i)

Setup an interface.

Caller is assumed to hold the lock on the IfaceTable object.

Parameters
iis the number of a new interface to be configured
Returns
true on success, false on failure.

Definition at line 269 of file Router.cpp.

Here is the call graph for this function:

bool forest::Router::setupLeafAddresses ( )
private

Allocate addresses to peers specified in the initial link table.

Verifies that the initial peer addresses are in the range of assignable leaf addresses, and allocates them if they are.

Returns
true on success, false on failure

Definition at line 298 of file Router.cpp.

bool forest::Router::setupQueues ( )
private

Setup queues as needed to support initial comtree configuration.

For each defined comtree, a queue is allocated to each of its links. For each comtree link, initial rates are the minimum bit rate and packet rate allowed.

Returns
true on success, false on failure

Definition at line 314 of file Router.cpp.

bool forest::Router::validLeafAdr ( fAdr_t  adr) const
inlineprivate

Determine if a given address is currently assigned.

Caller is assumed to hold the LinkTable lock.

Parameters
adris a forest unicast address
Returns
true if adr is one that had been previously assigned

Definition at line 188 of file Router.h.


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