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

Type MeshRouter

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
Method Summary
  __init__(self, hub, messaging)
  addTransport(self, t, nodeId)
Handles the routing protocol initilization.
  handleLinkMessage(self, t, lm)
Called by the SpoonTransportThread when a link message has been received for one of our LMTYPEs.
  handleNetworkTraffic(self, t, obj)
  handleUpdate(self, t, update, localUpdate)
Handles a routing table update, builds the update message and sends it out to all except the src of the update.
  removeTransport(self, t)
Removes the transport from the network.
  sendNetMsg(self, dst, mtype, obj)
Sends a network message to the destination specified.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Instance Variable Summary
  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.

Method Details

addTransport(self, t, nodeId)

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

handleLinkMessage(self, t, lm)

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.

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

removeTransport(self, t)

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

sendNetMsg(self, dst, mtype, obj)

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

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.

Generated by Epydoc 2.1 on Sun Nov 26 15:33:58 2006 http://epydoc.sf.net