Interface Switch

    • Field Detail

      • NULL

        static final Switch NULL
        An attribute that implements the Null Object Design Pattern for Switch objects.
    • Method Detail

      • getUplinkBandwidth

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

        void setUplinkBandwidth​(double uplinkBandwidth)
      • getDownlinkBandwidth

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

        void setDownlinkBandwidth​(double downlinkBandwidth)
      • getPorts

        int getPorts()
        Gets the number of ports the switch has.
        Returns:
      • setPorts

        void setPorts​(int ports)
      • 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).
      • setSwitchingDelay

        void setSwitchingDelay​(double switchingDelay)
      • getUplinkSwitches

        List<Switch> getUplinkSwitches()
      • getHostList

        List<NetworkHost> getHostList()
        Gets a read-only list of Hosts connected to the switch.
        Returns:
      • 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
      • getPacketToHostMap

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

        List<Switch> getDownlinkSwitches()
      • 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.
      • 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.
      • 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.
      • 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.
      • addPacketToBeSentToDownlinkSwitch

        void addPacketToBeSentToDownlinkSwitch​(Switch downlinkSwitch,
                                               HostPacket packet)
      • addPacketToBeSentToUplinkSwitch

        void addPacketToBeSentToUplinkSwitch​(Switch uplinkSwitch,
                                             HostPacket packet)
      • getDatacenter

        NetworkDatacenter getDatacenter()
        Gets the Datacenter where the switch is connected to.
        Returns:
      • setDatacenter

        void setDatacenter​(NetworkDatacenter datacenter)
        Sets the Datacenter where the switch is connected to.
        Parameters:
        datacenter - the Datacenter to set
      • 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