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

This class provides a common substrate used by various controllers. More...

#include <Substrate.h>

Collaboration diagram for forest::Substrate:

Classes

struct  QueuePair
 
struct  ThreadInfo
 

Public Member Functions

 Substrate (fAdr_t, ipa_t, fAdr_t, ipa_t, ipp_t, uint64_t, int, void *(*)(void *), int, int, PacketStoreTs *, Logger *)
 
bool init ()
 
bool run (int)
 Run forever, or until time expires. More...
 
void setRtrPort (ipp_t)
 
void setNonce (uint64_t)
 
void setRtrReady (bool)
 

Private Member Functions

void inbound (pktx)
 Send an incoming packet to a thread, possibly assigning new one. More...
 
void outbound (pktx, int)
 Handle an outbound packet from one of the worker threads. More...
 
void sendToForest (int)
 Send packet to Forest network. More...
 
int recvFromForest ()
 Check for next packet from the Forest network. More...
 
bool connect ()
 Send initial connect packet to forest router Uses comtree 1, which is for user signalling.
 
bool disconnect ()
 Send final disconnect packet to forest router.
 

Private Attributes

fAdr_t myAdr
 Forest address of self.
 
ipa_t myIp
 address of interface to use
 
fAdr_t rtrAdr
 Forest address of router.
 
ipa_t rtrIp
 IP address for forest router.
 
ipp_t rtrPort
 port used by forest router
 
uint64_t nonce
 nonce used when connecting
 
bool rtrReady
 true when router is ready to go
 
uint64_t seqNum
 for outgoing requests
 
uint64_t now
 current time
 
int threadCount
 number of threads in pool
 
int dgSock
 datagram socket to Forest router
 
int dgPort
 port number used for datagram socket
 
int listenSock
 listening stream socket
 
int listenPort
 port number for listening socket
 
PacketStoreTsps
 pointer to packet store
 
Loggerlogger
 error message logger
 
ThreadInfopool
 pool of "worker threads"
 
UiSetPair * threads
 idle/active thread indexes
 
void *(* handler )(void *)
 pointer to handler for worker threads
 
IdMap * inReqMap
 maps srcAdr and sequence # of an inbound More...
 
IdMap * outReqMap
 maps sequence number of an outbound More...
 

Detailed Description

This class provides a common substrate used by various controllers.

It manages a pool of threads that respond to control packets, creating a new thread whenever a new request comes in and routing control packet replies back to the thread that sent the request.

Definition at line 29 of file Substrate.h.

Member Function Documentation

void forest::Substrate::inbound ( pktx  px)
private

Send an incoming packet to a thread, possibly assigning new one.

Parameters
pxis a packet index

Definition at line 141 of file Substrate.cpp.

Here is the call graph for this function:

void forest::Substrate::outbound ( pktx  px,
int  t 
)
private

Handle an outbound packet from one of the worker threads.

Parameters
pxis a packet index
tis the thread index (in the tread pool)

Definition at line 181 of file Substrate.cpp.

Here is the call graph for this function:

pktx forest::Substrate::recvFromForest ( )
private

Check for next packet from the Forest network.

The sender's IP and port are placed in the packet's tunnel fields.

Returns
next packet or 0, if no report has been received.

Definition at line 229 of file Substrate.cpp.

Here is the call graph for this function:

bool forest::Substrate::run ( int  finTimeSec)

Run forever, or until time expires.

Parameters
finTimeis the number of seconds to run before halting; if zero, run forever

Definition at line 74 of file Substrate.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void forest::Substrate::sendToForest ( int  px)
private

Send packet to Forest network.

If the packet has a zero destination address, it is sent to the (ip,port) specified in the packet's tunnel fields. Otherwise, it is sent to the router.

Definition at line 254 of file Substrate.cpp.

Here is the call graph for this function:

Member Data Documentation

IdMap* forest::Substrate::inReqMap
private

maps srcAdr and sequence # of an inbound

request to index of assigned thread

Definition at line 75 of file Substrate.h.

IdMap* forest::Substrate::outReqMap
private

maps sequence number of an outbound

request to index of thread that sent it

Definition at line 77 of file Substrate.h.


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