forest-net
an overlay networks for large-scale virtual worlds
|
Maintains information about an entire Forest network. More...
#include <NetInfo.h>
Classes | |
struct | IfInfo |
struct | LeafNodeInfo |
structure holding information used by leaf nodes More... | |
struct | LinkDesc |
struct | LinkInfo |
struct | RtrNodeInfo |
structure holding information used by router nodes More... | |
Public Types | |
enum | statusType { UP, DOWN, BOOTING } |
Public Member Functions | |
NetInfo (int, int, int, int) | |
Constructor for NetInfo, allocates space and initializes private data. More... | |
~NetInfo () | |
Destructor for NetInfo class. More... | |
bool | validNode (int) const |
Check to see that a node number is valid. More... | |
int | firstNode () const |
Get the number of the "first" node in the Forest network. More... | |
int | nextNode (int) const |
Get the node number of the "next" node in the Forest network. More... | |
int | getMaxNode () const |
Get the maximum node number for the network. More... | |
string & | getNodeName (int, string &) const |
Get the name for a specified node. More... | |
int | getNodeNum (string &) const |
Get the node number corresponding to a give node name. More... | |
int | getNodeNum (fAdr_t) const |
Get the node number corresponding to a give forest address. More... | |
Forest::ntyp_t | getNodeType (int) const |
Get the type of a specified node. More... | |
fAdr_t | getNodeAdr (int) const |
Get the Forest address of a node. More... | |
bool | getNodeLocation (int, pair< double, double > &) const |
Get the location of a node in the Forest network. More... | |
statusType | getStatus (int) const |
Get the status of a node. More... | |
bool | setNodeName (int, string &) |
Set the name of a node. More... | |
bool | setNodeAdr (int, fAdr_t) |
Set the forest address of a node. More... | |
bool | setNodeLocation (int, pair< double, double > &) |
Set the location of a node in the Forest network. More... | |
void | setStatus (int, statusType) |
Set the status of a node. More... | |
bool | isLeaf (int) const |
Determine if a given node number identifies a leaf. More... | |
int | firstLeaf () const |
Get the node number of the first leaf node in the Forest network. More... | |
int | nextLeaf (int) const |
Get the node number of the "next" leaf node in the Forest network. More... | |
int | firstController () const |
Get the node number of the first controller in the Forest network. More... | |
int | nextController (int) const |
Get the node number of the next controller in the Forest network. More... | |
ipa_t | getLeafIpAdr (int) const |
Get the IP address of a leaf node. More... | |
int | addLeaf (const string &, Forest::ntyp_t) |
Add a leaf node to a Forest network. More... | |
bool | setLeafType (int, Forest::ntyp_t) |
Set the node type of a leaf node. More... | |
bool | setLeafIpAdr (int, ipa_t) |
Set the IP address of a leaf node. More... | |
bool | isRouter (int) const |
Determine if a given node number identifies a router. More... | |
bool | validIf (int, int) const |
Check to see if a given router interface is valid. More... | |
int | firstRouter () const |
Get the node number of the first router in the Forest network. More... | |
int | nextRouter (int) const |
Get the node number of the "next" router in the Forest network. More... | |
int | getMaxRouter () const |
Get the maximum router number for the network. More... | |
int | getNumRouters () const |
Get the number of routers in this network. More... | |
int | getIface (int, int) const |
Get the interface associated with a given local link number. More... | |
int | getNumIf (int) const |
Get the number of interfaces defined for a router. More... | |
bool | getLeafRange (int, pair< fAdr_t, fAdr_t > &) const |
Get the range of leaf addresses for a router. More... | |
ipa_t | getIfIpAdr (int, int) const |
Get the IP address of a specified router interface. More... | |
ipp_t | getIfPort (int, int) const |
Get the IP port of a specified router interface. More... | |
RateSpec & | getIfRates (int, int) const |
Get the RateSpec for a router interface. More... | |
bool | getIfLinks (int, int, pair< int, int > &) const |
Get the range of link numbers assigned to an interface. More... | |
int | addRouter (const string &) |
Add a new router to the NetInfo object. More... | |
bool | addInterfaces (int, int) |
Add interfaces to a router. More... | |
bool | setLeafRange (int, pair< int, int > &) |
Set the range of assignable client addresses for this router. More... | |
bool | setIfIpAdr (int, int, ipa_t) |
Set the IP address of a router interface. More... | |
bool | setIfPort (int, int, ipp_t) |
Set the IP address of a router interface. More... | |
bool | setIfLinks (int, int, pair< int, int > &) |
Set the RateSpec for a router interface. More... | |
bool | validLink (int) const |
Check to see if a given link number is valid. More... | |
int | firstLink () const |
Get the number of the first link in the Forest network. More... | |
int | nextLink (int) const |
Get the number of the next link in the Forest network. More... | |
int | firstLinkAt (int) const |
Get the number of the first link incident to a specified node. More... | |
int | nextLinkAt (int, int) const |
Get the number of the next link incident to a specified node. More... | |
int | getMaxLink () const |
Get the maximum link number for the network. More... | |
int | getLeft (int) const |
Get the node number for the "left" endpoint of a given link. More... | |
int | getRight (int) const |
Get the node number for the "right" endpoint of a given link. More... | |
int | getPeer (int, int) const |
Get the node number for the "other" endpoint of a given link. More... | |
RateSpec & | getLinkRates (int) const |
Get the RateSpec of a link in the Forest network. More... | |
RateSpec & | getAvailRates (int) const |
Get the available rates of a link in the Forest network. More... | |
RateSpec & | getDefLeafRates () |
Get the default rates for leaf nodes in a Forest network. More... | |
int | getLinkLength (int) const |
Get the length of a link in the Forest network. More... | |
int | getLinkNum (int, int) const |
Get the global link number of a link incident to a node. More... | |
int | getLLnum (int, int) const |
Get the local link number used by one of the endpoints of a link. More... | |
int | getLeftLLnum (int) const |
Get the local link number used by the left endpoint of a link. More... | |
int | getRightLLnum (int) const |
Get the local link number used by the right endpoint of a link. More... | |
uint64_t | getNonce (int) const |
Get the nonce for a link. More... | |
int | addLink (int, int, int, int) |
Add a link to a forest network. More... | |
bool | setLeftLLnum (int, int) |
Set the local link number used by the left endpoint of a link. More... | |
bool | setRightLLnum (int, int) |
Set the local link number used by the right endpoint of a link. More... | |
bool | setLinkLength (int, int) |
Set the RateSpec for a link. More... | |
bool | setNonce (int, uint64_t) |
Set the nonce for a link. More... | |
bool | read (istream &) |
Reads a network topology file and initializes the NetInfo data structure. More... | |
string | link2string (int) const |
Create a string representation of a link. More... | |
string | linkProps2string (int) const |
Create a string representation of a link and its properties. More... | |
string | linkState2string (int) const |
Create a string representation of a link and its current state. More... | |
string | toString () const |
Create a string representation of the NetInfo object. More... | |
void | lock () |
Lock the data structure. More... | |
void | unlock () |
Unlock the data structure. | |
Private Member Functions | |
uint64_t | ll2l_key (int, int) const |
returns key used with locLnk2lnk More... | |
bool | readRouter (istream &, RtrNodeInfo &, IfInfo *, string &) |
Read a router description from an input stream. More... | |
bool | readLocation (istream &, pair< double, double > &) |
Read a (latitude,longitude) pair. More... | |
bool | readAdrRange (istream &, pair< fAdr_t, fAdr_t > &) |
Read an address range pair. More... | |
bool | readRateSpec (istream &, RateSpec &) |
Read a rate specification. More... | |
int | readIface (istream &, IfInfo *, string &) |
Read a router interface description from an input stream. More... | |
bool | readLeaf (istream &, LeafNodeInfo &, string &) |
Read a leaf node description from an input stream. More... | |
bool | readLink (istream &, LinkDesc &, string &) |
Read a link description from an input stream. More... | |
bool | readLinkEndpoint (istream &, string &, int &) |
Read a link endpoint. More... | |
bool | check () const |
Perform a series of consistency checks. More... | |
bool | checkLocalLinks () const |
Check that the local link numbers at all routers are consistent. More... | |
bool | checkBackBone () const |
Check that the routers are all connected. More... | |
bool | checkAddresses () const |
Check that no two nodes have the same Forest address. More... | |
bool | checkLeafRange () const |
Check leaf address ranges of all routers. More... | |
bool | checkLeafNodes () const |
Check consistency of leaf nodes. More... | |
bool | checkLinkRates () const |
Check that link rates are consistent with Forest requirements. More... | |
bool | checkRtrRates () const |
Check interface and link rates at all routers for consistency. More... | |
string & | rtr2string (int, string &) const |
Create a string representation of a router. More... | |
string & | leaf2string (int, string &) const |
Create a string representation of a leaf node. More... | |
Private Attributes | |
int | maxRtr |
max node number for a router; More... | |
int | maxNode |
max node number in netTopo graph | |
int | maxLink |
max link number in netTopo graph | |
int | maxLeaf |
max number of leafs | |
int | maxCtl |
maximum number of controllers | |
Wgraph * | netTopo |
NetTopo is a weighted graph defining the network topology. More... | |
LeafNodeInfo * | leaf |
UiSetPair * | leaves |
in-use and free leaf numbers | |
set< int > * | controllers |
set of controllers (by node #) | |
RtrNodeInfo * | rtr |
UiSetPair * | routers |
tracks routers and unused router numbers | |
map< string, int > * | nameNodeMap |
maps a node name back to corresponding node number | |
map< fAdr_t, int > * | adrNodeMap |
maps a forest address to a node number | |
HashMap * | locLnk2lnk |
maps router/local link# to global link# | |
LinkInfo * | link |
RateSpec | defaultLeafRates |
default link rates | |
pthread_mutex_t | glock |
for locking in multi-threaded contexts | |
Static Private Attributes | |
static int const | UNDEF_LAT = 91 |
static int const | UNDEF_LONG = 361 |
Maintains information about an entire Forest network.
The NetInfo data structure is intended for use by network control elements that require a global view of the network. Currently, this includes the NetMgr and the ComtreeController components.
Internally, a NetInfo object uses a Wgraph to represent the network topology. It also has tables of attributes for all nodes and links. It provides a large number of methods for accessing the internal representation in a convenient way, It also has a read() method to read in a network description from a file and build the corresponding internal data structure. And it has a toString() method that can be used in an output stream.
forest::NetInfo::NetInfo | ( | int | maxNode1, |
int | maxLink1, | ||
int | maxRtr1, | ||
int | maxCtl1 | ||
) |
Constructor for NetInfo, allocates space and initializes private data.
maxNode1 | is the maximum number of nodes in this NetInfo object |
maxLink1 | is the maximum number of links in this NetInfo object |
maxRtr1 | is the maximum number of routers in this NetInfo object |
maxCtl1 | is the maximum number of controllers in this NetInfo object |
Definition at line 20 of file NetInfo.cpp.
forest::NetInfo::~NetInfo | ( | ) |
Destructor for NetInfo class.
Deallocates all dynamic storage
Definition at line 46 of file NetInfo.cpp.
bool forest::NetInfo::addInterfaces | ( | int | r, |
int | numIf | ||
) |
Add interfaces to a router.
Currently this operation can only be done once for a router, typically during its initial initiialization.
r | is the node number of the router |
numIf | is the number of interfaces that are to allocated to the router |
Definition at line 106 of file NetInfo.cpp.
int forest::NetInfo::addLeaf | ( | const string & | name, |
Forest::ntyp_t | nTyp | ||
) |
Add a leaf node to a Forest network.
name | is the name of the new leaf |
nTyp | is the desired node type (CLIENT or CONTROLLER) |
Definition at line 120 of file NetInfo.cpp.
int forest::NetInfo::addLink | ( | int | u, |
int | v, | ||
int | uln, | ||
int | vln | ||
) |
Add a link to a forest network.
u | is a node number of some node in the network |
v | is a node number of some node in the network |
uln | if u is a ROUTER, then uln is a local link number used by u to identify the link - for leaf nodes, this argument is ignored |
vln | if v is a ROUTER, then vln is a local link number used by v to identify the link - for leaf nodes, this argument is ignored |
Definition at line 149 of file NetInfo.cpp.
int forest::NetInfo::addRouter | ( | const string & | name) |
Add a new router to the NetInfo object.
A new router object is allocated and assigned a name.
name | is the name of the new router |
Definition at line 78 of file NetInfo.cpp.
|
private |
Perform a series of consistency checks.
Print error message for each detected problem.
Definition at line 598 of file NetInfo.cpp.
|
private |
Check that no two nodes have the same Forest address.
Write message to stderr for every error detected.
Definition at line 697 of file NetInfo.cpp.
|
private |
Check that the routers are all connected.
Write message to stderr for every error detected.
Definition at line 674 of file NetInfo.cpp.
|
private |
Check consistency of leaf nodes.
Write message to stderr for every error detected.
Definition at line 764 of file NetInfo.cpp.
|
private |
Check leaf address ranges of all routers.
Write message to stderr for every error detected.
Definition at line 720 of file NetInfo.cpp.
|
private |
Check that link rates are consistent with Forest requirements.
Definition at line 804 of file NetInfo.cpp.
|
private |
Check that the local link numbers at all routers are consistent.
Write message to stderr for every error detected.
Definition at line 636 of file NetInfo.cpp.
|
private |
Check interface and link rates at all routers for consistency.
Write an error message to stderr for each error detected
Definition at line 827 of file NetInfo.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
Get the number of the first link incident to a specified node.
n | is the node number of a node in the network |
Definition at line 708 of file NetInfo.h.
|
inline |
|
inline |
|
inline |
|
inline |
int forest::NetInfo::getIface | ( | int | llnk, |
int | rtr | ||
) | const |
Get the interface associated with a given local link number.
llnk | is a local link number |
rtr | is a router |
Definition at line 62 of file NetInfo.cpp.
|
inline |
Get the IP address of a specified router interface.
r | is the node number of a router in the network |
iface | is an interface number for r |
Definition at line 581 of file NetInfo.h.
|
inline |
Get the range of link numbers assigned to an interface.
Each router interface is assigned a consecutive range of link numbers.
r | is the node number of a router in the network |
iface | is an interface number for r |
Definition at line 610 of file NetInfo.h.
|
inline |
Get the IP port of a specified router interface.
r | is the node number of a router in the network |
iface | is an interface number for r |
Definition at line 591 of file NetInfo.h.
|
inline |
|
inline |
Get the range of leaf addresses for a router.
r | is the node number of the router |
adr | is the forest address that defines the start of the range |
Definition at line 516 of file NetInfo.h.
|
inline |
Get the node number for the "left" endpoint of a given link.
The endpoints of a link are arbitrarily designated "left" and "right".
lnk | is a link number |
Definition at line 733 of file NetInfo.h.
|
inline |
Get the local link number used by the left endpoint of a link.
Each router in a Forest network refers to links using local link numbers.
lnk | is a "global" link number |
Definition at line 776 of file NetInfo.h.
|
inline |
|
inline |
Get the global link number of a link incident to a node.
nn | is a valid node number |
llnk | is an optional local link number |
Definition at line 838 of file NetInfo.h.
|
inline |
|
inline |
Get the local link number used by one of the endpoints of a link.
Each router in a Forest network refers to links using local link numbers.
lnk | is a "global" link number |
r | is the node number of router |
Definition at line 764 of file NetInfo.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get the location of a node in the Forest network.
n | is a node number |
loc | is a reference to a pair of doubles in which the latitude and longitude are returned |
Definition at line 555 of file NetInfo.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get the number of interfaces defined for a router.
r | is the node number of a router |
Definition at line 528 of file NetInfo.h.
|
inline |
|
inline |
Get the node number for the "other" endpoint of a given link.
n | is a node number |
lnk | is a link number |
Definition at line 753 of file NetInfo.h.
|
inline |
Get the node number for the "right" endpoint of a given link.
The endpoints of a link are arbitrarily designated "left" and "right".
lnk | is a link number |
Definition at line 743 of file NetInfo.h.
|
inline |
Get the local link number used by the right endpoint of a link.
Each router in a Forest network refers to links using local link numbers.
lnk | is a "global" link number |
Definition at line 787 of file NetInfo.h.
|
inline |
|
inline |
|
inline |
|
private |
Create a string representation of a leaf node.
leaf | is a node number for a leaf node |
s | is a reference to a string in which result is returned |
Definition at line 999 of file NetInfo.cpp.
string & forest::NetInfo::link2string | ( | int | ) | const |
Create a string representation of a link.
lnk | is a link number |
s | is a reference to a string in which result is returned |
Definition at line 876 of file NetInfo.cpp.
string & forest::NetInfo::linkProps2string | ( | int | ) | const |
Create a string representation of a link and its properties.
link | is a link number |
s | is a reference to a string in which result is returned |
Definition at line 894 of file NetInfo.cpp.
string & forest::NetInfo::linkState2string | ( | int | ) | const |
Create a string representation of a link and its current state.
link | is a link number |
s | is a reference to a string in which result is returned |
Definition at line 913 of file NetInfo.cpp.
|
inlineprivate |
returns key used with locLnk2lnk
Helper method used to define keys for internal locLnk2lnk HashMap.
r | is the node number of a router |
llnk | is a local link number at r |
Definition at line 916 of file NetInfo.h.
|
inline |
|
inline |
Get the node number of the next controller in the Forest network.
Used for iterating through all the controllers
n | is the node number for a controller |
Definition at line 305 of file NetInfo.h.
|
inline |
Get the node number of the "next" leaf node in the Forest network.
Used for iterating through all the leaves.
n | is the number of a leaf in the network |
Definition at line 438 of file NetInfo.h.
|
inline |
|
inline |
Get the number of the next link incident to a specified node.
n | is the node number of a node in the network |
lnk | is a link incident to n |
Definition at line 718 of file NetInfo.h.
|
inline |
Get the node number of the "next" node in the Forest network.
Used for iterating through all the nodes.
n | is the number of a node in the network |
Definition at line 282 of file NetInfo.h.
|
inline |
Get the node number of the "next" router in the Forest network.
Used for iterating through all the routers.
r | is the number of a router in the network |
Definition at line 498 of file NetInfo.h.
bool forest::NetInfo::read | ( | istream & | in) |
Reads a network topology file and initializes the NetInfo data structure.
Example of NetInfo file format.
router(salt,1.1000,(40,-50),(1.1-1.200),
[ 1, 193.168.3.4, 1, (50000,30000,25000,15000) ], [ 2, 193.168.3.5, 2-30, (50000,30000,25000,15000) ] )
leaf(netMgr,controller,192.168.1.3,2.900,(40,-50))
link(netMgr,salt.2,1000,(3000,3000,5000,5000)) ; # semicolon to terminate
in | is an open input stream from which topology file is read |
Definition at line 195 of file NetInfo.cpp.
Read an address range pair.
in | is an open input stream |
range | is a reference to a pair of Forest addresses in which result is returned |
Definition at line 382 of file NetInfo.cpp.
|
private |
Read a router interface description from an input stream.
in | is an open input stream |
ifaces | points to an array of IfInfo structs used to return the interface definition; this interface is written at the position specified by its interface number |
errMsg | is a reference to a string used for returning an error message |
Definition at line 419 of file NetInfo.cpp.
|
private |
Read a leaf node description from an input stream.
Expects the next nonblank input character to be the opening parentheis of the leaf node description.
in | is an open input stream |
leaf | is a reference to a LeafNodeInfo struct used to return result |
errMsg | is a reference to a string used for returning an error message |
Definition at line 495 of file NetInfo.cpp.
|
private |
Read a link description from an input stream.
Expects the next nonblank input character to be the opening parentheis of the link description.
in | is an open input stream |
link | is a reference to a LinkDesc struct used to return the result |
errMsg | is a reference to a string used for returning an error message |
Definition at line 542 of file NetInfo.cpp.
|
private |
Read a link endpoint.
in | is an open input stream |
name | is a reference to a string used to return the endpoint name |
num | is a reference to an int used to return the local link number |
Definition at line 584 of file NetInfo.cpp.
|
private |
Read a (latitude,longitude) pair.
in | is an open input stream |
loc | is a reference to a pair of ints in which result is returned |
Definition at line 367 of file NetInfo.cpp.
|
private |
Read a rate specification.
in | is an open input stream |
rs | is a reference to a RateSpec in which result is returned |
Definition at line 395 of file NetInfo.cpp.
|
private |
Read a router description from an input stream.
Expects the next nonblank input character to be the opening parentheis of the router description.
in | is an open input stream |
rtr | is a reference to a RtrNodeInfo struct used to return the result |
ifaces | points to an array of IfInfo structs used to return the interface definitions |
errMsg | is a reference to a string used for returning an error message |
Definition at line 319 of file NetInfo.cpp.
|
private |
Create a string representation of a router.
rtr | is a node number for a router |
s | is a reference to a string in which result is returned |
Definition at line 965 of file NetInfo.cpp.
|
inline |
|
inline |
Set the RateSpec for a router interface.
r | is the node number of a router in the network |
iface | is an interface number for r |
rs | is a reference to a RateSpec |
r | is the node number of the router |
iface | is the interface number |
links | is a reference to a pair of link numbers that define range |
Definition at line 648 of file NetInfo.h.
|
inline |
Set the IP address of a router interface.
r | is the node number of a router |
iface | is the interface number |
port | is the port number for the interface |
Definition at line 673 of file NetInfo.h.
|
inline |
|
inline |
Set the range of assignable client addresses for this router.
r | is the node number of the router |
adr | is the forest address that defines the start of the range |
Definition at line 622 of file NetInfo.h.
|
inline |
|
inline |
Set the local link number used by the left endpoint of a link.
Each router in a Forest network refers to links using local link numbers.
lnk | is a "global" link number |
loc | is the local link number to be used by the left endpoint of lnk |
Definition at line 850 of file NetInfo.h.
|
inline |
Set the RateSpec for a link.
lnk | is a link number |
rs | is the new RateSpec for the link |
lnk | is a link number |
rs | is a RateSpec inline bool NetInfo::setAvailRates(int lnk, RateSpec& rs) { if (!validLink(lnk)) return false; link[lnk].availRates = rs; return true; }Set the length of a link. |
lnk | is a "global" link number |
len | is the new length |
Definition at line 905 of file NetInfo.h.
|
inline |
|
inline |
Set the location of a node in the Forest network.
n | is a node number |
loc | is a reference to a pair of doubles which defines the new latitude and longitude |
Definition at line 392 of file NetInfo.h.
|
inline |
|
inline |
|
inline |
Set the local link number used by the right endpoint of a link.
Each router in a Forest network refers to links using local link numbers.
lnk | is a "global" link number |
loc | is the local link number to be used by the right endpoint of lnk |
Definition at line 862 of file NetInfo.h.
|
inline |
string & forest::NetInfo::toString | ( | ) | const |
Create a string representation of the NetInfo object.
s | is a reference to a string in which result is returned |
Definition at line 932 of file NetInfo.cpp.
|
inline |
Check to see if a given router interface is valid.
r | is the node number of a router |
iface | is an integer interface n umber |
Definition at line 480 of file NetInfo.h.
|
inline |
|
inline |
|
private |
|
private |