public class Link extends NetworkElement
NetworkElement
Modifier and Type | Field and Description |
---|---|
protected double |
lastTimeProcessCalledMode1
Parameters that override
NetworkElement.lastTimeProcessCalled
because Link has different modes of processing. |
protected double |
lastTimeProcessCalledMode2 |
protected NetworkElement |
node1
|
protected NetworkElement |
node2 |
protected double[] |
packetDelaysN1toN2
Delay times for packets stored in the list
packetsFromN1toN2 ,
in simulation-clock ticks. |
protected double[] |
packetDelaysN2toN1
Similar to
packetDelaysN1toN2 . |
protected java.util.ArrayList<Packet> |
packetsFromN1toN2
|
protected java.util.ArrayList<Packet> |
packetsFromN2toN1
|
protected double |
propagationTime
Propagation time for this communication link.
|
protected double |
transmissionTime
Transmission time for this communication link
(per packet, assuming all packets are of the same size!).
|
lastTimeProcessCalled, name, simulator
Constructor and Description |
---|
Link(Simulator simulator_,
java.lang.String name_,
NetworkElement node1_,
NetworkElement node2_)
Constructor.
|
Link(Simulator simulator_,
java.lang.String name_,
NetworkElement node1_,
NetworkElement node2_,
double transmissionTime_,
double propagationTime_)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
deliverArrivedPackets(java.util.ArrayList<Packet> packets_,
double[] packetDelays_,
NetworkElement node_,
double lastTimeProcessCalled_)
Helper method to deliver the packets that propagated
through the link and arrived to the other end, if any.
Note that we assume that the packets are enqueued on the first-come-first-served basis, so their delays are sorted in an ascending order. |
protected void |
enqueueNewPacket(java.util.ArrayList<Packet> packets_,
double[] packetDelays_,
Packet packet_)
Helper method to enqueue a new packet into one
of the lists and calculate its delay on the link.
|
double |
getPropagationTime()
Parameter getter.
|
double |
getTransmissionTime()
Parameter getter.
|
void |
handle(NetworkElement dummySource_,
Packet dummyPacket_)
Link does not "handle" incoming
packets, so this method does nothing.
|
void |
process(int mode_)
This method should be called to signal the passage of time.
|
void |
send(NetworkElement source_,
Packet packet_)
The link just accepts any new packets given to it
and enqueues the new packet behind any existing packets.
|
void |
setPropagationTime(double propagationTime_)
Parameter setter.
|
void |
setTransmissionTime(double transmissionTime_)
Parameter setter.
|
getName, getSimulator
protected double lastTimeProcessCalledMode1
NetworkElement.lastTimeProcessCalled
because Link has different modes of processing.protected double lastTimeProcessCalledMode2
protected NetworkElement node1
protected NetworkElement node2
protected double[] packetDelaysN1toN2
packetsFromN1toN2
,
in simulation-clock ticks. The delay for each packet is calculated
when the packet is received in send(NetworkElement, Packet)
and the delay is decremented in process(int)
until
it reaches zero. At this time, the packet is delivered to
node2
.protected double[] packetDelaysN2toN1
packetDelaysN1toN2
.protected java.util.ArrayList<Packet> packetsFromN1toN2
protected java.util.ArrayList<Packet> packetsFromN2toN1
protected double propagationTime
protected double transmissionTime
public Link(Simulator simulator_, java.lang.String name_, NetworkElement node1_, NetworkElement node2_)
simulator_
- the runtime environmentname_
- the name given to this linknode1_
- one node to be connected with this linknode2_
- the other node to be connected with this linkpublic Link(Simulator simulator_, java.lang.String name_, NetworkElement node1_, NetworkElement node2_, double transmissionTime_, double propagationTime_)
simulator_
- the runtime environmentname_
- the name given to this linknode1_
- one node to be connected with this linknode2_
- the other node to be connected with this linktransmissionTime_
- the transmission time associated with this link (measured in clock ticks)propagationTime_
- the propagation time associated with this link (measured in clock ticks)protected void deliverArrivedPackets(java.util.ArrayList<Packet> packets_, double[] packetDelays_, NetworkElement node_, double lastTimeProcessCalled_)
packets_
- the list of packetspacketDelays_
- the array of delays associated with packetsnode_
- the node to which the arrived packets will be deliveredlastTimeProcessCalled_
- protected void enqueueNewPacket(java.util.ArrayList<Packet> packets_, double[] packetDelays_, Packet packet_)
packets_
- the list of packetspacketDelays_
- the array of delays associated with packetspacket_
- the new packet to enqueuepublic double getPropagationTime()
public double getTransmissionTime()
public void handle(NetworkElement dummySource_, Packet dummyPacket_)
handle
in class NetworkElement
dummySource_
- this dummy parameter is ignoreddummyPacket_
- this dummy parameter is ignoredNetworkElement.handle(NetworkElement, sime.Packet)
public void process(int mode_)
process
in class NetworkElement
mode_
- the transmission mode for this link; value "0" means both-way transmission,
value "1" means one-way transmission from node1
to node2
, and
value "2" means one-way transmission from node2
to node1
NetworkElement.process(int)
public void send(NetworkElement source_, Packet packet_)
process(int)
is called.source_
is used to
distinguish the nodes connected to the link's ends.
At the time when a packet is enqueued, its delay is also
calculated and stored in the corresponding array
(packetDelaysN1toN2
or packetDelaysN2toN1
).
Note: In the current implementation when calculating the
packet delay, we do not check the packet length.
The transmission time transmissionTime
is assumed to be the same for all packets. Of course, this is not true
because TCP acknowledgment-only segments are much shorter than
TCP segments carrying data. this is a TODO item.
send
in class NetworkElement
source_
- the source of the packetpacket_
- the new packet in flight on this linkNetworkElement.send(NetworkElement, Packet)
public void setPropagationTime(double propagationTime_)
propagationTime_
- the propagation time to set (in simulator clock ticks)public void setTransmissionTime(double transmissionTime_)
transmissionTime_
- the transmission time to set (in simulator clock ticks)