AbstractSwitch

public abstract class AbstractSwitch extends CloudSimEntity implements Switch

A base class for implementing Network Switch.

Author:Saurabh Kumar Garg, Manoel Campos da Silva Filho

Constructors

AbstractSwitch

public AbstractSwitch(CloudSim simulation, NetworkDatacenter dc)

Methods

addPacketToBeSentToFirstUplinkSwitch

protected void addPacketToBeSentToFirstUplinkSwitch(HostPacket netPkt)

addPacketToSendToDownlinkSwitch

protected void addPacketToSendToDownlinkSwitch(Switch downlinkSwitch, HostPacket packet)

Adds a packet that will be sent to a downlink Switch.

Parameters:
  • downlinkSwitch – the target switch
  • packet – the packet to be sent

addPacketToSendToHost

protected void addPacketToSendToHost(NetworkHost host, HostPacket packet)

Adds a packet that will be sent to a NetworkHost.

Parameters:
  • host – the target NetworkHost
  • packet – the packet to be sent

addPacketToSendToUplinkSwitch

protected void addPacketToSendToUplinkSwitch(Switch uplinkSwitch, HostPacket packet)

Adds a packet that will be sent to a uplink Switch.

Parameters:
  • uplinkSwitch – the target switch
  • packet – the packet to be sent

bandwidthByPacket

protected double bandwidthByPacket(double bwCapacity, int simultaneousPackets)

Considering a list of packets to be sent, gets the amount of available bandwidth for each packet, assuming that the bandwidth is shared equally among all packets.

Parameters:
  • bwCapacity – the total bandwidth capacity to share among the packets to be sent (in Megabits/s)
  • simultaneousPackets – number of packets to be simultaneously sent
Returns:

the available bandwidth for each packet in the list of packets to send (in Megabits/s) or the total bandwidth capacity if the packet list has 0 or 1 element

downlinkTransferDelay

public double downlinkTransferDelay(HostPacket packet, int simultaneousPackets)

getDatacenter

public NetworkDatacenter getDatacenter()

getDownlinkBandwidth

public double getDownlinkBandwidth()

getDownlinkSwitchPacketList

protected List<HostPacket> getDownlinkSwitchPacketList(Switch downlinkSwitch)

Gets the list of packets to be sent to a downlink switch.

Parameters:
  • downlinkSwitch – the id of the switch to get the list of packets to send
Returns:

the list of packets to be sent to the given switch.

getDownlinkSwitches

public List<Switch> getDownlinkSwitches()

getHostPacketList

protected List<HostPacket> getHostPacketList(NetworkHost host)

Gets the list of packets to be sent to a host.

Parameters:
  • host – the host to get the list of packets to send
Returns:

the list of packets to be sent to the given host.

getPorts

public int getPorts()

getSwitchingDelay

public double getSwitchingDelay()

getUplinkBandwidth

public double getUplinkBandwidth()

getUplinkSwitchPacketList

protected List<HostPacket> getUplinkSwitchPacketList(Switch uplinkSwitch)

Gets the list of packets to be sent to an uplink switch.

Parameters:
  • uplinkSwitch – the switch to get the list of packets to send
Returns:

the list of packets to be sent to the given switch.

getUplinkSwitches

public List<Switch> getUplinkSwitches()

getVmEdgeSwitch

protected EdgeSwitch getVmEdgeSwitch(HostPacket pkt)

Gets the EdgeSwitch that the Host where the VM receiving a packet is connected to.

Parameters:
  • pkt – the packet targeting some VM
Returns:

the Edge Switch connected to the Host where the targeting VM is placed

getVmHost

protected NetworkHost getVmHost(Vm vm)

Gets the Host where a VM is placed.

Parameters:
  • vm – the VM to get its Host
Returns:

the Host where the VM is placed

packetTransferDelay

protected double packetTransferDelay(HostPacket netPkt, double bwCapacity, int simultaneousPackets)

Computes the network delay to send a packet through the network, considering that a list of packets will be sent simultaneously.

Parameters:
  • netPkt – the packet to be sent
  • bwCapacity – the total bandwidth capacity (in Megabits/s)
  • simultaneousPackets – number of packets to be simultaneously sent
Returns:

the expected time to transfer the packet through the network (in seconds)

processEvent

public void processEvent(SimEvent evt)

processHostPacket

protected void processHostPacket(SimEvent evt)

Process a packet sent to a host.

Parameters:
  • evt – The packet sent.

processPacketDown

protected void processPacketDown(SimEvent evt)

Sends a packet to Datacenter connected through a downlink port.

Parameters:
  • evt – Event/packet to process

processPacketUp

protected void processPacketUp(SimEvent evt)

Sends a packet to Datacenter connected through a uplink port.

Parameters:
  • evt – Event/packet to process

setDatacenter

public void setDatacenter(NetworkDatacenter datacenter)

setDownlinkBandwidth

public final void setDownlinkBandwidth(double downlinkBandwidth)

setPorts

public final void setPorts(int ports)

setSwitchingDelay

public final void setSwitchingDelay(double switchingDelay)

setUplinkBandwidth

public final void setUplinkBandwidth(double uplinkBandwidth)

shutdownEntity

public void shutdownEntity()

startEntity

protected void startEntity()

uplinkTransferDelay

public double uplinkTransferDelay(HostPacket packet, int simultaneousPackets)