hans-3.0.2: Network Stack

Safe HaskellNone
LanguageHaskell2010

Hans.Tcp.SendWindow

Contents

Synopsis

Remote Window

data Window Source #

This structure holds bookkeeping variables for the remote end's receive window, as well as the retransmit queue.

emptyWindow Source #

Arguments

:: TcpSeqNum

SND.NXT

-> TcpSeqNum

SND.WND

-> TSClock 
-> Window 

sndNxt :: Getting r Window TcpSeqNum Source #

The value of SND.NXT.

NOTE: SND.UNA <= SND.NXT < SND.UNA + SND.WND

setSndNxt :: TcpSeqNum -> Window -> (Window, Bool) Source #

Only sets the value of SND.NXT when the retransmit queue is empty.

sndUna :: Getting r Window TcpSeqNum Source #

The value of SND.UNA -- the left-edge of the send window.

sndWnd :: Lens' Window TcpSeqNum Source #

The value of SND.WND.

nullWindow :: Window -> Bool Source #

True when the window is empty.

fullWindow :: Window -> Bool Source #

True when the window is full.

flushWindow :: Window -> (Window, ()) Source #

Remove everything from the remote window.

Timestamp Clock

updateTSClock :: Config -> UTCTime -> TSClock -> TSClock Source #

Update the timestamp clock, and return the new value of TSval.

tsVal :: Getting r TSClock Word32 Source #

The current value of the TS clock.

Packet Processing

queueSegment :: Config -> UTCTime -> (Word32 -> TcpSeqNum -> TcpHeader) -> ByteString -> Window -> (Window, Maybe (Bool, TcpHeader, ByteString)) Source #

Returns the new send window, as well as boolean indicating whether or not the retransmit timer needs to be started.

retransmitTimeout :: Window -> (Window, Maybe (TcpHeader, ByteString)) Source #

A retransmit timer has gone off: reset the sack bit on all segments in the queue; if the left-edge exists, mark it as having been retransmitted, and return it back to be sent.

XXX: does this need to update the TS clock?

ackSegment :: Config -> UTCTime -> TcpSeqNum -> Window -> (Window, Maybe (Bool, Maybe NominalDiffTime)) Source #

Remove all segments of the send window that occur before this sequence number, and increase the size of the available window. When the segment doesn't acknowledge anything in the window, Nothing as the second parameter. Otherwise, return a boolean that is True when there are no outstanding segments, and a measurement of the RTT when the segment has not been retransmitted.

Selective Ack

handleSack :: [SackBlock] -> Window -> (Window, [(TcpHeader, ByteString)]) Source #

Process a sack option, and return the updated window, and the segments that are missing from the remote window.