Difference between revisions of "TTCPRecvBuffer"
(Created page with "Return to Unit TCP __TOC__ === Description === ---- ''To be documented'' === Class definitions === ---- <div class="toccolours mw-collapsible mw-collapsed"...") |
(No difference)
|
Revision as of 01:50, 30 May 2018
Return to Unit TCP
Description
To be documented
Class definitions
TTCPRecvBuffer = class(TSocketBuffer)
constructor Create(ASocket:TTransportSocket);
|
|
destructor Destroy; override;
|
|
private
| |
FUrgent:LongWord;
|
Number of OOB bytes readable from Buffer |
FAvailable:LongWord;
|
Number of bytes readable from Buffer |
FFirst:PTCPSegment;
|
Pointer to First Segment |
FLast:PTCPSegment;
|
Pointer to Last Segment |
function DelayOverride(ASegment:PTCPSegment):Boolean;
|
|
function GetSegment(ASequence:LongWord; ALength:Word):PTCPSegment;
|
|
function GetPrevious(ASequence:LongWord; ALength:Word):PTCPSegment;
|
|
function GetOverlapped(ASequence:LongWord; ALength:Word):PTCPSegment;
|
|
function AddSegment(APrev:PTCPSegment; ASequence:LongWord; AFlags:Byte; ASize:Word):PTCPSegment;
|
|
function RemoveSegment(ASegment:PTCPSegment):Boolean;
|
|
procedure FlushSegments(All:Boolean);
|
|
protected
| |
procedure SetSize(ASize:LongWord); override;
|
|
public
| |
StartSequence:LongWord;
|
Initial Sequence number of Remote (IRS) |
NextSequence:LongWord;
|
Next Sequence number to Receive (RCV.NXT) |
LastSequence:LongWord;
|
Last Sequence number in Buffer (Including Unacknowledged data) |
LastAcknowledge:LongWord;
|
Last Acknowledged number to Remote
Note: NextSequence is the next byte we expect to Receive from Remote. LastAcknowledge will be the first Unacknowledged Seqeunce number of the Remote. LastSequence is the last sequence we have received from the Remote. If NextSequence equals LastSequence and LastAcknowledge equals NextSequence all segments have been Acknowledged. |
UrgentPointer:LongWord;
|
(RCV.UP) |
MaxSeg:Word;
|
Local Max Segment Size |
WindowSize:LongWord;
|
Local Window Size (RCV.WND) |
WindowScale:Byte;
|
Local Window Scale |
LastWindow:LongWord;
|
Last Window value sent to Remote |
SynSequence:LongWord;
|
Sequence number of remote SYN |
FinSequence:LongWord;
|
Sequence number of remote FIN |
NoSack:Boolean;
|
Selective Ack not in use |
function CheckIdle:Boolean;
|
|
function GetUrgent:LongWord;
|
|
function GetAvailable:LongWord;
|
|
function SynReceived:Boolean;
|
|
function FinReceived:Boolean;
|
|
function CheckSequence(ASequence:LongWord; ASize:Word):Boolean;
|
|
function ReadData(var ABuffer; var ASize:Integer; AFlags:Integer):Boolean;
|
|
function WriteSegment(ASequence:LongWord; AUrgent:Word; AFlags:Byte; AData:Pointer; ASize:Word):Boolean;
|
|
function AcknowledgeSegments(var AAcknowledge:LongWord; var AWindow:Word; AForce:Boolean):Boolean;
|
|
function TimestampSegment(AOptions:Pointer; var AOffset:Word):Boolean;
|
|
function SelectiveAckSegments(AOptions:Pointer; var AOffset:Word):Boolean;
|
Function declarations
constructor TTCPRecvBuffer.Create;
Note | None documented |
---|
destructor TTCPRecvBuffer.Destroy;
Note | None documented |
---|
function TTCPRecvBuffer.DelayOverride(ASegment:PTCPSegment):Boolean;
Note | Delayed ack must send an ack at least every two segments |
---|
function TTCPRecvBuffer.GetSegment(ASequence:LongWord; ALength:Word):PTCPSegment;
Sequence | Sequence is the start sequence |
---|---|
Length | Length includes the control bits |
Matching Conditions | ------|
1 Match . |--| . First <= Seqeuence and Last >= Sequence + Length
|
function TTCPRecvBuffer.GetPrevious(ASequence:LongWord; ALength:Word):PTCPSegment;
Sequence | Sequence is the start sequence |
---|---|
Length | Length includes the control bits |
Note | If no Segment is after the passed Sequence returns the last Segment |
Matching Conditions | ------|
1 Match |--| . Sequence + Length <= First
|
function TTCPRecvBuffer.GetOverlapped(ASequence:LongWord; ALength:Word):PTCPSegment;
Sequence | Sequence is the start sequence |
---|---|
Length | Length includes the control bits |
Matching Conditions | ------|
1 Match |----------| Seqeuence <= First and Sequence + Length >= Last
|
function TTCPRecvBuffer.AddSegment(APrev:PTCPSegment; ASequence:LongWord; AFlags:Byte; ASize:Word):PTCPSegment;
Prev | Prev is the Previous segment |
---|---|
Sequence | Sequence is the start sequence |
Size | Size can be zero
Size should not include the SYN and FIN sequence |
function TTCPRecvBuffer.RemoveSegment(ASegment:PTCPSegment):Boolean;
Note | None documented |
---|
procedure TTCPRecvBuffer.FlushSegments(All:Boolean);
Note | None documented |
---|
procedure TTCPRecvBuffer.SetSize(ASize:LongWord);
Size | Size cannot be set smaller than the default or existing |
---|---|
Note | For TCP setting the size does not clear existing segments |
function TTCPRecvBuffer.CheckIdle:Boolean;
Note | None documented |
---|
function TTCPRecvBuffer.GetUrgent:LongWord;
Note | None documented |
---|
function TTCPRecvBuffer.GetAvailable:LongWord;
Note | None documented |
---|
function TTCPRecvBuffer.SynReceived:Boolean;
Note | None documented |
---|
function TTCPRecvBuffer.FinReceived:Boolean;
Note | None documented |
---|
function TTCPRecvBuffer.CheckSequence(ASequence:LongWord; ASize:Word):Boolean;
Note | None documented |
---|
function TTCPRecvBuffer.ReadData(var ABuffer; var ASize:Integer; AFlags:Integer):Boolean;
Size | Passed Size contains size of Buffer and should return the size of Datagram |
---|---|
Flags | Flags is for MSG_PEEK and MSG_OOB when applicable |
function TTCPRecvBuffer.WriteSegment(ASequence:LongWord; AUrgent:Word; AFlags:Byte; AData:Pointer; ASize:Word):Boolean;
Overlap Handling | ------|
1 Entire |----------| Seqeuence <= First and Sequence + Length >= Last
|
---|---|
Socket Timing | For each received segment a notification is scheduled for the socket thread to check the socket in TCP_ACK_TIMEOUT milliseconds. This is the maximum to before the received segment must be acknowledged, but it may be acknowledged earlier if a segment is sent or if there are earlier received segments to be acknowledged as well. |
function TTCPRecvBuffer.AcknowledgeSegments(var AAcknowledge:LongWord; var AWindow:Word; AForce:Boolean):Boolean;
Note | Delayed Ack is handled here by checking Timeout and following segments |
---|---|
Socket Timing | No notifications are sent to or scheduled for the socket thread when checking for received segments to acknowledge. This is because WriteSegment will have scheduled a notification for TCP_ACK_TIMEOUT milliseconds after each segment was received which will ensure they are acknowledged in time. |
function TTCPRecvBuffer.TimestampSegment(AOptions:Pointer; var AOffset:Word):Boolean;
Offset | Offset points to the point to insert the timestamp option |
---|
function TTCPRecvBuffer.SelectiveAckSegments(AOptions:Pointer; var AOffset:Word):Boolean;
Note | None documented |
---|
Return to Unit Reference