All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class magician.Node.PortInterface

java.lang.Object
   |
   +----magician.Node.PortInterface

public class PortInterface
extends Object
implements Runnable, ActiveNetsConstants, PerfConstants
This module accepts outgoing packets packets as byte arrays, and decides which Port must send them

See Also:
PortManager

Variable Index

 o bytesSent
 o packetsSent
 o SPLoader
Loader for loading KU SmartPackets which use serialization

Constructor Index

 o PortInterface()
creates a PortInterface object

Method Index

 o createNewOTWPacket(KUSmartPacketV2)
creates a new OnTheWirePacket given the executable object
 o defineType(KUSmartPacketV2)
creates a Type definition for the incoming class
 o finalize()
cleans up before exiting
 o findOTWPFor(KUSmartPacketV2)
create ANEP encapsulation for SP object
 o getANAddress(String)
verifies if given address is an Active Net address and if not returns the AN address of the AN gateway from which destination can be reached
 o getExecutable(byte[])
extract executable SmartPacket object from ANEP encapsulation
 o getLinkAddress(String)
translates a virtual Active Node name to a link layer Address, currently IP.
 o getLinkBandwidthToNode(String)
get link bandwidth to neighbor
 o getLLAddress(String)
get the link layer address for Active Node
 o getPort(String)
get the port that a Active Node is listening to
 o run()
 o sendPacket(String, int, byte[])
accepts a byte array representing an envinroment specific SmartPacket and sends it to the specified Active Node by calling a PortManager's send method
 o SendSmartPacket(String, Object)
Routine to send SmartPackets.
 o transmit(InetPacket)
accepts a byte array representing an envinroment specific SmartPacket and sends it to the specified Active Node by calling a PortManager's send method

Variables

 o packetsSent
 public static long packetsSent
 o bytesSent
 public static long bytesSent
 o SPLoader
 public static SmartPacketLoader SPLoader
Loader for loading KU SmartPackets which use serialization

Constructors

 o PortInterface
 public PortInterface()
creates a PortInterface object

Methods

 o run
 public void run()
 o getANAddress
 protected static synchronized String getANAddress(String addr)
verifies if given address is an Active Net address and if not returns the AN address of the AN gateway from which destination can be reached

Parameters:
addr - the address to be checked
Returns:
the corresponding Active Node name
 o getLinkAddress
 protected static synchronized String getLinkAddress(String nodeName)
translates a virtual Active Node name to a link layer Address, currently IP.

Parameters:
nodeName - the name of the Active Node
Returns:
a String representing the link layer address
 o getPort
 protected static int getPort(String nodeName)
get the port that a Active Node is listening to

Parameters:
nodeName - the name of the Active Node
Returns:
the port it is listening to
 o getLinkBandwidthToNode
 protected static int getLinkBandwidthToNode(String nodeName)
get link bandwidth to neighbor

Parameters:
nodeName - name of neighbor
Returns:
the link bandwidth (in Kbps) if link exists else 0.
 o getLLAddress
 protected static String getLLAddress(String nodeName)
get the link layer address for Active Node

Parameters:
nodeName - name of the node
Returns:
a String containing the link layer address
 o transmit
 protected static synchronized boolean transmit(InetPacket ipkt)
accepts a byte array representing an envinroment specific SmartPacket and sends it to the specified Active Node by calling a PortManager's send method

Parameters:
addr - the IP address of the Active Node
port - the port to which to send the packet
packetBytes - a byte array containing bytes of the SmartPacket
 o sendPacket
 protected void sendPacket(String addr,
                           int port,
                           byte packetBytes[]) throws IOException
accepts a byte array representing an envinroment specific SmartPacket and sends it to the specified Active Node by calling a PortManager's send method

Parameters:
addr - the IP address of the Active Node
port - the port to which to send the packet
packetBytes - a byte array containing bytes of the SmartPacket
Throws: IOException
if packet could not be sent to given address
 o SendSmartPacket
 protected synchronized boolean SendSmartPacket(String PortName,
                                                Object SPObject)
Routine to send SmartPackets.

Parameters:
PortName - name of destination active node
SPObject - the SmartPacket object
Returns:
true if transmission successful, false otherwise
 o findOTWPFor
 protected static OnTheWirePacket findOTWPFor(KUSmartPacketV2 SPObject)
create ANEP encapsulation for SP object

Parameters:
SPObject - the Smartpacket object
Returns:
an ANEP encapsulation of the SmartPacket
See Also:
OnTheWirePacket
 o getExecutable
 protected static KUSmartPacketV2 getExecutable(byte packetbytes[]) throws NullPointerException
extract executable SmartPacket object from ANEP encapsulation

Parameters:
packetbytes - bytes of the ANEP packet
Returns:
the executable Smartpacket object
Throws: NullPointerException
if executable cannot be created
 o defineType
 protected static byte[] defineType(KUSmartPacketV2 SPObject)
creates a Type definition for the incoming class

Parameters:
cl - the class whose type is being defined
Returns:
a 16 byte array representing the Type ID
 o createNewOTWPacket
 protected static synchronized OnTheWirePacket createNewOTWPacket(KUSmartPacketV2 SPObject)
creates a new OnTheWirePacket given the executable object

Parameters:
destination - the destination of the SmartPacket
SPObject - the executable SmartPacket Object
Returns:
a new OnTheWirePacket object
See Also:
OnTheWirePacket
 o finalize
 public void finalize()
cleans up before exiting

Overrides:
finalize in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index
1