gov.nasa.gsfc.drl.rtstps.core.ccsds.path
Class PathService

java.lang.Object
  extended by gov.nasa.gsfc.drl.rtstps.core.RtStpsNode
      extended by gov.nasa.gsfc.drl.rtstps.core.ccsds.AbstractService
          extended by gov.nasa.gsfc.drl.rtstps.core.ccsds.path.PathService
All Implemented Interfaces:
FrameReceiver, Receiver, Sender, java.lang.Cloneable

public class PathService
extends AbstractService
implements FrameReceiver, Sender, java.lang.Cloneable

This class handles the first phase of the CCSDS Path Service. It performs packet assembly from v2 CADUs and sends the packets to a PacketReceiver. It does not sort packets, which it expects subsequent PacketReceivers to do. It does identify idle packets, but it does no other packet functions or verifications other than what it needs to do to assemble them.

This class receives frames as a FrameReceiver and decomposes each one's packet zone into a stream of packets. You must set the PacketReceiver for this class to operate successfully. The packet zone must include the first header pointer in the first two bytes immediately followed by packet data, which excludes any trailing bytes that are not packet parts.


Field Summary
private  LongStatusItem badFirstHeaderPointers
           
static java.lang.String CLASSNAME
          This is a class name for this STPS node type, which is also the element name.
private  LongStatusItem createdPackets
           
private  LongStatusItem discardedFragmentByteCount
           
private  LongStatusItem discardedFragments
           
private  boolean frameHasBadFhp
           
private static int FREE_STATE
           
private static int IDLE_VCDU
           
private  LongStatusItem idleVcdus
           
private  LongStatusItem irrationalPacketLengths
           
private  int mpduEnd
           
private  int mpduStart
           
private static int NO_PACKET_HEADER_IN_MPDU
           
private  PacketReceiver output
           
private  PacketCaddy packetCaddy
           
private  PacketList packetList
           
private  PacketZone packetZone
           
private  org.w3c.dom.NodeList pklinks
           
private  PacketOutputTool potool
           
private  PathServiceSetup setup
           
private static int SPLIT_HEADER_STATE
           
private static int SPLIT_PACKET_STATE
           
private  SplitHeader splitHeader
           
private  int state
           
private  LongStatusItem troublesomeFrames
           
 
Fields inherited from class gov.nasa.gsfc.drl.rtstps.core.ccsds.AbstractService
cadu, sequencer, serviceElement
 
Fields inherited from class gov.nasa.gsfc.drl.rtstps.core.RtStpsNode
linkName, statusItemList, typeName
 
Constructor Summary
PathService()
          Create a PathService object.
 
Method Summary
private  void abortSplitHeader(int firstPieceLength)
          I use this method when I must discard a packet header and the first frame piece during the "split packet header" scenario.
private  void abortSplitPacket(int firstPieceLength)
          I use this method when I must discard the first packet fragment and create a short packet during the "split packet" scenario.
 void addReceiver(Receiver receiver)
          Add a Receiver to this sender's list of receivers.
private  boolean decomposeDataZone(byte[] data, FrameAnnotation frameAnnotation)
          Decompose a packet zone into packets.
private  boolean discardUnexpectedPiece(int fhp)
          I use this method when I encounter an unexpected piece, which I discard, during the "free state" scenario.
private  boolean doSplitHeaderScenario(int fhp, FrameAnnotation frameAnnotation)
          This method processes the first piece, which is the second half of a split header, when this class is in the "split packet header" state.
private  boolean doSplitPacketScenario(int fhp, FrameAnnotation frameAnnotation)
          This method processes the first frame piece, which is subsequent packet piece, when this class is in the "split packet" state.
 void finishSetup(Configuration configuration)
          Finish the setup.
 void flush()
          Flush the pipeline.
 void load(org.w3c.dom.Element element, Configuration configuration)
          Set up this stps node with a configuration.
 void putFrame(Frame frame)
          Give a frame to this class for packet reassembly.
private  void resolveIrrationalPacket()
          A packet length must be rational.
 
Methods inherited from class gov.nasa.gsfc.drl.rtstps.core.ccsds.AbstractService
putFrames
 
Methods inherited from class gov.nasa.gsfc.drl.rtstps.core.RtStpsNode
clear, clone, getElementName, getLinkName, getStatusItems, setLinkName, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gov.nasa.gsfc.drl.rtstps.core.FrameReceiver
getLinkName, putFrames
 

Field Detail

CLASSNAME

public static final java.lang.String CLASSNAME
This is a class name for this STPS node type, which is also the element name. It is not necessarily the link name, which is the name of one particular object.

See Also:
Constant Field Values

NO_PACKET_HEADER_IN_MPDU

private static final int NO_PACKET_HEADER_IN_MPDU
See Also:
Constant Field Values

IDLE_VCDU

private static final int IDLE_VCDU
See Also:
Constant Field Values

FREE_STATE

private static final int FREE_STATE
See Also:
Constant Field Values

SPLIT_HEADER_STATE

private static final int SPLIT_HEADER_STATE
See Also:
Constant Field Values

SPLIT_PACKET_STATE

private static final int SPLIT_PACKET_STATE
See Also:
Constant Field Values

state

private int state

packetCaddy

private PacketCaddy packetCaddy

setup

private PathServiceSetup setup

packetZone

private PacketZone packetZone

splitHeader

private SplitHeader splitHeader

packetList

private PacketList packetList

mpduStart

private int mpduStart

mpduEnd

private int mpduEnd

frameHasBadFhp

private boolean frameHasBadFhp

pklinks

private org.w3c.dom.NodeList pklinks

output

private PacketReceiver output

potool

private PacketOutputTool potool

idleVcdus

private LongStatusItem idleVcdus

badFirstHeaderPointers

private LongStatusItem badFirstHeaderPointers

troublesomeFrames

private LongStatusItem troublesomeFrames

irrationalPacketLengths

private LongStatusItem irrationalPacketLengths

createdPackets

private LongStatusItem createdPackets

discardedFragments

private LongStatusItem discardedFragments

discardedFragmentByteCount

private LongStatusItem discardedFragmentByteCount
Constructor Detail

PathService

public PathService()
Create a PathService object.

Method Detail

load

public void load(org.w3c.dom.Element element,
                 Configuration configuration)
          throws RtStpsException
Set up this stps node with a configuration.

Overrides:
load in class AbstractService
Throws:
RtStpsException

addReceiver

public void addReceiver(Receiver receiver)
                 throws RtStpsException
Add a Receiver to this sender's list of receivers.

Specified by:
addReceiver in interface Sender
Parameters:
receiver - If the receiver is not of the expected type, then the method throws an StpsException.
Throws:
RtStpsException

finishSetup

public void finishSetup(Configuration configuration)
                 throws RtStpsException
Finish the setup. When this method is called, you may assume all nodes have been created and exist by name in the map, and all standard links have been resolved. This is a last chance to prepare for data flow.

Overrides:
finishSetup in class AbstractService
Throws:
RtStpsException

flush

public final void flush()
                 throws RtStpsException
Flush the pipeline.

Specified by:
flush in interface FrameReceiver
Specified by:
flush in interface Receiver
Throws:
RtStpsException

putFrame

public void putFrame(Frame frame)
              throws RtStpsException
Give a frame to this class for packet reassembly.

Specified by:
putFrame in interface FrameReceiver
Throws:
RtStpsException

decomposeDataZone

private boolean decomposeDataZone(byte[] data,
                                  FrameAnnotation frameAnnotation)
Decompose a packet zone into packets.

Parameters:
data - An array of bytes that define the complete frame.
frameAnnotation - The annotation for this frame.
Returns:
true if there was any problem decomposing this frame. The method will do as much as possible with a frame even if it has problems. False = no frame problems.

doSplitHeaderScenario

private boolean doSplitHeaderScenario(int fhp,
                                      FrameAnnotation frameAnnotation)
This method processes the first piece, which is the second half of a split header, when this class is in the "split packet header" state.

Parameters:
fhp - The first header pointer.
frameAnnotation - Frame annotation from the current frame.
Returns:
true if there was any problem decomposing this frame. The method will do as much as possible with a frame even if it has problems. False = no frame problems.

doSplitPacketScenario

private boolean doSplitPacketScenario(int fhp,
                                      FrameAnnotation frameAnnotation)
This method processes the first frame piece, which is subsequent packet piece, when this class is in the "split packet" state.

Parameters:
fhp - The first header pointer.
frameAnnotation - Frame annotation from the current frame.
Returns:
true if there was any problem decomposing this frame. The method will do as much as possible with a frame even if it has problems. False = no frame problems.

abortSplitHeader

private void abortSplitHeader(int firstPieceLength)
I use this method when I must discard a packet header and the first frame piece during the "split packet header" scenario. It discards the fragments and accounts for them in status.


abortSplitPacket

private void abortSplitPacket(int firstPieceLength)
I use this method when I must discard the first packet fragment and create a short packet during the "split packet" scenario.


discardUnexpectedPiece

private boolean discardUnexpectedPiece(int fhp)
I use this method when I encounter an unexpected piece, which I discard, during the "free state" scenario.


resolveIrrationalPacket

private void resolveIrrationalPacket()
A packet length must be rational. If it were not and the Path Service tried to construct an irrational-length packet, then up to 64 kb of good packet data could be lost. This method cleans up after an irrational length is detected. It drops the current frame and any saved data, and it resets to look for a new packet starting with the next frame.