SunSPOT API V2.0


com.sun.spot.peripheral.radio
Class LowPan

java.lang.Object
  extended by com.sun.spot.peripheral.radio.LowPan
All Implemented Interfaces:
ILowPan, RouteEventClient

public class LowPan
extends Object
implements ILowPan, RouteEventClient

Packet processing layer based on the low pan draft. Provides link layer fragmentation and mesh routing in cooperation with a routing manager.

Version:
0.2
Author:
Allen Ajit George, Jochen Furthmueller

Field Summary
 
Fields inherited from interface com.sun.spot.peripheral.radio.ILowPan
DEFAULT_HOPS, MAC_PAYLOAD_OFFSET, MAX_MAC_PAYLOAD_OFFSET
 
Constructor Summary
protected LowPan(long ourAddress, IRoutingManager aodvManager, IRadioPacketDispatcher radioPacketDispatcher)
          protected constructor for the instantiation of the singleton
 
Method Summary
 void deregisterDataEventListener(IDataEventListener listener)
          Undo a previous call of registerDataEventListener()
 void deregisterProtocol(byte protocolNum)
          Deregister a protocol.
 void deregisterProtocolFamily(byte protocolFamily)
          Deregister a protocol family.
 void deregisterRouteEventListener(IRouteEventListener listener)
          Undo a previous call of registerRouteEventListener()
static ILowPan getInstance()
          Get the instance of this singleton.
 IRoutingManager getRoutingManager()
          Get the routing manager
 void receive(RadioPacket packet)
          This method is called by the packet dispatcher this low pan layer is registered with.
 void registerDataEventListener(IDataEventListener dataListener)
          Register to be notified as soon as the LowPan module forwards data.
 void registerMHEventListener(IMHEventListener mhListener)
          Register to be notified when certain multihop routing events occur.
 void registerProtocol(byte protocolNum, IProtocolManager protocolMan)
          Register a protocol manager to send and receive packets
 void registerProtocolFamily(byte protocolFamily, IProtocolManager protocolMan)
          Register a protocol manager to send and receive packets
 void registerRouteEventListener(IRouteEventListener routeListener)
          Register to be notified when certain routing events occur.
 void routeFound(RouteInfo info, Object uniqueKey)
          This method is called by the routing manager as soon as a route is available or if no route has been found within the defined period.
 long send(byte protocolFamily, byte protocolNum, long toAddress, byte[] buffer, int startOffset, int endOffset)
          Send a byte buffer on a given protocol.
 boolean send(byte protocolFamily, byte protocolNum, long toAddress, byte[] buffer, int startOffset, int endOffset, boolean failIfNotSingleHop)
          Send a byte buffer on a given protocol.
 long sendBroadcast(byte protocolNum, byte[] buffer, int startOffset, int endOffset, int hops)
          Broadcast a byte buffer on a given protocol, without any attempt at meshing (can be fragmented)
 void sendWithoutMeshingOrFragmentation(byte protocolNum, long toAddress, byte[] buffer, int startOffset, int endOffset)
          Send a byte buffer on a given protocol, without any attempt at meshing or fragmentation
 void setOurAddress(long addr)
          Method called by RadioPacketDispatcher on a host.
 IRoutingManager setRoutingManager(IRoutingManager newRoutingManager)
          Replace the routing manager with a different implemenation
protected  boolean validateSeqNo(LowPanPacket lpp)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LowPan

protected LowPan(long ourAddress,
                 IRoutingManager aodvManager,
                 IRadioPacketDispatcher radioPacketDispatcher)
protected constructor for the instantiation of the singleton

Parameters:
aodvManager -
radioPacketDispatcher -
Method Detail

getInstance

public static ILowPan getInstance()
Get the instance of this singleton.


setRoutingManager

public IRoutingManager setRoutingManager(IRoutingManager newRoutingManager)
Replace the routing manager with a different implemenation

Specified by:
setRoutingManager in interface ILowPan
Parameters:
newRoutingManager - a new routing manager
Returns:
the old routing manager

registerProtocolFamily

public void registerProtocolFamily(byte protocolFamily,
                                   IProtocolManager protocolMan)
Register a protocol manager to send and receive packets

Specified by:
registerProtocolFamily in interface ILowPan
Parameters:
protocolFamily - protocol family this protocol is in (ie IPv6, SunSPOT, etc)
protocolMan - the protocol manager to be registered

registerProtocol

public void registerProtocol(byte protocolNum,
                             IProtocolManager protocolMan)
Register a protocol manager to send and receive packets

Specified by:
registerProtocol in interface ILowPan
Parameters:
protocolNum - number of protocol to be handled
protocolMan - the protocol manager to be registered

deregisterProtocol

public void deregisterProtocol(byte protocolNum)
Deregister a protocol.

Specified by:
deregisterProtocol in interface ILowPan
Parameters:
protocolNum - identifier for the protocol

deregisterProtocolFamily

public void deregisterProtocolFamily(byte protocolFamily)
Deregister a protocol family.

Specified by:
deregisterProtocolFamily in interface ILowPan
Parameters:
protocolFamily - identifier for the protocol

registerDataEventListener

public void registerDataEventListener(IDataEventListener dataListener)
Register to be notified as soon as the LowPan module forwards data.

Specified by:
registerDataEventListener in interface ILowPan
Parameters:
dataListener - the class that wants to be called back

registerRouteEventListener

public void registerRouteEventListener(IRouteEventListener routeListener)
Register to be notified when certain routing events occur.

Specified by:
registerRouteEventListener in interface ILowPan
Parameters:
routeListener - the class that wants to be called back

registerMHEventListener

public void registerMHEventListener(IMHEventListener mhListener)
Register to be notified when certain multihop routing events occur.

Specified by:
registerMHEventListener in interface ILowPan
Parameters:
mhListener - the class that wants to be called back

deregisterDataEventListener

public void deregisterDataEventListener(IDataEventListener listener)
Undo a previous call of registerDataEventListener()

Specified by:
deregisterDataEventListener in interface ILowPan
Parameters:
listener - the class that wants to be deregistered

deregisterRouteEventListener

public void deregisterRouteEventListener(IRouteEventListener listener)
Undo a previous call of registerRouteEventListener()

Parameters:
listener - the class that wants to be deregistered

routeFound

public void routeFound(RouteInfo info,
                       Object uniqueKey)
This method is called by the routing manager as soon as a route is available or if no route has been found within the defined period. Then the nextHop field of the RouteInfo is invalid.

Specified by:
routeFound in interface RouteEventClient

receive

public void receive(RadioPacket packet)
             throws ChannelBusyException,
                    NoRouteException
This method is called by the packet dispatcher this low pan layer is registered with. It deceides which instance this packet should be passed to: forwardMeshPacket() for packets that are addressed to another node, reassembly() for fragmented packets or readPacket() for non fragmented packets.

Specified by:
receive in interface ILowPan
Parameters:
packet - packet that was received by the underlying radio
Throws:
ChannelBusyException - channel was busy when access was attempted
NoRouteException - No route could be found to the destination

validateSeqNo

protected boolean validateSeqNo(LowPanPacket lpp)
                         throws ChannelBusyException,
                                NoRouteException
Throws:
ChannelBusyException
NoRouteException

getRoutingManager

public IRoutingManager getRoutingManager()
Description copied from interface: ILowPan
Get the routing manager

Specified by:
getRoutingManager in interface ILowPan
Returns:
the routing manager

send

public long send(byte protocolFamily,
                 byte protocolNum,
                 long toAddress,
                 byte[] buffer,
                 int startOffset,
                 int endOffset)
          throws ChannelBusyException,
                 NoRouteException
Description copied from interface: ILowPan
Send a byte buffer on a given protocol. The caller simply supplied a byte payload

Specified by:
send in interface ILowPan
Parameters:
protocolFamily - the protocol family associated with the outgoing packet
protocolNum - the protocol number associated with the outgoing packet
toAddress - the destination
buffer - byte array that holds the data to be sent
startOffset - offset within the byte array at which data should be read
endOffset - offset within the byte array after which data should not be read
Returns:
the time at which the data was sent
Throws:
ChannelBusyException - the radio channel could not be accessed
NoRouteException - a route to the destination could not be found

send

public boolean send(byte protocolFamily,
                    byte protocolNum,
                    long toAddress,
                    byte[] buffer,
                    int startOffset,
                    int endOffset,
                    boolean failIfNotSingleHop)
             throws ChannelBusyException,
                    NoRouteException
Description copied from interface: ILowPan
Send a byte buffer on a given protocol. The caller simply supplied a byte payload

Specified by:
send in interface ILowPan
Parameters:
protocolFamily - the protocol family associated with the outgoing packet
protocolNum - the protocol number associated with the outgoing packet
toAddress - the destination
buffer - byte array that holds the data to be sent
startOffset - offset within the byte array at which data should be read
endOffset - offset within the byte array after which data should not be read
failIfNotSingleHop - if true this method should not send if not single hop.
Returns:
true if the buffer was sent
Throws:
ChannelBusyException - the radio channel could not be accessed
NoRouteException - a route to the destination could not be found

sendWithoutMeshingOrFragmentation

public void sendWithoutMeshingOrFragmentation(byte protocolNum,
                                              long toAddress,
                                              byte[] buffer,
                                              int startOffset,
                                              int endOffset)
                                       throws NoAckException,
                                              ChannelBusyException
Description copied from interface: ILowPan
Send a byte buffer on a given protocol, without any attempt at meshing or fragmentation

Specified by:
sendWithoutMeshingOrFragmentation in interface ILowPan
Parameters:
protocolNum - higher level protocol number (for port based protocol manager)
toAddress - address of the remote device for radio packet
buffer - data buffer to be sent
startOffset - index of first byte of data to be sent from the buffer
endOffset - index of the last byte of data to be sent
Throws:
NoAckException - Ack was expected but not received
ChannelBusyException - radio channel was busy when send was attempted

sendBroadcast

public long sendBroadcast(byte protocolNum,
                          byte[] buffer,
                          int startOffset,
                          int endOffset,
                          int hops)
                   throws ChannelBusyException
Description copied from interface: ILowPan
Broadcast a byte buffer on a given protocol, without any attempt at meshing (can be fragmented)

Specified by:
sendBroadcast in interface ILowPan
Parameters:
protocolNum - higher level protocol number (for port based protocol manager)
buffer - data buffer to be sent
startOffset - index of first byte of data to be sent from the buffer
endOffset - index of the last byte of data to be sent
hops - number of mesh hops this broadcast should take
Returns:
the time at which the data was sent
Throws:
ChannelBusyException - radio channel was busy when send attempted

setOurAddress

public void setOurAddress(long addr)
Description copied from interface: ILowPan
Method called by RadioPacketDispatcher on a host. The low pan needs to use the basestations ieee address.

Specified by:
setOurAddress in interface ILowPan
Parameters:
addr - 64-bit value representing our IEEE address

SunSPOT API V2.0


Copyright © 2007 Sun Microsystems, Inc. All Rights Reserved.