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.
-
SimpleNode(String)
- Create a new node.
-
AddLink(Link)
- Connect a link
-
ConnectedLinks()
- Get an enumeration of the currently connected links.
-
PacketArrived(LinkPacket, Link)
- The callback for new packets.
-
RemoveLink(Link)
- Disconnect a link
-
toString()
- String representation is name plus type:
SimpleNode
public SimpleNode(String name)
- Create a new node.
toString
public String toString()
- String representation is name plus type:
- Overrides:
- toString in class Object
ConnectedLinks
protected Enumeration ConnectedLinks()
- Get an enumeration of the currently connected links.
@return an enumeration of the links
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
AddLink
public synchronized void AddLink(Link l)
- Connect a link
@see Node#AddLink
RemoveLink
public synchronized void RemoveLink(Link l)
- Disconnect a link
@see Node#RemoveLink
All Packages Class Hierarchy This Package Previous Next Index