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

java.lang.Object
  extended by sidnet.stack.users.marco_project.packet_centric.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
           
 double[] fieldVector
           
 Coordinate rly
           
 Coordinate snk
           
static TopologyGUI topologyGUI
           
 MacAddress undeliverableToMacAddress
           
 
Constructor Summary
ElectrostaticRouter(Node myNode, StatsCollector stats, ExperimentDataImpl experimentData)
          Creates a new instance of ElectrostaticRouter
 
Method Summary
 double addChargeEffect(ElectricCharge e, double[] fieldVectorr, Coordinate vpl, double snkMagnitude)
           
 double[] calculateFieldVector(java.util.List<ElectricCharge> charges, Coordinate vpl, Coordinate srcLoc)
           
 Coordinate calculateNextVPL(Coordinate currentVPL, double[] fieldVector, int routeId)
           
 Coordinate computeCircleAndLineIntersection(Coordinate A, Coordinate B, Coordinate C, double radius)
           
 Coordinate computeVirtualSinkCoordinate(ElectricCharge srcCharge, Coordinate snkLoc)
           
 ElectricCharge computeVirtualSourceCharge(ElectricCharge srcCharge, Coordinate snkLoc)
           
 void drawFieldVector(Coordinate vpl, double[] fieldVectorr)
           
 void dropNotify(Message msg, MacAddress nextHopMac, Reason reason)
          Notification mechanism for packet dropped due to various "Reasons"
 ElectricCharge findCharge(java.util.List<ElectricCharge> charges, Coordinate pos)
           
 RouteInterface getProxy()
          internals
 void initFieldVectors(int routeOutgoingAngle)
           
 double maxCoverage()
           
 void peek(NetMessage msg, MacAddress lastHopMac)
          Called by the network layer for every incoming packet.
 void receive(Message msg, NetAddress src, MacAddress lastHop, byte macId, NetAddress dst, byte priority, byte ttl)
          Receive a message from the Link layer This function is called whenever the link layer receives a message whose final destination is THIS node.
 int selectNextHop(Coordinate vpl)
           
 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, needs to be forwarded The mechanism is explained in the SIDnet manual.
 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
Constructor Detail

ElectrostaticRouter

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

Method Detail

dropNotify

public void dropNotify(Message msg,
                       MacAddress nextHopMac,
                       Reason reason)
Notification mechanism for packet dropped due to various "Reasons"

Specified by:
dropNotify in interface NetInterface.NetHandler

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, 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 - outgoing packet

receive

public void receive(Message msg,
                    NetAddress src,
                    MacAddress lastHop,
                    byte macId,
                    NetAddress dst,
                    byte priority,
                    byte ttl)
Receive 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 - message received
src - source network address
lastHop - source link address
macId - incoming interface
dst - destination network address
priority - packet priority
ttl - packet time-to-live

peek

public void peek(NetMessage msg,
                 MacAddress lastHopMac)
Description copied from interface: RouteInterface
Called by the network layer for every incoming packet. A routing implementation may wish to look at these packets for informational purposes, but should not change their contents.

Specified by:
peek in interface RouteInterface
Parameters:
msg - incoming packet
lastHopMac - last link-level hop of incoming packet

findCharge

public ElectricCharge findCharge(java.util.List<ElectricCharge> charges,
                                 Coordinate pos)

maxCoverage

public double maxCoverage()

initFieldVectors

public void initFieldVectors(int routeOutgoingAngle)

calculateNextVPL

public Coordinate calculateNextVPL(Coordinate currentVPL,
                                   double[] fieldVector,
                                   int routeId)

computeVirtualSourceCharge

public ElectricCharge computeVirtualSourceCharge(ElectricCharge srcCharge,
                                                 Coordinate snkLoc)

computeVirtualSinkCoordinate

public Coordinate computeVirtualSinkCoordinate(ElectricCharge srcCharge,
                                               Coordinate snkLoc)

computeCircleAndLineIntersection

public Coordinate computeCircleAndLineIntersection(Coordinate A,
                                                   Coordinate B,
                                                   Coordinate C,
                                                   double radius)

selectNextHop

public int selectNextHop(Coordinate vpl)

calculateFieldVector

public double[] calculateFieldVector(java.util.List<ElectricCharge> charges,
                                     Coordinate vpl,
                                     Coordinate srcLoc)

addChargeEffect

public double addChargeEffect(ElectricCharge e,
                              double[] fieldVectorr,
                              Coordinate vpl,
                              double snkMagnitude)

drawFieldVector

public void drawFieldVector(Coordinate vpl,
                            double[] fieldVectorr)

sendToLinkLayer

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


sendToAppLayer

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


setAppInterface

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


setNetEntity

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


getProxy

public RouteInterface getProxy()
internals