Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

NetworkLayer Class Reference

#include <NetworkLayer.h>

Inheritance diagram for NetworkLayer::

BasicObject ListenerInterface PacketHandlerInterface List of all members.

Public Methods

 NetworkLayer ()
 Default constructor. More...

 NetworkLayer (NetworkLayerListener *networkLayerListener)
 Constructor you normally use. More...

virtual ~NetworkLayer ()
LinkLayerInterfacegetLli ()
 Return the LinkLayerInterface underneath the network layer. More...

LiveBroadcastTablegetLiveBroadcastTable ()
 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

VirtualCircuitTablem_virtualCircuitTable
 The VC routing table. More...

LinkLayerInterfacem_linkLayerInterface
 Pointer to the link layer. More...

LiveBroadcastTablem_liveBroadcastTable
 Where broadcasts are stored. More...

NetworkLayerListenerm_networkLayerListener
 A pointer to an object that can process data packets. More...

PriorityPacketQueuem_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

Constructor & Destructor Documentation

NetworkLayer::NetworkLayer
 

Default constructor.

Definition at line 27 of file NetworkLayer.cpp.

NetworkLayer::NetworkLayer NetworkLayerListener * networkLayerListener
 

Constructor you normally use.

Definition at line 67 of file NetworkLayer.cpp.

NetworkLayer::~NetworkLayer [virtual]
 

Definition at line 104 of file NetworkLayer.cpp.


Member Function Documentation

void NetworkLayer::connectForward Node * fromNode,
ConnectionPacket * packet
[private]
 

Forwards the connect packet based on all the options and other circumstances.

Definition at line 664 of file NetworkLayer.cpp.

Referenced by handleConnectPacket().

void NetworkLayer::connectTerminate Node * fromNode,
ConnectionPacket * packet
[private]
 

Become the terminating peer for a VC.

Definition at line 689 of file NetworkLayer.cpp.

Referenced by handleConnectPacket().

void NetworkLayer::destroyVc int vcn
 

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().

void NetworkLayer::destroyVcsTo Node * node
 

Destroy all virtual circuits to or from the specified node.

Definition at line 234 of file NetworkLayer.cpp.

Referenced by handleEvent().

void NetworkLayer::discover
 

Send a discovery request to all neighbors.

Definition at line 527 of file NetworkLayer.cpp.

Referenced by discoveryThreadImpl().

void * NetworkLayer::discoveryThread void * arg [static, private]
 

A wrapper around discoveryThreadImpl().

Definition at line 491 of file NetworkLayer.cpp.

void NetworkLayer::discoveryThreadImpl [private]
 

This is a thread which will continually try to discover more neighbor nodes.

Definition at line 504 of file NetworkLayer.cpp.

Referenced by discoveryThread().

bool NetworkLayer::forwardPacket Node * fromNode,
NpPacket * packet
[private]
 

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.

Parameters:
fromNode   Where the packet came from.
packet   The packet to forward.
Returns:
true if it forwarded the packet, false if the send failed.

Definition at line 547 of file NetworkLayer.cpp.

Referenced by destroyVc(), destroyVcsTo(), handleDataPacket(), and handleFinPacket().

LiveBroadcastTable * NetworkLayer::getLiveBroadcastTable
 

Return the LiveBroadcastTable within the network layer.

You shouldnt be using this except for debugging purposes.

Definition at line 147 of file NetworkLayer.cpp.

LinkLayerInterface * NetworkLayer::getLli
 

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().

void NetworkLayer::handleBroadcastPacket Node * fromNode,
ConnectionPacket * packet
[private]
 

void NetworkLayer::handleConnectPacket Node * fromNode,
NpPacket * packet
[private]
 

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().

void NetworkLayer::handleControlPacket Node * fromNode,
NpPacket * packet
[private]
 

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().

void NetworkLayer::handleDataPacket Node * fromNode,
NpPacket * packet
[private]
 

Forwards the data packet if it isnt for us.

Definition at line 825 of file NetworkLayer.cpp.

Referenced by processPacketsImpl().

void NetworkLayer::handleDiscoveryPacket Node * fromNode,
NpPacket * packet
[private]
 

Another node is requesting that we divulge who we are.

Definition at line 859 of file NetworkLayer.cpp.

Referenced by handleControlPacket().

void NetworkLayer::handleEstablishedPacket Node * fromNode,
NpPacket * packet
[private]
 

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().

void NetworkLayer::handleEvent ObservableInterface * observed,
int eventType,
void * object
[virtual]
 

Process events from nodes we are listening to.

Reimplemented from ListenerInterface.

Definition at line 371 of file NetworkLayer.cpp.

void NetworkLayer::handleFinPacket Node * fromNode,
NpPacket * packet
[private]
 

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().

void NetworkLayer::handleImHerePacket Node * fromNode,
NpPacket * packet
[private]
 

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().

void NetworkLayer::handlePacket Node * fromNode,
NpPacket * packet
[virtual]
 

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.

void NetworkLayer::handlePingPacket Node * fromNode,
NpPacket * packet
[private]
 

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().

void NetworkLayer::handlePongPacket Node * fromNode,
NpPacket * packet
[private]
 

We got the response to our ping.

Definition at line 996 of file NetworkLayer.cpp.

Referenced by handleControlPacket().

bool NetworkLayer::hasVc int vcn
 

Returns:
true if (selfNode, VCN) is in the virtual circuit table.

Definition at line 276 of file NetworkLayer.cpp.

Referenced by ServiceTable::sendData().

int NetworkLayer::isThisPacketForMe Node * fromNode,
NpPacket * packet
[private]
 

Determine if the given packet is destined for the local node.

Returns:
1 if the packet is for me 0 if the packet is not for me -1 if the entry does not exist in the routing table

Definition at line 292 of file NetworkLayer.cpp.

Referenced by handleDataPacket(), and handleFinPacket().

int NetworkLayer::makeVc int connectionDescriptor
 

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.

Returns:
NL_ERROR means attempt to connect failed, NL_UNREACHABLE means the Link Layer is not connected to any nodes, NL_OK if connection packet sent successfully

Definition at line 163 of file NetworkLayer.cpp.

Referenced by ServiceTable::connectService(), and ServiceTable::repairConnectionImpl().

void NetworkLayer::ping
 

Ping all of your neighbors.

Definition at line 479 of file NetworkLayer.cpp.

Referenced by pingThreadImpl().

void * NetworkLayer::pingThread void * arg [static, private]
 

A wrapper around pingThreadImpl().

Definition at line 444 of file NetworkLayer.cpp.

void NetworkLayer::pingThreadImpl [private]
 

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().

void * NetworkLayer::processPackets void * arg [static, private]
 

A wrapper around processPacketsImpl.

Definition at line 397 of file NetworkLayer.cpp.

void NetworkLayer::processPacketsImpl [private]
 

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().

int NetworkLayer::send TpPacket * packet,
int vcn
 

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().

void NetworkLayer::signalBreak int connectionDescriptor
 

Definition at line 1014 of file NetworkLayer.cpp.

void NetworkLayer::toStream std::ostream & out [virtual]
 

Print the current state of this network layer to the output stream provided.

Reimplemented from BasicObject.

Definition at line 1026 of file NetworkLayer.cpp.


Member Data Documentation

TimeValue NetworkLayer::m_beginPingTime [private]
 

Time that we sent out the ping.

Definition at line 112 of file NetworkLayer.h.

pthread_t NetworkLayer::m_discoveryThreadId [private]
 

Thread ID for the discovery thread.

Definition at line 118 of file NetworkLayer.h.

Condition NetworkLayer::m_discoveryThreadInterrupt [private]
 

Used to signal for the discovery thread to die.

Definition at line 121 of file NetworkLayer.h.

LinkLayerInterface* NetworkLayer::m_linkLayerInterface [private]
 

Pointer to the link layer.

Definition at line 94 of file NetworkLayer.h.

LiveBroadcastTable* NetworkLayer::m_liveBroadcastTable [private]
 

Where broadcasts are stored.

Definition at line 97 of file NetworkLayer.h.

NetworkLayerListener* NetworkLayer::m_networkLayerListener [private]
 

A pointer to an object that can process data packets.

Definition at line 100 of file NetworkLayer.h.

PriorityPacketQueue* NetworkLayer::m_packetQueue [private]
 

All packets from the Link Layer are placed on this queue.

Definition at line 103 of file NetworkLayer.h.

pthread_t NetworkLayer::m_pingThreadId [private]
 

Thread ID for the ping thread.

Definition at line 109 of file NetworkLayer.h.

Condition NetworkLayer::m_pingThreadInterrupt [private]
 

Used to signal for the ping thread to die.

Definition at line 115 of file NetworkLayer.h.

pthread_t NetworkLayer::m_processPacketThreadId [private]
 

Thread ID for the process packet thread.

Definition at line 106 of file NetworkLayer.h.

TRanrotBGenerator NetworkLayer::m_randomNumberGenerator [private]
 

Definition at line 123 of file NetworkLayer.h.

VirtualCircuitTable* NetworkLayer::m_virtualCircuitTable [private]
 

The VC routing table.

Definition at line 91 of file NetworkLayer.h.


The documentation for this class was generated from the following files:
Generated at Thu Jul 11 13:31:57 2002 for Peekabooty by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001