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
      • downlinkTransferDelay

        public double downlinkTransferDelay​(HostPacket packet,
                                            int simultaneousPackets)
        Description copied from interface: Switch
        Considering a list of packets to be sent simultaneously, computes the expected time to transfer each packet through the downlink, assuming that the bandwidth is shared equally between all packets.
        Specified by:
        downlinkTransferDelay in interface Switch
        simultaneousPackets - number of packets to be simultaneously sent
        Returns:
        the expected transmission time in seconds
      • uplinkTransferDelay

        public double uplinkTransferDelay​(HostPacket packet,
                                          int simultaneousPackets)
        Description copied from interface: Switch
        Considering a list of packets to be sent simultaneously, computes the expected time to transfer each packet through the uplink, assuming that the bandwidth is shared equally between all packets.
        Specified by:
        uplinkTransferDelay in interface Switch
        simultaneousPackets - number of packets to be simultaneously sent
        Returns:
        the expected transmission time in seconds
      • 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)
      • 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
      • 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()
        Description copied from interface: Switch
        Gets the bandwidth this Switch has to communicate with Switches in the upper layer.
        Specified by:
        getUplinkBandwidth in interface Switch
        Returns:
        Bandwidth of uplink (in Megabits/s).
        See Also:
        Switch.getUplinkSwitches()
      • setUplinkBandwidth

        public final void setUplinkBandwidth​(double uplinkBandwidth)
        Description copied from interface: Switch
        Sets the bandwidth this Switch has to communicate with Switches in the upper layer.
        Specified by:
        setUplinkBandwidth in interface Switch
        Parameters:
        uplinkBandwidth - uplink bandwidth to set (in Megabits/s).
        See Also:
        Switch.getUplinkSwitches()
      • getDownlinkBandwidth

        public double getDownlinkBandwidth()
        Description copied from interface: Switch
        Gets the bandwidth this Switch has to communicate with Switches in the lower layer.
        Specified by:
        getDownlinkBandwidth in interface Switch
        Returns:
        Bandwidth of downlink (in Megabits/s).
        See Also:
        Switch.getDownlinkSwitches()
      • setDownlinkBandwidth

        public final void setDownlinkBandwidth​(double downlinkBandwidth)
        Description copied from interface: Switch
        Sets the bandwidth this Switch has to communicate with Switches in the lower layer.
        Specified by:
        setDownlinkBandwidth in interface Switch
        Parameters:
        downlinkBandwidth - downlink bandwidth to set (in Megabits/s).
        See Also:
        Switch.getDownlinkSwitches()
      • 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)
        Description copied from interface: Switch
        Sets the number of ports the switch has.
        Specified by:
        setPorts in interface Switch
        Parameters:
        ports - the number of ports to set
      • getSwitchingDelay

        public double getSwitchingDelay()
        Description copied from interface: Switch
        Gets 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).
        Specified by:
        getSwitchingDelay in interface Switch
        Returns:
        the switching delay
      • setSwitchingDelay

        public final void setSwitchingDelay​(double switchingDelay)
        Description copied from interface: Switch
        Sets 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).
        Specified by:
        setSwitchingDelay in interface Switch
        Parameters:
        switchingDelay - the switching delay to set
      • getUplinkSwitches

        public java.util.List<Switch> getUplinkSwitches()
        Description copied from interface: Switch
        Gets the list of Switches in the upper layer that this Switch is connected to.
        Specified by:
        getUplinkSwitches in interface Switch
        Returns:
      • getDownlinkSwitches

        public java.util.List<Switch> getDownlinkSwitches()
        Description copied from interface: Switch
        Gets the list of Switches in the lower layer that this Switch is connected to.
        Specified by:
        getDownlinkSwitches in interface Switch
        Returns:
      • getDownlinkSwitchPacketList

        protected java.util.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

        protected java.util.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

        protected java.util.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.
      • 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
      • 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
      • 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
      • 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)