SunSPOT API V3.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:
1.0
Author:
Allen Ajit George, Jochen Furthmueller, Pete St. Pierre

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.
 IService getNetManager()
          returns a handle to the netmanagement object
 IRoutingManager getRoutingManager()
          returns a handle to the routing manager object
 IRoutingPolicyManager getRoutingPolicyManager()
          returns a handle to the RoutingPolicyManager object
 LowPanStats getStatistics()
          return a copy of the lowpan statistics object
 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)
          send a LowPan packet using 802.15.4 broadcast packets
 void sendWithoutMeshingOrFragmentation(byte protocolNum, long toAddress, byte[] buffer, int startOffset, int endOffset)
          Sends a packet over a single hop.
 void setOurAddress(long addr)
          set the IEEE Address for which we process packets
 IRoutingManager setRoutingManager(IRoutingManager newRoutingManager)
          Replace the routing manager with a different implemenation
 
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:
ourAddress - MAC address we generate packets from/answer for
aodvManager - the routing manager used for mesh routing
radioPacketDispatcher - The underlying object that transmits and received 802.15.4 radio packets
Method Detail

getInstance

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

Returns:
the LowPan packet dispatcher for this SPOT

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
Parameters:
info - object containg routing information
uniqueKey - a key that uniquely identifies the route

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 - the radio was busy/in-use
NoRouteException - a mesh route could not be found to the next hop for the received packet

getRoutingManager

public IRoutingManager getRoutingManager()
returns a handle to the routing manager object

Specified by:
getRoutingManager in interface ILowPan
Returns:
An object that implements the IRoutingManager interface

getNetManager

public IService getNetManager()
returns a handle to the netmanagement object

Returns:
An object that implements the IService interface

getRoutingPolicyManager

public IRoutingPolicyManager getRoutingPolicyManager()
returns a handle to the RoutingPolicyManager object

Returns:
An object that implements the IRoutingManager interface

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
Sends a packet over a single hop. The buffer must fit within a single 802.15.4 packet. No 6lowpan headers are used.

Specified by:
sendWithoutMeshingOrFragmentation in interface ILowPan
Parameters:
protocolNum - SPOT protocol number
toAddress - destination address for this packet
buffer - the data buffer being sent
startOffset - start index for data to be sent
endOffset - end index of data from buffer to be sent
Throws:
NoAckException - receiving end did not generate the 802.15.4 layer ACK for this packet
ChannelBusyException - radio was busy/in-use

sendBroadcast

public long sendBroadcast(byte protocolNum,
                          byte[] buffer,
                          int startOffset,
                          int endOffset,
                          int hops)
                   throws ChannelBusyException
send a LowPan packet using 802.15.4 broadcast packets

Specified by:
sendBroadcast in interface ILowPan
Parameters:
protocolNum - The SPOT prootocol number of the packet
buffer - data buffer to send
startOffset - start of data buffer to send
endOffset - end index of data buffer to send
hops - maximum number of hops this LowPan packet should be passed within a mesh routed environment
Returns:
timestamp packet was sent
Throws:
ChannelBusyException - radio channel was busy/in-use

setOurAddress

public void setOurAddress(long addr)
set the IEEE Address for which we process packets

Specified by:
setOurAddress in interface ILowPan
Parameters:
addr - our IEEE Address as a long

getStatistics

public LowPanStats getStatistics()
return a copy of the lowpan statistics object


SunSPOT API V3.0


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