Class AbstractSwitch

    • Method Detail

      • startEntity

        protected void startEntity()
        Description copied from class: CloudSimEntity
        Defines the logic to be performed by the entity when the simulation starts.
        Specified by:
        startEntity in class CloudSimEntity
      • processEvent

        public void processEvent​(SimEvent evt)
        Description copied from interface: SimEntity
        Processes events or services that are available for the entity. This method is invoked by the CloudSim class whenever there is an event in the deferred queue, which needs to be processed by the entity.
        Specified by:
        processEvent in interface SimEntity
        Parameters:
        evt - information about the event just happened
      • 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
      • 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
      • processPacketUp

        protected void processPacketUp​(SimEvent evt)
        Sends a packet to Datacenter connected through a uplink port.
        Parameters:
        evt - Event/packet to process
      • networkDelayForPacketTransmission

        protected double networkDelayForPacketTransmission​(HostPacket netPkt,
                                                           double bwCapacity,
                                                           List<HostPacket> netPktList)
        Computes the network delay to send a packet through the network.
        Parameters:
        netPkt - the packet to be sent
        bwCapacity - the total bandwidth capacity (in Megabits/s)
        netPktList - the list of packets waiting to be sent
        Returns:
        the expected time to transfer the packet through the network (in seconds)
      • shutdownEntity

        public void shutdownEntity()
        Description copied from interface: SimEntity
        Shuts down the entity. This method is invoked by the CloudSim before the simulation finishes. If you want to save data in log files this is the method in which the corresponding code would be placed.
        Specified by:
        shutdownEntity in interface SimEntity
        Overrides:
        shutdownEntity in class CloudSimEntity
      • getUplinkBandwidth

        public double getUplinkBandwidth()
        Specified by:
        getUplinkBandwidth in interface Switch
        Returns:
        Bandwitdh of uplink (in Megabits/s).
      • setUplinkBandwidth

        public final void setUplinkBandwidth​(double uplinkBandwidth)
        Specified by:
        setUplinkBandwidth in interface Switch
      • getDownlinkBandwidth

        public double getDownlinkBandwidth()
        Specified by:
        getDownlinkBandwidth in interface Switch
        Returns:
        Bandwitdh of downlink (in Megabits/s).
      • setDownlinkBandwidth

        public final void setDownlinkBandwidth​(double downlinkBandwidth)
        Specified by:
        setDownlinkBandwidth in interface Switch
      • getPorts

        public int getPorts()
        Description copied from interface: Switch
        Gets the number of ports the switch has.
        Specified by:
        getPorts in interface Switch
        Returns:
      • setPorts

        public final void setPorts​(int ports)
        Specified by:
        setPorts in interface Switch
      • getSwitchingDelay

        public double getSwitchingDelay()
        Specified by:
        getSwitchingDelay in interface Switch
        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

        public final void setSwitchingDelay​(double switchingDelay)
        Specified by:
        setSwitchingDelay in interface Switch
      • getHostList

        public List<NetworkHost> getHostList()
        Description copied from interface: Switch
        Gets a read-only list of Hosts connected to the switch.
        Specified by:
        getHostList in interface Switch
        Returns:
      • disconnectHost

        public boolean disconnectHost​(NetworkHost host)
        Description copied from interface: Switch
        Disconnects a NetworkHost from the switch, by removing it from the Switch.getHostList().
        Specified by:
        disconnectHost in interface Switch
        Parameters:
        host - the host to be disconnected from the switch
        Returns:
        true if the Host was connected to the switch, false otherwise
      • getDownlinkSwitchPacketList

        public List<HostPacket> getDownlinkSwitchPacketList​(Switch downlinkSwitch)
        Description copied from interface: Switch
        Gets the list of packets to be sent to a downlink switch.
        Specified by:
        getDownlinkSwitchPacketList in interface 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

        public List<HostPacket> getUplinkSwitchPacketList​(Switch uplinkSwitch)
        Description copied from interface: Switch
        Gets the list of packets to be sent to an uplink switch.
        Specified by:
        getUplinkSwitchPacketList in interface 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

        public List<HostPacket> getHostPacketList​(NetworkHost host)
        Description copied from interface: Switch
        Gets the list of packets to be sent to a host.
        Specified by:
        getHostPacketList in interface Switch
        Parameters:
        host - the host to get the list of packets to send
        Returns:
        the list of packets to be sent to the given host.
      • getDatacenter

        public NetworkDatacenter getDatacenter()
        Description copied from interface: Switch
        Gets the Datacenter where the switch is connected to.
        Specified by:
        getDatacenter in interface Switch
        Returns:
      • setDatacenter

        public void setDatacenter​(NetworkDatacenter datacenter)
        Description copied from interface: Switch
        Sets the Datacenter where the switch is connected to.
        Specified by:
        setDatacenter in interface Switch
        Parameters:
        datacenter - the Datacenter to set
      • 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
      • addPacketToBeSentToFirstUplinkSwitch

        protected void addPacketToBeSentToFirstUplinkSwitch​(HostPacket netPkt)