IcmpPacket

public class IcmpPacket implements NetworkPacket<SimEntity>

Represents a ping (ICMP protocol) packet that can be used to gather information from the network layer. An IcmpPacket traverses the network topology similar to a HostPacket, but it collects information like bandwidths, and Round Trip Time etc.

You can set all the parameters to an IcmpPacket that can be applied to a HostPacket. So if you want to find out the kind of information that a particular type of HostPacket is experiencing, set the size and network class of an IcmpPacket to the same as the HostPacket, and send it to the same destination from the same source.

Author:Gokul Poduval, Chen-Khong Tham, National University of Singapore

Constructors

IcmpPacket

public IcmpPacket(String name, int packetID, long size, SimEntity source, SimEntity destination, int netServiceLevel)

Constructs a new ICMP packet.

Parameters:
  • name – Name of this packet
  • packetID – the ID of this packet
  • size – size of the packet
  • source – the entity that sends out this packet
  • destination – the entity to which this packet is destined
  • netServiceLevel – the class of traffic this packet belongs to

Methods

addBaudRate

public void addBaudRate(double baudRate)

Register the baud rate of the output link where the current entity that holds the IcmpPacket will send it next. Every entity that the IcmpPacket traverses should add the baud rate of the link on which this packet will be sent out next.

Parameters:
  • baudRate – the entity’s baud rate in bits/s

addEntryTime

public void addEntryTime(double time)

Register the time the packet arrives at an entity such as a Router or CloudResource. This method should be called by routers and other entities when the IcmpPacket reaches them along with the current simulation time.

Parameters:

addExitTime

public void addExitTime(double time)

Register the time the packet leaves an entity such as a Router or CloudResource. This method should be called by routers and other entities when the IcmpPacket is leaving them. It should also supply the current simulation time.

Parameters:

addHop

public void addHop(SimEntity entity)

Add an entity where the IcmpPacket traverses. This method should be called by network entities that count as hops, for instance Routers or CloudResources. It should not be called by links etc.

Parameters:
  • entity – the id of the hop that this IcmpPacket is traversing

getBaudRate

public double getBaudRate()

Gets the bottleneck bandwidth between the source and the destination.

Returns:the bottleneck bandwidth

getDestination

public SimEntity getDestination()

getDetailBaudRate

public List<Double> getDetailBaudRate()

Gets a read-only list of all the bandwidths that this packet has traversed.

getDetailEntryTimes

public List<Double> getDetailEntryTimes()

Gets a read-only list of all entry times that the packet has traversed.

getDetailExitTimes

public List<Double> getDetailExitTimes()

Gets a read-only list of all exit times from all entities that the packet has traversed.

getHopsList

public List<SimEntity> getHopsList()

Gets a read-only list of all entities that this packet has traversed, that defines the hops it has made.

getId

public int getId()

Returns the ID of this packet

Returns:packet ID

getLastHop

public SimEntity getLastHop()

Gets the entity that was the last hop where this packet has traversed.

getNetServiceLevel

public int getNetServiceLevel()

Gets the network service type of this packet

Returns:the network service type

getNumberOfHops

public int getNumberOfHops()

Gets the number of hops that the packet has traversed. Since the packet takes a round trip, the same router may have been traversed twice.

getReceiveTime

public double getReceiveTime()

getSendTime

public double getSendTime()

getSize

public long getSize()

getSource

public SimEntity getSource()

getTag

public int getTag()

Gets the packet direction that indicates if it is going or returning. The direction can be CloudSimTags.ICMP_PKT_SUBMIT or CloudSimTags.ICMP_PKT_RETURN.

getTotalResponseTime

public double getTotalResponseTime()

Gets the total time that the packet has spent in the network. This is basically the Round-Trip Time (RTT). Dividing this by half should be the approximate latency.

RTT is taken as the “final entry time” - “first exit time”.

Returns:total round-trip time

setDestination

public void setDestination(SimEntity destination)

setLastHop

public void setLastHop(SimEntity entity)

Sets the entity that was the last hop where this packet has traversed.

Parameters:
  • entity – the entity to set as the last hop

setNetServiceLevel

public void setNetServiceLevel(int netServiceLevel)

Sets the network service type of this packet.

By default, the service type is 0 (zero). It is depends on the packet scheduler to determine the priority of this service level.

Parameters:
  • netServiceLevel – the service level to set

setReceiveTime

public void setReceiveTime(double time)

setSendTime

public void setSendTime(double time)

setSize

public boolean setSize(long size)

Sets the size of the packet.

Parameters:
  • size – the size to set
Returns:

true if a positive value was given, false otherwise

setSource

public void setSource(SimEntity source)

setTag

public boolean setTag(int tag)

Sets the packet direction that indicates if it is going or returning. The direction can be CloudSimTags.ICMP_PKT_SUBMIT or CloudSimTags.ICMP_PKT_RETURN.

Parameters:
  • tag – the direction to set
Returns:

true if the tag is valid, false otherwise

toString

public String toString()

Returns a human-readable information of this packet.

Returns:description of this packet