Class IcmpPacket

java.lang.Object
org.cloudbus.cloudsim.network.IcmpPacket
All Implemented Interfaces:
NetworkPacket<SimEntity>

public class IcmpPacket extends Object 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.

Since:
CloudSim Toolkit 1.0
Author:
Gokul Poduval, Chen-Khong Tham, National University of Singapore
  • Constructor Summary

    Constructors
    Constructor
    Description
    IcmpPacket(String name, int packetID, long size, SimEntity source, SimEntity destination, int netServiceLevel)
    Creates an ICMP packet.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addBaudRate(double baudRate)
    Register the baud rate (in bits/s) of the output link where the current entity that holds the IcmpPacket will send it next.
    void
    addEntryTime(double time)
    Register the time the packet arrives at an entity such as a Router or CloudResource.
    void
    addExitTime(double time)
    Register the time the packet leaves an entity such as a Router or CloudResource.
    void
    addHop(SimEntity entity)
    Add an entity where the IcmpPacket traverses.
    double
    Gets the bottleneck bandwidth (baud rate) between the source and the destination.
    Gets the entity that the packet is going to.
    Gets a read-only list of all the bandwidths (in bits/s) that this packet has traversed.
    Gets a read-only list containing the time (in seconds) the packet arrived at every entity it has traversed.
    Gets a read-only list of all exit times (in seconds) from all entities that the packet has traversed.
    Gets a read-only list of all entities that this packet has traversed, that defines the hops it has made.
    int
    Gets the ID of this packet
    Gets the entity that was the last hop where this packet has traversed.
    int
    Gets the network service level of this packet
    int
    Gets the number of hops that the packet has traversed.
    double
    Gets the time (in seconds) when the packet was received.
    double
    Gets the time (in seconds) when the packet was sent.
    long
    Gets the size of the packet in bytes.
    Gets the entity that this packet is coming from (the sender).
    Gets the packet direction that indicates if it is going or returning.
    double
    Gets the total time that the packet has spent in the network (in seconds).
    void
    Sets the entity that the packet is going to (the receiver).
    void
    Sets the entity that was the last hop where this packet has traversed.
    void
    setNetServiceLevel(int netServiceLevel)
    Sets the network service type of this packet.
    void
    setReceiveTime(double time)
    Sets the time when the packet was received.
    void
    setSendTime(double time)
    Sets the time when the packet was sent.
    boolean
    setSize(long size)
    Sets the size of the packet.
    void
    Sets the entity that this packet is coming from (the sender).
    void
    Sets the packet direction that indicates if it is going or returning.
    Gets human-readable information of this packet.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • IcmpPacket

      public IcmpPacket(String name, int packetID, long size, SimEntity source, SimEntity destination, int netServiceLevel)
      Creates an 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
  • Method Details

    • getId

      public int getId()
      Gets the ID of this packet
      Returns:
    • toString

      public String toString()
      Gets human-readable information of this packet.
      Overrides:
      toString in class Object
      Returns:
      description of this packet
    • getSize

      public long getSize()
      Description copied from interface: NetworkPacket
      Gets the size of the packet in bytes.
      Specified by:
      getSize in interface NetworkPacket<SimEntity>
      Returns:
      size of the packet in bytes.
    • setSize

      public boolean setSize(long size)
      Sets the size of the packet.
      Parameters:
      size - the size to set (in bytes)
      Returns:
      true if a positive value was given, false otherwise
    • getSource

      public SimEntity getSource()
      Description copied from interface: NetworkPacket
      Gets the entity that this packet is coming from (the sender).
      Specified by:
      getSource in interface NetworkPacket<SimEntity>
      Returns:
    • setSource

      public void setSource(SimEntity source)
      Description copied from interface: NetworkPacket
      Sets the entity that this packet is coming from (the sender).
      Specified by:
      setSource in interface NetworkPacket<SimEntity>
      Parameters:
      source - the source ID to set
    • getDestination

      public SimEntity getDestination()
      Description copied from interface: NetworkPacket
      Gets the entity that the packet is going to.
      Specified by:
      getDestination in interface NetworkPacket<SimEntity>
      Returns:
    • setDestination

      public void setDestination(SimEntity destination)
      Description copied from interface: NetworkPacket
      Sets the entity that the packet is going to (the receiver).
      Specified by:
      setDestination in interface NetworkPacket<SimEntity>
      Parameters:
      destination - the destination to set
    • getSendTime

      public double getSendTime()
      Description copied from interface: NetworkPacket
      Gets the time (in seconds) when the packet was sent.
      Specified by:
      getSendTime in interface NetworkPacket<SimEntity>
      Returns:
    • setSendTime

      public void setSendTime(double time)
      Description copied from interface: NetworkPacket
      Sets the time when the packet was sent.
      Specified by:
      setSendTime in interface NetworkPacket<SimEntity>
      Parameters:
      time - the time to set (in seconds)
    • getReceiveTime

      public double getReceiveTime()
      Description copied from interface: NetworkPacket
      Gets the time (in seconds) when the packet was received.
      Specified by:
      getReceiveTime in interface NetworkPacket<SimEntity>
      Returns:
    • setReceiveTime

      public void setReceiveTime(double time)
      Description copied from interface: NetworkPacket
      Sets the time when the packet was received.
      Specified by:
      setReceiveTime in interface NetworkPacket<SimEntity>
      Parameters:
      time - the time to set (in seconds)
    • 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.
      Returns:
    • getTotalResponseTime

      public double getTotalResponseTime()
      Gets the total time that the packet has spent in the network (in seconds). 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 (in seconds)
    • getBaudRate

      public double getBaudRate()
      Gets the bottleneck bandwidth (baud rate) between the source and the destination.
      Returns:
      the bottleneck bandwidth (in bits/s)
    • 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
    • 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:
      time - current simulation time, use CloudSim.clock() to obtain this
    • 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:
      time - current simulation time, use CloudSim.clock() to obtain this
    • addBaudRate

      public void addBaudRate(double baudRate)
      Register the baud rate (in bits/s) 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
    • getDetailBaudRate

      public List<Double> getDetailBaudRate()
      Gets a read-only list of all the bandwidths (in bits/s) that this packet has traversed.
      Returns:
    • 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.
      Returns:
    • getDetailEntryTimes

      public List<Double> getDetailEntryTimes()
      Gets a read-only list containing the time (in seconds) the packet arrived at every entity it has traversed.
      Returns:
    • getDetailExitTimes

      public List<Double> getDetailExitTimes()
      Gets a read-only list of all exit times (in seconds) from all entities that the packet has traversed.
      Returns:
    • getLastHop

      public SimEntity getLastHop()
      Gets the entity that was the last hop where this packet has traversed.
      Returns:
    • 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
    • getNetServiceLevel

      public int getNetServiceLevel()
      Gets the network service level of this packet
      Returns:
      the network service level
    • 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
    • getTag

      public CloudSimTag getTag()
      Gets the packet direction that indicates if it is going or returning. The direction can be CloudSimTag.ICMP_PKT_SUBMIT or CloudSimTag.ICMP_PKT_RETURN.
      Returns:
    • setTag

      public void setTag(CloudSimTag tag)
      Sets the packet direction that indicates if it is going or returning. The direction can be CloudSimTag.ICMP_PKT_SUBMIT or CloudSimTag.ICMP_PKT_RETURN.
      Parameters:
      tag - the direction to set