spoon :: routing :: MeshRouter :: MeshRouter :: Class MeshRouter
[hide private]
[frames] | no frames]

Class MeshRouter

source code

object --+
         |
        MeshRouter

This class handles LMTYPE_NETWORK messages and LMTYPE_NETWORK_PROTO messages. LMTYPE_NETWORK_PROTO is handled as a routing update, and LMTYPE_NETWORK will be handled as network traffic to be dealt with or routed.

If there is a SingletonMessaging instance already created (e.g. through the use of the acceptMsg decorator) and messaging is None

Instance Methods [hide private]
  __init__(self, hub, messaging=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
  addTransport(self, t, nodeId)
Handles the routing protocol initilization.
  removeTransport(self, t)
Removes the transport from the network.
  handleUpdate(self, t, update, localUpdate=None)
Handles a routing table update, builds the update message and sends it out to all except the src of the update.
  handleLinkMessage(self, t, lm)
Called by the SpoonTransportThread when a link message has been received for one of our LMTYPEs.
  handleNetworkTraffic(self, t, obj)
  sendNetMsg(self, dst, mtype, obj)
Sends a network message to the destination specified.

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__


Instance Variables [hide private]
  hub
the TransportHub that the router is associated with, should be set at init time and never changed.
  nodes
This is the routing table.
  transports
A set of the transports that are currently active.

Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

__init__(self, hub, messaging=None)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

addTransport(self, t, nodeId)

source code 
Handles the routing protocol initilization. This involves first exchanging routing tables entirely, then updating our routing table as appropriate. While updating our routing table, we need to construct a routing update message and send it to all transports other than the transport being added.
Parameters:
  • t - The transport being added to the network

removeTransport(self, t)

source code 
Removes the transport from the network. This involves figuring out which nodes are now unreachable (any routes we had over that transport), removing any references to the transport from our routing table, and updating our neighbors about our changed routing table.
Parameters:
  • t - The transport being removed from the network

handleUpdate(self, t, update, localUpdate=None)

source code 
Handles a routing table update, builds the update message and sends it out to all except the src of the update.
Parameters:
  • t - The source transport from which the update came (in other words where NOT to send our update)
  • update - A dict containing the routing update.
  • localUpdate - Only used in the specific case of when creating a new transport. This will include an entry for the node we've just connected to, so that it may be merged into the update sent out to the other nodes.

handleLinkMessage(self, t, lm)

source code 
Called by the SpoonTransportThread when a link message has been received for one of our LMTYPEs.
Parameters:
  • t - The transport that it came from
  • lm - The LinkMessage that came in.

handleNetworkTraffic(self, t, obj)

source code 
None

sendNetMsg(self, dst, mtype, obj)

source code 
Sends a network message to the destination specified. A NetMessage object is constructed from the arguments provided to this method and routed appropriately.
Parameters:
  • dst - The node id of the destination
  • mtype - The message type (probably NMTYPE_MESSAGE)
  • obj - The object attachment of the NetMessage

Instance Variable Details [hide private]

hub

the TransportHub that the router is associated with, should be set at init time and never changed.

nodes

This is the routing table. It's a dictionary whose keys are node ids, and the values are a tuple consisting of the hop count to the node and the transport used to get there.

transports

A set of the transports that are currently active.