Difference between revisions of "TTCPSendBuffer"
(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:47, 30 May 2018
Return to Unit TCP
Description
To be documented
Class definitions
TTCPSendBuffer = class(TSocketBuffer)
constructor Create(ASocket:TTransportSocket);
|
|
destructor Destroy; override;
|
|
private
| |
FFirst:PTCPSegment;
|
Pointer to First Segment |
FLast:PTCPSegment;
|
Pointer to Last Segment |
function AddSegment(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 Local (ISS) |
NextSequence:LongWord;
|
Next Sequence number to Send (SND.NXT |
LastSequence:LongWord;
|
Last Sequence number in Buffer |
LastAcknowledge:LongWord;
|
Last Acknowledged number from Remote (SND.UNA)
Note: LastAcknowledge is the NextSequence that Remote expects to Receive or the first Unacknowledged Sequence number. If LastAcknowledge equals NextSequence all segments have been Acknowledged LastSequence is the last sequence in our buffer to send. If NextSequence equals LastSequence there is no more data to send. |
UrgentPointer:LongWord;
|
(SND.UP) |
MaxSeg:Word;
|
Remote Max Segment Size (Learned from Remote) |
WindowSize:LongWord;
|
Remote Window Size (SND.WND) |
WindowScale:Byte;
|
Remote Window Scale |
WindowTimeout:Int64;
|
Timeout for probing small/zero Window |
CongestionWindow:Word;
|
Slow Start Window Size |
SynSequence:LongWord;
|
Sequence number of our SYN |
FinSequence:LongWord;
|
Sequence number of our FIN |
WindowSequence:LongWord;
|
Sequence number of last Window update (SND.WL1) |
WindowAcknowledge:LongWord;
|
Acknowledge number of last Window update (SND.WL2) |
NoPush:Boolean;
|
Disable Push on final segment |
NoSack:Boolean;
|
Selective Ack not in use |
NoNagle:Boolean;
|
Nagle not in use |
VjSa:LongWord;
|
VJ's alg, standard average |
VjSd:LongWord;
|
VJ's alg, standard deviation |
VjLast:LongWord;
|
VJ's alg, last transmit time |
function CheckIdle:Boolean;
|
|
function SynAcknowledged:Boolean;
|
|
function FinAcknowledged:Boolean;
|
|
function TestAcknowledge(AAcknowledge:LongWord):Boolean;
|
|
function CheckAcknowledge(AAcknowledge:LongWord):Boolean;
|
|
function ValidateAcknowledge(AAcknowledge:LongWord):Boolean;
|
|
function WriteData(var ABuffer; ASize,AFlags:Integer):Boolean;
|
|
function Finish:Boolean;
|
|
function Synchronize:Boolean;
|
|
function ReadSegment(var ASequence:LongWord; var AUrgent:Word; var AFlags:Byte; var AData:Pointer; var ASize:Word; AForce:Boolean):Boolean;
|
|
function AcknowledgeSegments(ASequence,AAcknowledge:LongWord; AWindow:Word):Boolean;
|
|
function TimestampSegment(AOptions:Pointer; var AOffset:Word):Boolean;
|
|
function SelectiveAckSegments(AOptions:Pointer; var AOffset:Word; ASize:Byte):Boolean;
|
Function declarations
constructor TTCPSendBuffer.Create;
Note | None documented |
---|
destructor TTCPSendBuffer.Destroy;
Note | None documented |
---|
function TTCPSendBuffer.AddSegment(ASequence:LongWord; AFlags:Byte; ASize:Word):PTCPSegment;
Sequence | Sequence is the start sequence |
---|---|
Size | Size can be zero
Size should not include the SYN and FIN sequence |
function TTCPSendBuffer.RemoveSegment(ASegment:PTCPSegment):Boolean;
Note | None documented |
---|
procedure TTCPSendBuffer.FlushSegments(All:Boolean);
Note | None documented |
---|
procedure TTCPSendBuffer.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 TTCPSendBuffer.CheckIdle:Boolean;
Note | None documented |
---|
function TTCPSendBuffer.SynAcknowledged:Boolean;
Note | None documented |
---|
function TTCPSendBuffer.FinAcknowledged:Boolean;
Note | None documented |
---|
function TTCPSendBuffer.TestAcknowledge(AAcknowledge:LongWord):Boolean;
Note | If SEG.ACK =< ISS, or SEG.ACK > SND.NXT then the ACK is unacceptable
Only ever used when Socket is in SYN_SENT state |
---|
function TTCPSendBuffer.CheckAcknowledge(AAcknowledge:LongWord):Boolean;
Note | If SND.UNA =< SEG.ACK =< SND.NXT then the ACK is acceptable
Only ever used when Socket is in SYN_REC state |
---|
function TTCPSendBuffer.ValidateAcknowledge(AAcknowledge:LongWord):Boolean;
Note | If the ACK acks something not yet sent (SEG.ACK > SND.NXT) then send an ACK
Used when Socket is in any of the Synchronized states |
---|
function TTCPSendBuffer.WriteData(var ABuffer; ASize,AFlags:Integer):Boolean;
Flags | Flags is for MSG_PEEK and MSG_OOB when applicable |
---|---|
Note | Data that will not fit in the Buffer is simply discarded
Send coalescing is handled here by checking Last segment
|
Socket Timing | Whenever data is written to the buffer a notification is sent to the socket thread to check the socket immediately. This ensures that the segment is sent immediately if acceptable or otherwise will be sent when an acknowledge is received from the remote due to the Nagle algorithm. |
function TTCPSendBuffer.Finish:Boolean;
Socket Timing | When the FIN segment is written to the buffer a notification is sent to the socket thread to check the socket immediately. This ensures that the segment will be sent to the remote either immediately or after the Nagle delay. |
---|
function TTCPSendBuffer.Synchronize:Boolean;
Socket Timing | When the SYN segment is written to the buffer a notification is sent to the socket thread to check the socket immediately. This ensures that the segment will be sent to the remote immediately. |
---|
function TTCPSendBuffer.ReadSegment(var ASequence:LongWord; var AUrgent:Word; var AFlags:Byte; var AData:Pointer; var ASize:Word; AForce:Boolean):Boolean;
Note | Nagle Algorithm and Retry Timeouts are handled here |
---|---|
Socket Timing | For each sent segment a notification is scheduled for the socket thread to check the socket in TCP_RETRY_TIMEOUT[Segment.Count] milliseconds. This is to ensure that the segment is retried if not acknowledged by that time.
|
function TTCPSendBuffer.AcknowledgeSegments(ASequence,AAcknowledge:LongWord; AWindow:Word):Boolean;
Note | Sequence, Acknowledge and Window are from the received Segment |
---|---|
Socket Timing | For each acknowledged segment a notification is sent to the socket thread to check the socket immediately. This is to ensure that segments waiting to be sent due to the Nagle algorithm are sent on receipt of an acknowledge. |
function TTCPSendBuffer.TimestampSegment(AOptions:Pointer; var AOffset:Word):Boolean;
Offset | Offset points to the point to extract the timestamp option |
---|
function TTCPSendBuffer.SelectiveAckSegments(AOptions:Pointer; var AOffset:Word; ASize:Byte):Boolean;
Offset | Offset points to the point to start extracting SACKS |
---|---|
Size | Size includes the Option and Size |
Return to Unit Reference