Class Edge

java.lang.Object
  extended byEdge

public class Edge
extends java.lang.Object

   
 Edge stores the specifics about each edge in the topology. 
 Edges can be temporarily disabled and they record when the next packet can be sent along the edge
 


Constructor Summary
Edge(int a, int b, EdgeOptions options)
          Create a live edge between nodes a and b
 
Method Summary
 int getNodeA()
          Returns node a
 int getNodeB()
          Returns node b
 EdgeOptions getOptions()
           
 boolean isEdge(int a, int b)
           
 boolean isLive()
           
 long schedulePkt(int src, int size, long now)
          Figure out when, in microseconds, a packet will arrive at the destination, given a link's bandwidth propogation delay characteristics.
 void setOptions(EdgeOptions options)
          Sets the options for the edge
 void setState(boolean state)
          Sets the state of the edge, either live or not live
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Edge

public Edge(int a,
            int b,
            EdgeOptions options)
Create a live edge between nodes a and b

Parameters:
a - Int specifying a node
b - Int specifying a node
options - The edge options. That is, the delay, the loss rate and the bandwidth
Method Detail

schedulePkt

public long schedulePkt(int src,
                        int size,
                        long now)
                 throws java.lang.IllegalArgumentException
Figure out when, in microseconds, a packet will arrive at the destination, given a link's bandwidth propogation delay characteristics.

Parameters:
src - The src node that wants to send the packet
size - The size of the packet in bytes
now - The current time in microseconds
Returns:
The time (in microseconds) when the next packet will arrive at the destination. Returns -1 if the packet is dropped
Throws:
java.lang.IllegalArgumentException - Thrown if size is greater than Packet.MAX_PACKET_SIZE

isEdge

public boolean isEdge(int a,
                      int b)
Parameters:
a - Int specifying a node
b - Int specifying a node
Returns:
Returns true if this is an edge between a and b

getNodeA

public int getNodeA()
Returns node a

Returns:
The address of node a

getNodeB

public int getNodeB()
Returns node b

Returns:
The address of node b

setState

public void setState(boolean state)
Sets the state of the edge, either live or not live

Parameters:
state - The state of the edge. True means live

isLive

public boolean isLive()
Returns:
True if edge is live

getOptions

public EdgeOptions getOptions()
Returns:
The options of the edge. That is, the loss rate, delay and bandwidth

setOptions

public void setOptions(EdgeOptions options)
Sets the options for the edge

Parameters:
options - The edge options