public class Endpoint extends NetworkElement
send(NetworkElement, Packet)
method is called;handle(NetworkElement, Packet)
is called
with a segment containing non-zero payload;handle(NetworkElement, Packet)
is called
with a segment having the ACK flag set.Modifier and Type | Field and Description |
---|---|
private Link |
networkLayerProtocol
Communication link adjoining this endpoint.
|
protected Receiver |
receiver
Created in the constructor; we assume a universal TCP receiver.
|
protected Endpoint |
remoteEndpoint
Remote endpoint that established a TCP connection
with this local endpoint.
|
protected Sender |
sender
The sender will be created in the constructor based on
the supplied type, such as Tahoe, Reno, etc.
|
lastTimeProcessCalled, name, simulator
Constructor and Description |
---|
Endpoint(Simulator simulator_,
java.lang.String name_,
Endpoint remoteTCPendpoint_,
java.lang.String senderType_,
int rcvWindow_)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
getLocalRcvWindow()
Returns the receive window size for this endpoint (in bytes)
by getting it from the local Receiver component.
|
Link |
getNetworkLayerProtocol() |
Endpoint |
getRemoteTCPendpoint() |
Sender |
getSender() |
void |
handle(NetworkElement source_,
Packet packet_)
Handle the data segments received from the remote endpoint.
|
void |
process(int mode_)
Before calling the local
Sender , this method
calls Simulator.checkExpiredTimers(TimedComponent)
to fire the Sender.rtoTimer if it expired. |
void |
send(NetworkElement source_,
Packet newDataPkt_)
"Sends" segments by passing them to the network layer protocol object.
|
void |
setLink(Link adjoiningLink_)
Configures this endpoint with the adjoining
communication link object, the attribute
networkLayerProtocol . |
(package private) void |
setRemoteTCPendpoint(Endpoint remoteTCPendpoint) |
void |
timerExpired(int timerType_)
Callback method to call when a simulated timer expires.
|
getName, getSimulator
private Link networkLayerProtocol
protected Receiver receiver
protected Endpoint remoteEndpoint
protected Sender sender
public Endpoint(Simulator simulator_, java.lang.String name_, Endpoint remoteTCPendpoint_, java.lang.String senderType_, int rcvWindow_) throws java.lang.Exception
simulator_
- the runtime environmentname_
- the name given to this endpointremoteTCPendpoint_
- the remote endpoint that established a TCP connection
with this local endpoint, if anysenderType_
- the TCP version of the Sender contained in this endpoint—one of: "Tahoe", "Reno", or "NewReno")rcvWindow_
- the size of the receive window for the TCP Receiver contained in this endpointjava.lang.Exception
- when an unknown TCP sender type parameter is passed inpublic int getLocalRcvWindow()
public Link getNetworkLayerProtocol()
public Endpoint getRemoteTCPendpoint()
public Sender getSender()
public void handle(NetworkElement source_, Packet packet_)
Handle the data segments received from the remote endpoint. By default, our in simulator the communication is one-way, meaning the the sending endpoint sends data and the receiving endpoint sends only ACKs (no data). However, this implementation allows for ACKs piggybacked on data segments from the receiving endpoint.
The actual work is delegated to the sender (for segments that carry an acknowledgment) or to the receiver (for segments that carry data), or both.
handle
in class NetworkElement
packet_
- an acknowledgment received from the receiver.source_
- the immediate source network element that passes this packet;
which may not be the original source that generated this packetpublic void process(int mode_)
Sender
, this method
calls Simulator.checkExpiredTimers(TimedComponent)
to fire the Sender.rtoTimer
if it expired.
If the received segment contained an ACK, this method will at
the end call Simulator.checkExpiredTimers(TimedComponent)
to fire the Receiver.delayedACKtimer
and have
the receiver transmit any cumulative ACKs.
process
in class NetworkElement
mode_
- processing mode: the value 1
requests processing of the sender component of this endpoint;
the value 2
requests processing of the receiver component
of this endpointSimulator.run(java.nio.ByteBuffer, int)
public void send(NetworkElement source_, Packet newDataPkt_)
send
in class NetworkElement
source_
- the source of the messagenewDataPkt_
- the new message to sendpublic void setLink(Link adjoiningLink_)
networkLayerProtocol
.adjoiningLink_
- the adjoining communication link to setvoid setRemoteTCPendpoint(Endpoint remoteTCPendpoint)
remoteTCPendpoint
- the remote TCP endpoint to setpublic void timerExpired(int timerType_)
TimedComponent