Switch

public interface Switch extends SimEntity

Represents a Network Switch.

Author:Manoel Campos da Silva Filho

Fields

NULL

Switch NULL

An attribute that implements the Null Object Design Pattern for Switch objects.

Methods

addPacketToBeSentToDownlinkSwitch

void addPacketToBeSentToDownlinkSwitch(Switch downlinkSwitch, HostPacket packet)

addPacketToBeSentToHost

void addPacketToBeSentToHost(NetworkHost host, HostPacket packet)

addPacketToBeSentToUplinkSwitch

void addPacketToBeSentToUplinkSwitch(Switch uplinkSwitch, HostPacket packet)

connectHost

void connectHost(NetworkHost host)

Connects a NetworkHost to the switch, by adding it to the getHostList().

Parameters:
  • host – the host to be connected to the switch

disconnectHost

boolean disconnectHost(NetworkHost host)

Disconnects a NetworkHost from the switch, by removing it from the getHostList().

Parameters:
  • host – the host to be disconnected from the switch
Returns:

true if the Host was connected to the switch, false otherwise

getDatacenter

NetworkDatacenter getDatacenter()

Gets the Datacenter where the switch is connected to.

getDownlinkBandwidth

double getDownlinkBandwidth()
Returns:Bandwitdh of downlink (in Megabits/s).

getDownlinkSwitchPacketList

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

List<Switch> getDownlinkSwitches()

getHostList

List<NetworkHost> getHostList()

Gets a read-only list of Hosts connected to the switch.

getHostPacketList

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.

getLevel

int getLevel()

Gets the level (layer) of the AbstractSwitch in the network topology, depending if it is a root switch (layer 0), aggregate switch (layer 1) or edge switch (layer 2)

Returns:the switch network level

getPacketList

List<HostPacket> getPacketList()

getPacketToHostMap

Map<NetworkHost, List<HostPacket>> getPacketToHostMap()
Returns:a read-only map of hosts and the list of packets to be sent to each one.

getPorts

int getPorts()

Gets the number of ports the switch has.

getSwitchingDelay

double getSwitchingDelay()
Returns:the latency time the switch spends to process a received packet. This time is considered constant no matter how many packets the switch have to process (in seconds).

getUplinkBandwidth

double getUplinkBandwidth()
Returns:Bandwitdh of uplink (in Megabits/s).

getUplinkSwitchPacketList

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.

getUplinkSwitchPacketMap

Map<Switch, List<HostPacket>> getUplinkSwitchPacketMap()
Returns:a read-only map of the uplink Switches and list of packets to be sent to each one.

getUplinkSwitches

List<Switch> getUplinkSwitches()

setDatacenter

void setDatacenter(NetworkDatacenter datacenter)

Sets the Datacenter where the switch is connected to.

Parameters:
  • datacenter – the Datacenter to set

setDownlinkBandwidth

void setDownlinkBandwidth(double downlinkBandwidth)

setPorts

void setPorts(int ports)

setSwitchingDelay

void setSwitchingDelay(double switchingDelay)

setUplinkBandwidth

void setUplinkBandwidth(double uplinkBandwidth)