public abstract class Sender extends java.lang.Object implements TimedComponent
Note: If you are in doubt or some of this code is conflicting
your textbook, please check the ultimate sources:
RFC 5681
and RFC 2581.
An older document, although outdated, may also be of interest:
RFC 2001.
Do not rely on any textbooks for precise details!
Read the textbook(s) for high-level understanding of
the material; read the RFCs for precise details.
SenderTahoe
,
SenderReno
,
SenderNewReno
Modifier and Type | Field and Description |
---|---|
protected java.nio.ByteBuffer |
bytestream
TCP bytestream to send to the receiver endpoint.
|
(package private) int |
congWindow
Current congestion window size, in bytes.
|
protected SenderState |
currentState
Sender's current state.
|
protected int |
dupACKcount
Counter of duplicate acknowledgments.
|
protected static int |
dupACKthreshold
The threshold number of duplicate acknowledgments after which
the TCP sender will assume that the oldest outstanding segment
is lost and perform Fast Retransmit.
|
(package private) TimerSimulated |
idleConnectionTimer
This is a TCP connection "inactivity-timeout" timer.
|
protected TimerSimulated |
idleConnectionTimerHandle
Handle to a running "idle-connection" timer (
idleConnectionTimer ),
so it can be canceled, if needed. |
protected int |
lastByteAcked
Pointer to the last byte ACKed so far.
|
protected int |
lastByteSent
Pointer to the last byte sent so far.
|
protected int |
lastByteSentBefore3xDupAcksRecvd
Pointer to the last byte sent
lastByteSent
at the time when dupACKthreshold duplicate acknowledgments
were received. |
(package private) Endpoint |
localEndpoint
Local endpoint that contains this sender object.
|
static int |
MSS
Maximum segment size, in bytes.
|
protected int |
rcvWindow
Last advertised size of the currently available space in the receiver's buffer.
|
(package private) RTOEstimator |
rtoEstimator
Retransmission timer (RTO) estimation;
performed after each new ACK is received.
|
(package private) TimerSimulated |
rtoTimer
Retransmission timer (RTO) value, measured in simulator time ticks
that are defined by
Simulator.getTimeIncrement() . |
protected TimerSimulated |
rtoTimerHandle
Handle to a running RTO timer (
rtoTimer ), so it can be canceled, if needed. |
(package private) int |
SSThresh
The Slow-Start threshold is a dynamically-set value indicating
an upper bound on the congestion window above which a
TCP sender transitions from Slow-Start to the Congestion Avoidance
state.
|
(package private) static int |
TIMER_DEFAULT
Default value of the timer, in our case equals to 3 × RTT.
|
Modifier | Constructor and Description |
---|---|
protected |
Sender(Endpoint localTCPendpoint_)
Base class constructor; not public.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
cancelRTOtimer()
Helper method, called from derived classes to cancel
the retransmission (RTO) timer when there are no
more unacknowledged segments.
|
(package private) Segment |
getOldestUnacknowledgedSegment()
Helper method to extract the oldest unacknowledged segment
from the input bytestream.
|
int |
getTotalBytesTransmitted()
Accessor for retrieving the statistics of the total number
of bytes successfully transmitted so far during this
simulation.
|
void |
handle(Segment ack_)
Processes ACKs received from the receiver.
|
(package private) abstract void |
onExpiredRTOtimer()
Helper method, called on the expired retransmission timeout (RTO) timer
from the sender's current state object
SenderState.handleRTOtimeout(sime.tcp.Segment) . |
(package private) abstract void |
onThreeDuplicateACKs()
Helper method, called on threshold number of duplicate ACKs.
|
void |
resetParametersToSlowStart()
This method provides a single place to reset
the congestion parameters when the sender needs
to transition to the slow start state from another state.
|
void |
send(byte[] newData_)
"Sends" segments by passing them to the network layer protocol object.
|
(package private) void |
startIdleConnectionTimer()
Helper method to start up the idle-connection timer countdown.
|
(package private) void |
startRTOtimer()
Helper method, called from derived classes to start up
or re-start the retransmission (RTO) timer countdown.
|
void |
timerExpired(int timerType_)
Callback method to call when a simulated timer expires.
|
protected java.nio.ByteBuffer bytestream
int congWindow
protected SenderState currentState
protected int dupACKcount
protected static final int dupACKthreshold
Note that because the threshold value is usually 3,
all related variables are named with 3dupAcks,
such as lastByteSentBefore3xDupAcksRecvd
or
the method onThreeDuplicateACKs()
.
TimerSimulated idleConnectionTimer
rtoTimer
).
Check also Issues in TCP Slow-Start Restart After Idle.
protected TimerSimulated idleConnectionTimerHandle
idleConnectionTimer
),
so it can be canceled, if needed.protected int lastByteAcked
protected int lastByteSent
protected int lastByteSentBefore3xDupAcksRecvd
lastByteSent
at the time when dupACKthreshold
duplicate acknowledgments
were received. Only when all the data outstanding at
that moment are acknowledged will the sender have
fully recovered from the loss.
In the worst case scenario, all of the currently
outstanding data might have been lost and will
need to be retransmitted. The sender doesn't know
this, so it keeps track of it.
(Recall that a Go-Back-N protocol would
now re-transmit all outstanding data.)
Endpoint localEndpoint
public static final int MSS
protected int rcvWindow
RTOEstimator rtoEstimator
RTOEstimator
TimerSimulated rtoTimer
Simulator.getTimeIncrement()
.
The timer is activated when a new segment is transmitted. When all outstanding segments are acknowledged, the timer is deactivated. When a regular acknowledgment is received and there are still outstanding, non-acknowledged segments, the timer should be re-started.
protected TimerSimulated rtoTimerHandle
rtoTimer
), so it can be canceled, if needed.int SSThresh
static final int TIMER_DEFAULT
protected Sender(Endpoint localTCPendpoint_)
void cancelRTOtimer()
Segment getOldestUnacknowledgedSegment()
public int getTotalBytesTransmitted()
public void handle(Segment ack_)
send(byte[])
.ack_
- An acknowledgment received from the receiver.abstract void onExpiredRTOtimer()
SenderState.handleRTOtimeout(sime.tcp.Segment)
.
Works slightly differently for different types of TCP senders (Tahoe, Reno, etc.).SenderState
abstract void onThreeDuplicateACKs()
dupACKthreshold
, but this method is named
after the commonly used value of 3 dupACKs.SenderState
public void resetParametersToSlowStart()
Note that this method does not modify the
current value of SSThresh
.
public void send(byte[] newData_)
send()
regardless of its current state. The sender state is used
in handle(Segment)
to process the acknowledgment
segments from the receiver. During ACK processing, the
sending parameters will be set, that are used in this
send()
method.newData_
- The new message to sendvoid startIdleConnectionTimer()
idleConnectionTimer
void startRTOtimer()
rtoTimer
public void timerExpired(int timerType_)
rtoTimer
), set as type "1"idleConnectionTimer
), set as type "2"
In case of an expired RTO timer, this method will ask
the current state object to handle the expired-timer event
which, in turn, will call onExpiredRTOtimer()
timerExpired
in interface TimedComponent
timerType_
- the type of the timer that expired (rtoTimer
or idleConnectionTimer
)TimedComponent