sidnet.stack.users.marco_project.image_charges.routing
Class ElectrostaticRouter

java.lang.Object
  extended by sidnet.stack.users.marco_project.image_charges.routing.ElectrostaticRouter
All Implemented Interfaces:
JistAPI.Proxiable, JistAPI.Timeless, NetInterface.NetHandler, RouteInterface

public class ElectrostaticRouter
extends java.lang.Object
implements RouteInterface


Nested Class Summary
 
Nested classes/interfaces inherited from interface jist.swans.route.RouteInterface
RouteInterface.Aodv, RouteInterface.BezierRouting, RouteInterface.Dsr, RouteInterface.ECGRIDRouting, RouteInterface.GenericRouting, RouteInterface.HeartbeatProtocol, RouteInterface.MultiTreeRouting, RouteInterface.RandomPathRouting, RouteInterface.ShortestPathRouting, RouteInterface.Zrp
 
Field Summary
 int contorUndeliverable
           
 boolean disconnected
           
 double[] fieldVector
           
 Coordinate rly
           
 java.util.HashMap<java.lang.Integer,java.lang.Long> sequenceMap
           
 Coordinate snk
           
static TopologyGUI topologyGUI
           
 MacAddress undeliverableToMacAddress
           
 
Constructor Summary
ElectrostaticRouter(Node myNode, StatsCollector stats)
          Creates a new instance of ElectrostaticRouter
 
Method Summary
 void addChargeEffect(ElectricCharge e, double[] fieldVector, Coordinate vpl)
          Applies effect of presented charge to the field vector at virtual packet position.
 double[] calculateFieldVector(java.util.List<ElectricCharge> charges, Coordinate vpl, Coordinate srcLoc)
          Calculates the field vector at a virtual packet position Optionally applies method of image charges
 Coordinate calculateNextVPL(Coordinate currentVPL, double[] fieldVector, Message msg)
          Based on the currentVPL location and current fieldVector coordinates, we should be able to determine the next desirable (hence virtual) VPL for the packet
 void drawFieldVector(Coordinate vpl, double[] fieldVectorr)
          Draws a field vector to the GUI
 void dropNotify(Message msg, MacAddress nextHopMac, Reason reason)
          Notifies on message drop.
 RouteInterface getProxy()
          internals
 void initFieldVectors(int routeOutgoingAngle)
          Initializes the field vectors around the source node
 boolean isDuplicated(DataMessage dataMsg)
           
 double maxCoverage()
          Analyzes all the 1-hop neighbors and returns the distance to furthest neighbor
 void peek(NetMessage msg, MacAddress lastHopMac)
          NOT AVAILABLE ANYMORE.
 void receive(Message msg, NetAddress src, MacAddress lastHop, byte macId, NetAddress dst, byte priority, byte ttl)
          Receives a message from the Link layer.
 int selectNextHop(Coordinate vpl)
          Returns id of selected next-hop node
 void send(NetMessage netMsg)
          This function is called when the App Layer transmits a packet (other than broadcast (NetAddress.ANY) packet) or a message is received from the MAC layer, but, since this node is not the FINAL destination of the message, it needs to be forwarded.
 void sendToAppLayer(Message msg, NetAddress src)
          convenience function to send data UP ("to app layer")
 byte sendToLinkLayer(NetMessage.Ip ipMsg, NetAddress nextHopDestIP)
          convenience function to send data DOWN ("to link layer")
 void setAppInterface(AppInterface appInterface)
          internals - for hooking up with App-Layer
 void setNetEntity(NetInterface netEntity)
          internals - for hooking up with the Network-Layer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

topologyGUI

public static TopologyGUI topologyGUI

contorUndeliverable

public int contorUndeliverable

undeliverableToMacAddress

public MacAddress undeliverableToMacAddress

rly

public Coordinate rly

snk

public Coordinate snk

fieldVector

public double[] fieldVector

disconnected

public boolean disconnected

sequenceMap

public java.util.HashMap<java.lang.Integer,java.lang.Long> sequenceMap
Constructor Detail

ElectrostaticRouter

public ElectrostaticRouter(Node myNode,
                           StatsCollector stats)
Creates a new instance of ElectrostaticRouter

Parameters:
myNode -
Method Detail

isDuplicated

public boolean isDuplicated(DataMessage dataMsg)

send

public void send(NetMessage netMsg)
This function is called when the App Layer transmits a packet (other than broadcast (NetAddress.ANY) packet) or a message is received from the MAC layer, but, since this node is not the FINAL destination of the message, it needs to be forwarded. The mechanism is explained in the SIDnet manual. On short: When the app-layer sends a packet down (or link layer sends it UP) to Network layer (unicast) the network layer calls the send(NetMessage) of the routing protocol "indexed" by the packet. Here you decide how to route or what to do with the packet. If it is a broadcast packet, the Network layer will immediatelly push the packet DOWN to the Link layer, bypassing the routing protocol

Specified by:
send in interface NetInterface.NetHandler
Specified by:
send in interface RouteInterface
Parameters:
netMsg -

receive

public void receive(Message msg,
                    NetAddress src,
                    MacAddress lastHop,
                    byte macId,
                    NetAddress dst,
                    byte priority,
                    byte ttl)
Receives a message from the Link layer. This function is called whenever the link layer receives a message whose final destination is THIS node.

Specified by:
receive in interface NetInterface.NetHandler
Parameters:
msg -
src -
lastHop -
macId -
dst -
priority -
ttl -

peek

public void peek(NetMessage msg,
                 MacAddress lastHopMac)
NOT AVAILABLE ANYMORE. YOU CANNOT PEEK PACKETS. DISREGARD. ONLY FOR BACKWARDS COMPATIBILITY

Specified by:
peek in interface RouteInterface
Parameters:
msg -
lastHopMac -

dropNotify

public void dropNotify(Message msg,
                       MacAddress nextHopMac,
                       Reason reason)
Notifies on message drop.

Specified by:
dropNotify in interface NetInterface.NetHandler
Parameters:
msg -
nextHopMac -
reason -

sendToLinkLayer

public byte sendToLinkLayer(NetMessage.Ip ipMsg,
                            NetAddress nextHopDestIP)
convenience function to send data DOWN ("to link layer")

Parameters:
ipMsg -
nextHopDestIP -
Returns:

sendToAppLayer

public void sendToAppLayer(Message msg,
                           NetAddress src)
convenience function to send data UP ("to app layer")

Parameters:
msg -
src -

initFieldVectors

public void initFieldVectors(int routeOutgoingAngle)
Initializes the field vectors around the source node

Parameters:
routeOutgoingAngle -

addChargeEffect

public void addChargeEffect(ElectricCharge e,
                            double[] fieldVector,
                            Coordinate vpl)
Applies effect of presented charge to the field vector at virtual packet position.

Parameters:
e -
fieldVector -
vpl -

calculateFieldVector

public double[] calculateFieldVector(java.util.List<ElectricCharge> charges,
                                     Coordinate vpl,
                                     Coordinate srcLoc)
Calculates the field vector at a virtual packet position Optionally applies method of image charges

Parameters:
charges -
vpl -
srcLoc -
Returns:

calculateNextVPL

public Coordinate calculateNextVPL(Coordinate currentVPL,
                                   double[] fieldVector,
                                   Message msg)
Based on the currentVPL location and current fieldVector coordinates, we should be able to determine the next desirable (hence virtual) VPL for the packet

Parameters:
currentVPL -
fieldVector -
msg -
Returns:

maxCoverage

public double maxCoverage()
Analyzes all the 1-hop neighbors and returns the distance to furthest neighbor

Returns:

selectNextHop

public int selectNextHop(Coordinate vpl)
Returns id of selected next-hop node

Parameters:
vpl -
Returns:

drawFieldVector

public void drawFieldVector(Coordinate vpl,
                            double[] fieldVectorr)
Draws a field vector to the GUI

Parameters:
vpl -
fieldVectorr -

setAppInterface

public void setAppInterface(AppInterface appInterface)
internals - for hooking up with App-Layer

Parameters:
appInterface -

setNetEntity

public void setNetEntity(NetInterface netEntity)
internals - for hooking up with the Network-Layer

Parameters:
netEntity -

getProxy

public RouteInterface getProxy()
internals

Returns: