Class link.SimpleNode
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class link.SimpleNode

java.lang.Object
   |
   +----link.SimpleNode

public class SimpleNode
extends Object
implements Node
A basic implementation of a node. Manages the connected links, and forwards all packets received to all other links. Clients are encouraged to extend this class and override the PacketArrived method.

Constructor Index

 o SimpleNode(String)
Create a new node.

Method Index

 o AddLink(Link)
Connect a link
 o ConnectedLinks()
Get an enumeration of the currently connected links.
 o PacketArrived(LinkPacket, Link)
The callback for new packets.
 o RemoveLink(Link)
Disconnect a link
 o toString()
String representation is name plus type:

Constructors

 o SimpleNode
  public SimpleNode(String name)
Create a new node.

Methods

 o toString
  public String toString()
String representation is name plus type:
Overrides:
toString in class Object
 o ConnectedLinks
  protected Enumeration ConnectedLinks()
Get an enumeration of the currently connected links. @return an enumeration of the links
 o PacketArrived
  public void PacketArrived(LinkPacket p,
                            Link l)
The callback for new packets. Implements the following algorithm, which retransmits the packet on all links other than the one the packet arrived on.
      Enumeration links = ConnectedLinks ();
      while (links.hasMoreElements ())
         {
         Link link = (Link) links.nextElement ();
         if (link != l)
            link.TransmitPacket (p, this);
         }
@see Node#PacketArrived
 o AddLink
  public synchronized void AddLink(Link l)
Connect a link @see Node#AddLink
 o RemoveLink
  public synchronized void RemoveLink(Link l)
Disconnect a link @see Node#RemoveLink

All Packages  Class Hierarchy  This Package  Previous  Next  Index