org.jnetpcap.protocol.tcpip
Class Tcp.SACK

java.lang.Object
  extended by org.jnetpcap.nio.JMemory
      extended by org.jnetpcap.nio.JBuffer
          extended by org.jnetpcap.packet.JHeader
              extended by org.jnetpcap.packet.JSubHeader<Tcp>
                  extended by org.jnetpcap.protocol.tcpip.Tcp.TcpOption
                      extended by org.jnetpcap.protocol.tcpip.Tcp.SACK
All Implemented Interfaces:
JPayloadAccessor
Enclosing class:
Tcp

@Header(id=5)
public static class Tcp.SACK
extends Tcp.TcpOption

TCP may experience poor performance when multiple packets are lost from one window of data. With the limited information available from cumulative acknowledgments, a TCP sender can only learn about a single lost packet per round trip time. An aggressive sender could choose to retransmit packets early, but such retransmitted segments may have already been successfully received.

SACK is a strategy which corrects this behavior in the face of multiple dropped segments. With selective acknowledgments, the data receiver can inform the sender about all segments that have arrived successfully, so the sender need retransmit only the segments that have actually been lost.

The SACK option is to be sent by a data receiver to inform the data sender of non-contiguous blocks of data that have been received and queued. The data receiver awaits the receipt of data (perhaps by means of retransmissions) to fill the gaps in sequence space between received blocks. When missing segments are received, the data receiver acknowledges the data normally by advancing the left window edge in the Acknowledgement Number Field of the TCP header. The SACK option does not change the meaning of the Acknowledgement Number field.

This note defines an extension of the SACK option for TCP. RFC 2018 specified the use of the SACK option for acknowledging out-of-sequence data not covered by TCP's cumulative acknowledgement field. This note extends RFC 2018 by specifying the use of the SACK option for acknowledging duplicate packets. This note suggests that when duplicate packets are received, the first block of the SACK option field can be used to report the sequence numbers of the packet that triggered the acknowledgement. This extension to the SACK option allows the TCP sender to infer the order of packets received at the receiver, allowing the sender to infer when it has unnecessarily retransmitted a packet. A TCP sender could then use this information for more robust operation in an environment of reordered packets, ACK loss, packet replication, and/or early retransmit timeouts.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jnetpcap.protocol.tcpip.Tcp.TcpOption
Tcp.TcpOption.OptionCode
 
Nested classes/interfaces inherited from class org.jnetpcap.packet.JHeader
JHeader.State
 
Nested classes/interfaces inherited from class org.jnetpcap.nio.JMemory
JMemory.Type
 
Field Summary
 
Fields inherited from class org.jnetpcap.packet.JHeader
annotatedHeader, BYTE, EMPTY_HEADER_ARRAY, isSubHeader, packet, state
 
Fields inherited from class org.jnetpcap.nio.JMemory
JNETPCAP_LIBRARY_NAME, MAX_DIRECT_MEMORY_DEFAULT, POINTER
 
Constructor Summary
Tcp.SACK()
           
 
Method Summary
 int blockCount()
          Calculates the number of SACK blocks within this option header.
 long[] blocks()
          Gets the block field of the option header, and returns the data as an array of unsigned 32 bit integers (java stored as long integers to preserve the sign).
 void blocks(long[] array)
          Copies the supplied data in the array to option header.
 int blocksLength()
          Calculates the length of the block field.
 long[] blocksToArray(long[] array)
          Gets the block field of the option header, and returns the data as an array of unsigned 32 bit integers (java stored as long integers to preserve the sign).
 
Methods inherited from class org.jnetpcap.protocol.tcpip.Tcp.TcpOption
code, code, length, length, lengthCheck, lengthDescription
 
Methods inherited from class org.jnetpcap.packet.JSubHeader
getLength, getOffset, getParent, setLength, setOffset, setParent
 
Methods inherited from class org.jnetpcap.packet.JHeader
decode, decodeHeader, getAnnotatedHeader, getDescription, getFields, getGap, getGapLength, getGapOffset, getHeader, getHeaderLength, getHeaderOffset, getId, getIndex, getName, getNextHeaderId, getNextHeaderOffset, getNicname, getPacket, getPayload, getPayloadLength, getPayloadOffset, getPostfix, getPostfixLength, getPostfixOffset, getPrefix, getPrefixLength, getPrefixOffset, getPreviousHeaderId, getPreviousHeaderOffset, getState, getSubHeaders, hasDescription, hasGap, hasNextHeader, hasPayload, hasPostfix, hasPrefix, hasPreviousHeader, hasSubHeaders, isFragmented, isGapTruncated, isHeaderTruncated, isPayloadTruncated, isPostfixTruncated, isPrefixTruncated, peer, peer, peerPayloadTo, setPacket, setSubHeaders, sizeof, toString, transferPayloadTo, transferPayloadTo, transferPayloadTo, validateHeader
 
Methods inherited from class org.jnetpcap.nio.JBuffer
findUTF8String, getByte, getByteArray, getByteArray, getByteArray, getDouble, getFloat, getInt, getLong, getShort, getUByte, getUInt, getUShort, getUTF8Char, getUTF8String, getUTF8String, getUTF8String, getUTF8String, isReadonly, order, order, peer, peer, peer, peer, setByte, setByteArray, setByteBuffer, setDouble, setFloat, setInt, setLong, setShort, setShort0, setUByte, setUInt, setUShort, transferFrom, transferFrom, transferFrom, transferTo, transferTo, transferTo
 
Methods inherited from class org.jnetpcap.nio.JMemory
availableDirectMemory, check, cleanup, createReference, isInitialized, isJMemoryBasedOwner, isOwner, maxDirectMemory, peer, reservedDirectMemory, setSize, size, softDirectMemory, toDebugString, toHexdump, toHexdump, totalActiveAllocated, totalAllocateCalls, totalAllocated, totalAllocatedSegments0To255Bytes, totalAllocatedSegments256OrAbove, totalDeAllocateCalls, totalDeAllocated, transferFrom, transferFrom, transferFromDirect, transferOwnership, transferTo, transferTo, transferTo, transferTo, transferTo, transferTo0
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tcp.SACK

public Tcp.SACK()
Method Detail

blockCount

public int blockCount()
Calculates the number of SACK blocks within this option header.

Returns:
number of 64 bit blocks

blocksLength

@Dynamic(value=LENGTH)
public int blocksLength()
Calculates the length of the block field.

Returns:
length of the field in bits

blocks

@Field(offset=16)
public long[] blocks()
Gets the block field of the option header, and returns the data as an array of unsigned 32 bit integers (java stored as long integers to preserve the sign). Each element of the array, is a 1 element of the 2 element block. The even elements starting at index 0 are start sequence numbers, while the odd elements starting at index 1 are the ending sequence numbers past the last acked byte in the stream.

Returns:
blocks field data converted to longs to represent a 32 bit unsigned integer

blocks

public void blocks(long[] array)
Copies the supplied data in the array to option header. The method also updates the option header length field overriding any previously set value there.

Parameters:
array - array containing the block records

blocksToArray

public long[] blocksToArray(long[] array)
Gets the block field of the option header, and returns the data as an array of unsigned 32 bit integers (java stored as long integers to preserve the sign). Each element of the array, is a 1 element of the 2 element block. The even elements starting at index 0 are start sequence numbers, while the odd elements starting at index 1 are the ending sequence numbers past the last acked byte in the stream.

Parameters:
array - preallocated array to store the data
Returns:
the array supplied as argument