forest-net
an overlay networks for large-scale virtual worlds
|
Monitor observes status reports sent by Avatars in a virtual world and reports them to a remote client that implements a graphical display of the moving Avatars. More...
#include <Monitor.h>
Public Member Functions | |
Monitor (ipa_t, ipa_t, int) | |
bool | init (const string &, const string &) |
open and setup socket More... | |
void | run (uint32_t) |
run avatar More... | |
Private Types | |
enum | STATE { IDLE, JOINING, LEAVING } |
Private Member Functions | |
bool | login (const string &, const string &) |
Send username and password to the Client manager, and receive. More... | |
int | groupNum (int, int) |
Return the multicast group number associated with a virtual world position. 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. | |
comt_t | check4command () |
Check for a new command from remote display program. More... | |
void | sendToRouter (int) |
Send packet to Forest router (connect, disconnect, sub_unsub). | |
int | receiveFromRouter () |
Check for next Avatar report packet and return it if there is one. More... | |
void | forwardReport (int, int) |
If the given packet is a status report and there is a remote display connected, then forward the status info to the remote display. More... | |
void | startComtSwitch (comt_t, uint32_t) |
Start the process of switching to a new comtree. More... | |
bool | completeComtSwitch (pktx, uint32_t) |
Attempt to complete the process of switching to a new comtree. More... | |
void | send2comtCtl (CtlPkt::CpType, bool=false) |
Send join or leave packet packet to the ComtreeController. More... | |
void | switchComtrees (int) |
Switch from the current comtree to newComt. More... | |
void | updateSubs () |
Update subscriptions without changing comtrees. More... | |
void | subscribeAll () |
Subscribe to all multicasts for regions in our current view, that we're not already subscribed to. | |
void | unsubscribeAll () |
Unsubscribe from all multicasts that we're currently subscribed to. | |
void | subscribe (list< int > &) |
Subscribe to a list of multicast groups. More... | |
void | unsubscribe (list< int > &) |
Unsubscribe from a list of multicast groups. More... | |
Private Attributes | |
int | worldSize |
of squares in x and y directions | |
fAdr_t | myAdr |
forest address of host | |
ipa_t | myIp |
IP address to bind to sockets. | |
fAdr_t | rtrAdr |
forest address of router | |
ipa_t | rtrIp |
IP address of router. | |
ipp_t | rtrPort |
port number of router | |
ipa_t | cmIp |
IP address of client manager. | |
fAdr_t | ccAdr |
address of ComtCtl | |
uint64_t | nonce |
used when connecting | |
int | dgSock |
datagram socket number | |
int | listenSock |
listening socket for remote GUI | |
int | connSock |
connection socket | |
int | cornerX |
lower-left corner of current view | |
int | cornerY |
int | viewSize |
size of current view | |
set< int > * | mySubs |
current multicast subscriptions | |
PacketStore * | ps |
pointer to packet store | |
STATE | switchState |
current state | |
uint32_t | switchTimer |
time last signalling packet sent | |
int | switchCnt |
number of attempts so far | |
comt_t | nextComt |
comtree we're switching to | |
comt_t | comt |
current comtree number | |
int | seqNum |
sequence number of control packet | |
Static Private Attributes | |
static const short | MON_PORT = 30124 |
port# for connection to GUI | |
static const int | NUMITEMS = 9 |
distinct items in status packet | |
static const int | GRID = 10000 |
xy extent of one grid square | |
static const int | MAX_AVATARS = 1000 |
max # of avatars to monitor | |
static const int | MAX_WORLD = 30000 |
max extent of virtual world | |
static const int | MAX_VIEW = 1000 |
max extent of view | |
static const int | UPDATE_PERIOD = 50 |
ms between status updates | |
static const uint32_t | SWITCH_TIMEOUT = 500000 |
500 ms timeout | |
static const bool | RETRY = true |
flag used to signal retry | |
Monitor observes status reports sent by Avatars in a virtual world and reports them to a remote client that implements a graphical display of the moving Avatars.
|
private |
Check for a new command from remote display program.
Check to see if the remote display has sent a comand and respond appropriately. Commands take the form of pairs (c,i) where c is a character that identifies a specific command, and i is an integer that provides an optional parameter value for the command. The current commands are defined below.
x set x coordinate of lower left corner of current view to paramater value y set y coordinate of lower left corner of current view to paramater value v set view size to value specified by paramater value c switch to comtree identified by parameter value
For the aswd commands, there are corresponding ASWD commands that shift by a larger amount. Also, there are OP commands that half/double the window size.
Note that the integer parameter must be sent even when the command doesn't use it
Definition at line 380 of file Monitor.cpp.
|
private |
Attempt to complete the process of switching to a new comtree.
This involves completing signalling interactions with ComtCtl, including re-sending signalling packets when timeouts occur.
p | is a packet number, or 0 if the caller just wants to check for a timeout |
now | is the current time |
Definition at line 248 of file Monitor.cpp.
|
private |
If the given packet is a status report and there is a remote display connected, then forward the status info to the remote display.
Filter out packets that are not in our current "view".
p | is the packet number for a packet from the Forest network |
now | is the current time |
Definition at line 590 of file Monitor.cpp.
|
private |
Return the multicast group number associated with a virtual world position.
x1 | is x coordinate |
y1 | is y coordinate |
Definition at line 434 of file Monitor.cpp.
bool forest::Monitor::init | ( | const string & | uname, |
const string & | pword | ||
) |
open and setup socket
Initialize sockets and open log file for writing.
Definition at line 82 of file Monitor.cpp.
|
private |
Send username and password to the Client manager, and receive.
cmIpAdr | is the IP address of the client manager |
uname | is the username to log in with |
pword | is the password to log in with |
Definition at line 105 of file Monitor.cpp.
|
private |
Check for next Avatar report packet and return it if there is one.
Definition at line 345 of file Monitor.cpp.
void forest::Monitor::run | ( | uint32_t | finishTime) |
run avatar
Run the monitor, stopping after finishTime Operate on a cycle with a period of UPDATE_PERIOD milliseconds, Each cycle, process all the packets that came in during that period and store results.
Print a record of all avatar's status, once per second.
Definition at line 174 of file Monitor.cpp.
|
private |
Send join or leave packet packet to the ComtreeController.
joinLeave | is either CLIENT_JOIN_COMTREE or CLIENT_LEAVE_COMTREE, depending on whether we want to join or leave the comtree |
Definition at line 311 of file Monitor.cpp.
|
private |
Start the process of switching to a new comtree.
Unsubscribe to the current comtree and leave send signalling message to leave the current comtree.
newComt | is the number of the comtree we're switching to |
now | is the current time |
Definition at line 222 of file Monitor.cpp.
|
private |
Subscribe to a list of multicast groups.
glist | is a reference to a list of multicast group numbers. |
Definition at line 479 of file Monitor.cpp.
|
private |
Switch from the current comtree to newComt.
This requires unsubscribing from all current multicasts and subscribing to multicasts in new comtree. Currently, Monitor is statically configured as a member of all comtrees.
Definition at line 443 of file Monitor.cpp.
|
private |
Unsubscribe from a list of multicast groups.
glist | is a reference to a list of multicast group numbers. |
Definition at line 514 of file Monitor.cpp.
|
private |
Update subscriptions without changing comtrees.
Unsubscribe to all multicasts that are not in current view, then subscribe to all missing multicasts that are in current view.
Definition at line 550 of file Monitor.cpp.