SunSPOT API V3.0


com.sun.spot.peripheral.radio
Class LowPanHeader

java.lang.Object
  extended by com.sun.spot.peripheral.radio.LowPanHeader

public class LowPanHeader
extends Object

LowPanHeader.java

Author:
Pete St. Pierre This class provides functionality for constructing a LowPanHeader. Use this class to set all the parameters associated with a packet. This object can be passed to LowPanPacket.writeHeaderAndPayload()

Field Summary
protected static byte BROADCAST_HEADER_LENGTH
          Size of a Broadcast Header
static byte DISPATCH_ESC
          Denotes the following header field is not in the scope of the LowPan spec We use this next byte for our SPOT protocol number
protected static byte DISPATCH_FRAG
          Denotes what follows is a some part of a LowPan packet
static byte DISPATCH_LOWPAN_BC0
          Denotes this packet is a LowPan Mesh Broadcast packet
static byte DISPATCH_LOWPAN_HC1
          Denotes this packet contains part of an IPv6 packet that uses header compression
static byte DISPATCH_LOWPAN_IPV6
          Denotes this packet contains part of an IPv6 format packet at the higher level
protected static byte DISPATCH_MESH
          Denotes what follows is a LowPan Mesh header
static byte DISPATCH_SPOT
          Denotes the following header field is not in the scope of the LowPan spec We use this next byte for our SPOT protocol number
static byte FAMILY_DEFINED_PROTO
          Denotes the protocol number is handled within the protocol family.
protected static byte FIRST_FRAGMENT
          Marks a packet as a First Fragment
protected static byte INTERIOR_FRAGMENT
          Marks a packet as an Interior Fragment
protected static byte LAST_FRAGMENT
          Marks a packet as the last Fragment
protected static byte MAX_FRAGMENTATION_HEADER_LENGTH
          Maximum size of a fragmentation header.
protected static byte MAX_MESH_HEADER_LENGTH
          Maximum size of a Mesh Header
protected static byte MAX_PROTOCOL_HEADER_LENGTH
          Max length of the protocol header
static byte MAX_UNFRAG_HEADER_LENGTH
          Unfragmented header is 17B Mesh, 2B Broadcast, 2B protocol
protected static byte UNFRAGMENTED
          Marks a packet as unfragmented
 
Constructor Summary
LowPanHeader()
          Creates a new instance of LowPanHeader
 
Method Summary
 int getLength()
          Calculates the number of bytes this LowPanHeader will take
 int getOutgoingBCastSeqNo()
          return the number of hops a mesh broadcast with this header will make
 long getOutgoingDestinationAddress()
          get the final destination from the mesh field of this header
 byte getOutgoingFragOffset()
          get the fragmentation offset field of the header, based on its location in the orginal datagram
 int getOutgoingFragSize()
          return the total size of the packet associated with this fragment
 int getOutgoingFragTag()
          return the datagram tag associated with this fragment
 int getOutgoingFragType()
          return the current fragment type (UNFRAGMENTED, FIRST_FRAGMENT, INTERIOR_FRAGMENT, LAST_FRAGMENT)
 int getOutgoingHops()
          return the number of hops this header is set to take
 long getOutgoingOriginatorAddress()
          get the originator from the mesh field of this header
 byte getProtocolFamily()
           
 byte getProtocolNo()
          get the protocol number from this header
 boolean isBCast()
          check to see if this header contains mesh broadcast information
 boolean isExtendedProtocol()
          Defines whether this header uses the extended protocol field
 boolean isFirstFrag()
          Checks the header to see if this header belongs to a packet that is the first fragment of a series.
 boolean isFragged()
          check whether this header contains a fragmentation field
 boolean isMeshed()
          check whether this header contains a mesh field
 void setBCast(boolean bCast)
          sets this packet to contain mesh broadcast information
 void setFragged(boolean fragged)
          set the flag indicating this header contains fragmentation information
 void setMeshed(boolean meshed)
          set the flag indicating there is a mesh field associated with this header
 void setOutgoingBCastSeqNo(int outgoingBCastSeqNo)
          Sets the number of hops a mesh broadcast with this header will make
 void setOutgoingDestinationAddress(long outgoingDestinationAddress)
          set the final destination field of the mesh header
 void setOutgoingFragOffset(int outgoingFragOffset)
          set the offset in the fragmentation header for this header, based on where the associated packet belongs in the reassembled packet
 void setOutgoingFragSize(int outgoingFragSize)
          sets the size field of this fragment header.
 void setOutgoingFragTag(int outgoingFragTag)
          set the datagram tag for this header
 void setOutgoingFragType(int outgoingFragType)
          set the type of this fragment
 void setOutgoingHops(int outgoingHops)
          set the number of hops a packet associated with this header will make
 void setOutgoingOriginatorAddress(long outgoingOriginatorAddress)
          set the originator field of the mesh header
 void setProtocolInfo(byte protocolFamily, byte protocolNo)
          set the protocol information in this header
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNFRAGMENTED

protected static final byte UNFRAGMENTED
Marks a packet as unfragmented

See Also:
Constant Field Values

LAST_FRAGMENT

protected static final byte LAST_FRAGMENT
Marks a packet as the last Fragment

See Also:
Constant Field Values

FIRST_FRAGMENT

protected static final byte FIRST_FRAGMENT
Marks a packet as a First Fragment

See Also:
Constant Field Values

INTERIOR_FRAGMENT

protected static final byte INTERIOR_FRAGMENT
Marks a packet as an Interior Fragment

See Also:
Constant Field Values

DISPATCH_LOWPAN_IPV6

public static final byte DISPATCH_LOWPAN_IPV6
Denotes this packet contains part of an IPv6 format packet at the higher level

See Also:
Constant Field Values

DISPATCH_LOWPAN_HC1

public static final byte DISPATCH_LOWPAN_HC1
Denotes this packet contains part of an IPv6 packet that uses header compression

See Also:
Constant Field Values

DISPATCH_LOWPAN_BC0

public static final byte DISPATCH_LOWPAN_BC0
Denotes this packet is a LowPan Mesh Broadcast packet

See Also:
Constant Field Values

DISPATCH_ESC

public static final byte DISPATCH_ESC
Denotes the following header field is not in the scope of the LowPan spec We use this next byte for our SPOT protocol number

See Also:
Constant Field Values

DISPATCH_SPOT

public static final byte DISPATCH_SPOT
Denotes the following header field is not in the scope of the LowPan spec We use this next byte for our SPOT protocol number

See Also:
Constant Field Values

FAMILY_DEFINED_PROTO

public static final byte FAMILY_DEFINED_PROTO
Denotes the protocol number is handled within the protocol family. Should be used with DISPATCH_SPOT protocol families

See Also:
Constant Field Values

DISPATCH_FRAG

protected static final byte DISPATCH_FRAG
Denotes what follows is a some part of a LowPan packet

See Also:
Constant Field Values

DISPATCH_MESH

protected static final byte DISPATCH_MESH
Denotes what follows is a LowPan Mesh header

See Also:
Constant Field Values

MAX_PROTOCOL_HEADER_LENGTH

protected static final byte MAX_PROTOCOL_HEADER_LENGTH
Max length of the protocol header

See Also:
Constant Field Values

BROADCAST_HEADER_LENGTH

protected static final byte BROADCAST_HEADER_LENGTH
Size of a Broadcast Header

See Also:
Constant Field Values

MAX_FRAGMENTATION_HEADER_LENGTH

protected static final byte MAX_FRAGMENTATION_HEADER_LENGTH
Maximum size of a fragmentation header. May be only 3 for a First Fragment

See Also:
Constant Field Values

MAX_MESH_HEADER_LENGTH

protected static final byte MAX_MESH_HEADER_LENGTH
Maximum size of a Mesh Header

See Also:
Constant Field Values

MAX_UNFRAG_HEADER_LENGTH

public static final byte MAX_UNFRAG_HEADER_LENGTH
Unfragmented header is 17B Mesh, 2B Broadcast, 2B protocol

See Also:
Constant Field Values
Constructor Detail

LowPanHeader

public LowPanHeader()
Creates a new instance of LowPanHeader

Method Detail

getLength

public int getLength()
Calculates the number of bytes this LowPanHeader will take

Returns:
returns the length, in number of bytes, of the LowPanHeader

isFirstFrag

public boolean isFirstFrag()
Checks the header to see if this header belongs to a packet that is the first fragment of a series.

Returns:
true if this header belongs to the first fragment of series

isExtendedProtocol

public boolean isExtendedProtocol()
Defines whether this header uses the extended protocol field

Returns:
true if this is an extended protocol header

getOutgoingHops

public int getOutgoingHops()
return the number of hops this header is set to take

Returns:
the number of hops for the associated packet

setOutgoingHops

public void setOutgoingHops(int outgoingHops)
set the number of hops a packet associated with this header will make

Parameters:
outgoingHops - the number of hops to set in this header

getOutgoingBCastSeqNo

public int getOutgoingBCastSeqNo()
return the number of hops a mesh broadcast with this header will make

Returns:
the number of hops a mesh broadcast with this header will make

setOutgoingBCastSeqNo

public void setOutgoingBCastSeqNo(int outgoingBCastSeqNo)
Sets the number of hops a mesh broadcast with this header will make

Parameters:
outgoingBCastSeqNo - the number of hops a mesh broadcast with this header should make

getOutgoingFragType

public int getOutgoingFragType()
return the current fragment type (UNFRAGMENTED, FIRST_FRAGMENT, INTERIOR_FRAGMENT, LAST_FRAGMENT)

Returns:
the type of fragment this header is

setOutgoingFragType

public void setOutgoingFragType(int outgoingFragType)
set the type of this fragment

Parameters:
outgoingFragType - the type of fragment, (UNFRAGMENTED, FIRST_FRAGMENT, INTERIOR_FRAGMENT, LAST_FRAGMENT)

getOutgoingFragTag

public int getOutgoingFragTag()
return the datagram tag associated with this fragment

Returns:
the datagram tag for this header, if it is a fragment

setOutgoingFragTag

public void setOutgoingFragTag(int outgoingFragTag)
set the datagram tag for this header

Parameters:
outgoingFragTag - the new datagram tag for this header

getOutgoingFragSize

public int getOutgoingFragSize()
return the total size of the packet associated with this fragment

Returns:
the total size of the datagram that the fragment this header is associated with should be

setOutgoingFragSize

public void setOutgoingFragSize(int outgoingFragSize)
sets the size field of this fragment header. Reflects the total size of the datagram when reassembled

Parameters:
outgoingFragSize - the total size of the datagram when reassembled

getOutgoingFragOffset

public byte getOutgoingFragOffset()
get the fragmentation offset field of the header, based on its location in the orginal datagram

Returns:
the offset in the total datagram for which the packet assocated with this header belongs

setOutgoingFragOffset

public void setOutgoingFragOffset(int outgoingFragOffset)
set the offset in the fragmentation header for this header, based on where the associated packet belongs in the reassembled packet

Parameters:
outgoingFragOffset - the place within the reassembled packet ththe packets associated with this header belongs

getOutgoingOriginatorAddress

public long getOutgoingOriginatorAddress()
get the originator from the mesh field of this header

Returns:
the originating address of the packet associated with this header

setOutgoingOriginatorAddress

public void setOutgoingOriginatorAddress(long outgoingOriginatorAddress)
set the originator field of the mesh header

Parameters:
outgoingOriginatorAddress - the address of the originator of the packet associated with this mesh header

getOutgoingDestinationAddress

public long getOutgoingDestinationAddress()
get the final destination from the mesh field of this header

Returns:
the final destination address of the packet associated with this header

setOutgoingDestinationAddress

public void setOutgoingDestinationAddress(long outgoingDestinationAddress)
set the final destination field of the mesh header

Parameters:
outgoingDestinationAddress - the address of the final destination of the packet associated with this mesh header

getProtocolNo

public byte getProtocolNo()
get the protocol number from this header

Returns:
the protocol number of the packet associated with this header

isMeshed

public boolean isMeshed()
check whether this header contains a mesh field

Returns:
true if there is a mesh field in this header

setMeshed

public void setMeshed(boolean meshed)
set the flag indicating there is a mesh field associated with this header

Parameters:
meshed - true if there is a mesh field to be set in this header

isFragged

public boolean isFragged()
check whether this header contains a fragmentation field

Returns:
true if there is fragmentation information in this header

setFragged

public void setFragged(boolean fragged)
set the flag indicating this header contains fragmentation information

Parameters:
fragged - true if this header contains fragmentation information

isBCast

public boolean isBCast()
check to see if this header contains mesh broadcast information

Returns:
true if this header contains mesh broadcast information

setBCast

public void setBCast(boolean bCast)
sets this packet to contain mesh broadcast information

Parameters:
bCast - true if this packet is to contain mesh broadcast header information

getProtocolFamily

public byte getProtocolFamily()

setProtocolInfo

public void setProtocolInfo(byte protocolFamily,
                            byte protocolNo)
set the protocol information in this header

Parameters:
protocolFamily - the family this protocol information relates to (IPv6, SPOT, etc.)
protocolNo - the protocol number of the packet associated with this header

SunSPOT API V3.0


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