#include <NetworkLayer.h>
Inheritance diagram for NetworkLayer::
Public Methods | |
NetworkLayer () | |
Default constructor. More... | |
NetworkLayer (NetworkLayerListener *networkLayerListener) | |
Constructor you normally use. More... | |
virtual | ~NetworkLayer () |
LinkLayerInterface * | getLli () |
Return the LinkLayerInterface underneath the network layer. More... | |
LiveBroadcastTable * | getLiveBroadcastTable () |
Return the LiveBroadcastTable within the network layer. More... | |
int | makeVc (int connectionDescriptor) |
Attempts to create a virtual circuit through the network. More... | |
bool | hasVc (int vcn) |
void | ping () |
Ping all of your neighbors. More... | |
void | discover () |
Send a discovery request to all neighbors. More... | |
void | destroyVc (int vcn) |
Destroy a virtual circuit. More... | |
int | send (TpPacket *packet, int vcn) |
Sends the Transport Layer packet to the specified VCN (connection descriptor). More... | |
void | signalBreak (int connectionDesc) |
void | handlePacket (Node *fromNode, NpPacket *packet) |
This function is called from LLI whenever it receives a packet. More... | |
void | handleEvent (ObservableInterface *observed, int eventType, void *object) |
Process events from nodes we are listening to. More... | |
void | destroyVcsTo (Node *node) |
Destroy all virtual circuits to or from the specified node. More... | |
virtual void | toStream (std::ostream &out) |
Print the current state of this network layer to the output stream provided. More... | |
Private Methods | |
void | processPacketsImpl () |
This is a thread which will continually process packets while there are still packets to process. More... | |
void | pingThreadImpl () |
This is a thread which will continually ping its neighbors at random intervals in order to determine average RTTs. More... | |
void | discoveryThreadImpl () |
This is a thread which will continually try to discover more neighbor nodes. More... | |
bool | forwardPacket (Node *fromNode, NpPacket *packet) |
This is only for NON-CONNECTION packets. More... | |
void | handleControlPacket (Node *fromNode, NpPacket *packet) |
This function deals with all control packets that come in. More... | |
void | handleBroadcastPacket (Node *fromNode, ConnectionPacket *packet) |
void | handleConnectPacket (Node *fromNode, NpPacket *packet) |
Decides what to do with a connect packet. More... | |
void | handleEstablishedPacket (Node *fromNode, NpPacket *packet) |
Established Packet Processing. More... | |
void | handleFinPacket (Node *fromNode, NpPacket *packet) |
FIN packet processing. More... | |
void | handleDataPacket (Node *fromNode, NpPacket *packet) |
Forwards the data packet if it isnt for us. More... | |
void | handleDiscoveryPacket (Node *fromNode, NpPacket *packet) |
Another node is requesting that we divulge who we are. More... | |
void | handleImHerePacket (Node *fromNode, NpPacket *packet) |
The response to a DISCOVERY request. More... | |
void | handlePingPacket (Node *fromNode, NpPacket *packet) |
Our own version of ping. More... | |
void | handlePongPacket (Node *fromNode, NpPacket *packet) |
We got the response to our ping. More... | |
int | isThisPacketForMe (Node *fromNode, NpPacket *packet) |
Determine if the given packet is destined for the local node. More... | |
void | connectForward (Node *fromNode, ConnectionPacket *packet) |
Forwards the connect packet based on all the options and other circumstances. More... | |
void | connectTerminate (Node *fromNode, ConnectionPacket *packet) |
Become the terminating peer for a VC. More... | |
Static Private Methods | |
void * | processPackets (void *arg) |
A wrapper around processPacketsImpl. More... | |
void * | pingThread (void *) |
A wrapper around pingThreadImpl(). More... | |
void * | discoveryThread (void *arg) |
A wrapper around discoveryThreadImpl(). More... | |
Private Attributes | |
VirtualCircuitTable * | m_virtualCircuitTable |
The VC routing table. More... | |
LinkLayerInterface * | m_linkLayerInterface |
Pointer to the link layer. More... | |
LiveBroadcastTable * | m_liveBroadcastTable |
Where broadcasts are stored. More... | |
NetworkLayerListener * | m_networkLayerListener |
A pointer to an object that can process data packets. More... | |
PriorityPacketQueue * | m_packetQueue |
All packets from the Link Layer are placed on this queue. More... | |
pthread_t | m_processPacketThreadId |
Thread ID for the process packet thread. More... | |
pthread_t | m_pingThreadId |
Thread ID for the ping thread. More... | |
TimeValue | m_beginPingTime |
Time that we sent out the ping. More... | |
Condition | m_pingThreadInterrupt |
Used to signal for the ping thread to die. More... | |
pthread_t | m_discoveryThreadId |
Thread ID for the discovery thread. More... | |
Condition | m_discoveryThreadInterrupt |
Used to signal for the discovery thread to die. More... | |
TRanrotBGenerator | m_randomNumberGenerator |
|
Default constructor.
Definition at line 27 of file NetworkLayer.cpp. |
|
Constructor you normally use.
Definition at line 67 of file NetworkLayer.cpp. |
|
Definition at line 104 of file NetworkLayer.cpp. |
|
Forwards the connect packet based on all the options and other circumstances.
Definition at line 664 of file NetworkLayer.cpp. Referenced by handleConnectPacket().
|
|
Become the terminating peer for a VC.
Definition at line 689 of file NetworkLayer.cpp. Referenced by handleConnectPacket().
|
|
Destroy a virtual circuit. You can only destroy a VC if you are originator or terminator of a VC. Definition at line 208 of file NetworkLayer.cpp. Referenced by ServiceTable::disconnectService().
|
|
Destroy all virtual circuits to or from the specified node.
Definition at line 234 of file NetworkLayer.cpp. Referenced by handleEvent().
|
|
Send a discovery request to all neighbors.
Definition at line 527 of file NetworkLayer.cpp. Referenced by discoveryThreadImpl().
|
|
A wrapper around discoveryThreadImpl().
Definition at line 491 of file NetworkLayer.cpp. |
|
This is a thread which will continually try to discover more neighbor nodes.
Definition at line 504 of file NetworkLayer.cpp. Referenced by discoveryThread().
|
|
This is only for NON-CONNECTION packets. This function looks up the next hop for this packet, sets the VCN in the packet appropriately, and then sends it to its destination.
Definition at line 547 of file NetworkLayer.cpp. Referenced by destroyVc(), destroyVcsTo(), handleDataPacket(), and handleFinPacket().
|
|
Return the LiveBroadcastTable within the network layer. You shouldnt be using this except for debugging purposes. Definition at line 147 of file NetworkLayer.cpp. |
|
Return the LinkLayerInterface underneath the network layer. You shouldnt be using this except for debugging purposes. Definition at line 137 of file NetworkLayer.cpp. Referenced by ServiceTable::connectService(), SummaryScreenCommand::getHtmlInterface(), ConnectionManagerCommand::getHtmlInterface(), VisualizerFrame::getInitialNeighborNodes(), NodeManagerCommand::run(), ConnectionManagerCommand::run(), BasicConfigurationCommand::run(), and VisualizerListener::setFrame().
|
|
|
|
Decides what to do with a connect packet. It can either forward the packet or decide to become the TP. If it forwards the packet, it randomly chooses a neighbor (except the one it received from) and sends it there. If it becomes the TP, then it transforms the packet to an ESTABLISHED packet and sends it back where it came from. Definition at line 625 of file NetworkLayer.cpp. Referenced by handleControlPacket().
|
|
This function deals with all control packets that come in. It calls the appropriate function for the packet type. Definition at line 576 of file NetworkLayer.cpp. Referenced by processPacketsImpl().
|
|
Forwards the data packet if it isnt for us.
Definition at line 825 of file NetworkLayer.cpp. Referenced by processPacketsImpl().
|
|
Another node is requesting that we divulge who we are.
Definition at line 859 of file NetworkLayer.cpp. Referenced by handleControlPacket().
|
|
Established Packet Processing. Very similiar to CONNECT packet processing. If the packet is not for me, add the entry to the VC table and forward it to the next hop. If it is for me, add the entry to the VC table and signal the transport layer that the circuit is complete. Definition at line 726 of file NetworkLayer.cpp. Referenced by handleControlPacket().
|
|
Process events from nodes we are listening to.
Reimplemented from ListenerInterface. Definition at line 371 of file NetworkLayer.cpp. |
|
FIN packet processing. A FIN packet causes the VC entries for BOTH directions of the VC (in the table) to be removed. The FIN packet is sent down the opposite link from which it was received. If you are an OP or a TP, you do not forward the packet. If you are the originator of a FIN packet, you must send the FIN packet in both directions. (This is not handled in this function). Definition at line 778 of file NetworkLayer.cpp. Referenced by handleControlPacket().
|
|
The response to a DISCOVERY request. Add the node info to our catcher list, and forward the packet on to the node we received the discovery request; unless, of course, we were the originator of the request. Definition at line 931 of file NetworkLayer.cpp. Referenced by handleControlPacket().
|
|
This function is called from LLI whenever it receives a packet. It puts the packets on the NetworkLayer queue to be processed. Reimplemented from PacketHandlerInterface. Definition at line 359 of file NetworkLayer.cpp. |
|
Our own version of ping. We need to do this because we may not actually be able to ping the node through normal means. Definition at line 977 of file NetworkLayer.cpp. Referenced by handleControlPacket().
|
|
We got the response to our ping.
Definition at line 996 of file NetworkLayer.cpp. Referenced by handleControlPacket().
|
|
Definition at line 276 of file NetworkLayer.cpp. Referenced by ServiceTable::sendData().
|
|
Determine if the given packet is destined for the local node.
Definition at line 292 of file NetworkLayer.cpp. Referenced by handleDataPacket(), and handleFinPacket().
|
|
Attempts to create a virtual circuit through the network. It does not do any retries or anything like that. That functionality is for the transport layer. Create a connection packet, then pick a random neighbor and send the packet.
Definition at line 163 of file NetworkLayer.cpp. Referenced by ServiceTable::connectService(), and ServiceTable::repairConnectionImpl().
|
|
Ping all of your neighbors.
Definition at line 479 of file NetworkLayer.cpp. Referenced by pingThreadImpl().
|
|
A wrapper around pingThreadImpl().
Definition at line 444 of file NetworkLayer.cpp. |
|
This is a thread which will continually ping its neighbors at random intervals in order to determine average RTTs.
Definition at line 457 of file NetworkLayer.cpp. Referenced by pingThread().
|
|
A wrapper around processPacketsImpl.
Definition at line 397 of file NetworkLayer.cpp. |
|
This is a thread which will continually process packets while there are still packets to process. It always tries to send control packets first. Once it has sent all packets available to it, it blocks and waits to be signalled. Definition at line 412 of file NetworkLayer.cpp. Referenced by processPackets().
|
|
Sends the Transport Layer packet to the specified VCN (connection descriptor). Returns how many bytes were sent, or an error code which is < 0. Definition at line 314 of file NetworkLayer.cpp. Referenced by ServiceTable::sendDataPacket().
|
|
Definition at line 1014 of file NetworkLayer.cpp. |
|
Print the current state of this network layer to the output stream provided.
Reimplemented from BasicObject. Definition at line 1026 of file NetworkLayer.cpp. |
|
Time that we sent out the ping.
Definition at line 112 of file NetworkLayer.h. |
|
Thread ID for the discovery thread.
Definition at line 118 of file NetworkLayer.h. |
|
Used to signal for the discovery thread to die.
Definition at line 121 of file NetworkLayer.h. |
|
Pointer to the link layer.
Definition at line 94 of file NetworkLayer.h. |
|
Where broadcasts are stored.
Definition at line 97 of file NetworkLayer.h. |
|
A pointer to an object that can process data packets.
Definition at line 100 of file NetworkLayer.h. |
|
All packets from the Link Layer are placed on this queue.
Definition at line 103 of file NetworkLayer.h. |
|
Thread ID for the ping thread.
Definition at line 109 of file NetworkLayer.h. |
|
Used to signal for the ping thread to die.
Definition at line 115 of file NetworkLayer.h. |
|
Thread ID for the process packet thread.
Definition at line 106 of file NetworkLayer.h. |
|
Definition at line 123 of file NetworkLayer.h. |
|
The VC routing table.
Definition at line 91 of file NetworkLayer.h. |