forest-net
an overlay networks for large-scale virtual worlds
|
This class provides a common substrate used by various controllers. More...
#include <Substrate.h>
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 | |
PacketStoreTs * | ps |
pointer to packet store | |
Logger * | logger |
error message logger | |
ThreadInfo * | pool |
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... | |
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.
|
private |
Send an incoming packet to a thread, possibly assigning new one.
px | is a packet index |
Definition at line 141 of file Substrate.cpp.
|
private |
Handle an outbound packet from one of the worker threads.
px | is a packet index |
t | is the thread index (in the tread pool) |
Definition at line 181 of file Substrate.cpp.
|
private |
Check for next packet from the Forest network.
The sender's IP and port are placed in the packet's tunnel fields.
Definition at line 229 of file Substrate.cpp.
bool forest::Substrate::run | ( | int | finTimeSec) |
Run forever, or until time expires.
finTime | is the number of seconds to run before halting; if zero, run forever |
Definition at line 74 of file Substrate.cpp.
|
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.
|
private |
maps srcAdr and sequence # of an inbound
request to index of assigned thread
Definition at line 75 of file Substrate.h.
|
private |
maps sequence number of an outbound
request to index of thread that sent it
Definition at line 77 of file Substrate.h.