Difference between revisions of "Unit TCP"

From Ultibo.org
Jump to: navigation, search
Line 296: Line 296:
 
----
 
----
  
''To be documented''
+
''None defined''
  
 
=== Function declarations ===
 
=== Function declarations ===

Revision as of 02:37, 30 December 2016

Return to Unit Reference


Description


Ultibo TCP (Transmission Control Protocol) unit

Notes:

Segment handling:

Send adds new segments to the end of the list only accepts ACKs for whole segments.

Recv adds/inserts segments in correct SEQ order accepts overlapping segments only sends ACKs for whole segments.

Send will coalesce small data writes into larger segments if options allow this.

Recv will store the segments exactly as received.


TCP Send and Recv do not use a block buffer as per UDP etc. Instead the data for each Segment is stored in memory (TCP_MAX_MSS) allocated with the Segment. The Free and Used values still track the amount of data in the buffer but this method allows OOB data to be handled correctly.

TCP Sequence numbers are compared using modulo 2^32 arithmetic. The following calculations provide the neccessary handling of wraparound etc.

LT = (A - B) < 0

LEQ = (A - B) <= 0

GT = (A - B) > 0

GEQ = (A - B) >= 0


See GlobalSock.pas for actual functions that implement this.

Constants



[Expand]
TCP specific constants TCP_*


[Expand]
TCP socket state constants TCP_STATE_*


[Expand]
TCP header option constants TCPOPT_*


[Expand]
TCP header flag constants TCP_FLAG_*


[Expand]
TCP port constants TCP_PORT_*


Type definitions


To be documented

Public variables


None defined

Function declarations



Initialization functions

[Expand]
procedure TCPInit;
Description: To be documented


TCP functions

[Expand]
function CheckTCP(AFamily:Word; ABuffer:Pointer):Boolean;
Description: Verify that the packet is a valid TCP packet


[Expand]
function GetTCPHeaderOffset(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented


[Expand]
function GetTCPHeaderLength(AFamily:Word; ABuffer:Pointer):Word;
Description: TO be documented


[Expand]
function GetTCPOptionsLength(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented


[Expand]
function GetTCPDataOffset(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented


[Expand]
function GetTCPDataLength(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented


[Expand]
function ChecksumTCPRecv(AFamily:Word; APseudo:PIPPseudo; ABuffer:Pointer; AOffset,ALength:Word):Word;
Description: Validate the Checksum of TCP Pseudo, Header and Data on Receive


[Expand]
function ChecksumTCPSend(AFamily:Word; APseudo:PIPPseudo; AHeader:PTCPHeader; AOptions,AData:Pointer; AOptionsLength,ADataLength:Word):Word;
Description: Checksum the TCP Pseudo, Header, Options and Data on Send


Return to Unit Reference