Skip to content

vGateway

The class "vGateway" is a unique implementation of the "PhysicalEntity" class. Unlike other entities, the "vGateway" does not possess a "vCPU", RAM, or ROM. Its primary role is to function as the entry point for the cloud environment, serving as the central hub for incoming and outgoing user traffic.

The "vGateway" inherits all the member functions implemented for the "vSwitch" class, allowing it to perform routing and switching operations. However, unlike other entities, the "vGateway" does not create a simulated process for packet decoding upon receiving simulated packets.

Additionally, the "vGateway" is designed to be linked exclusively with "vRouter" instances, facilitating seamless connectivity and routing between the gateway and the routers within the simulated network topology.

Bases: PhysicalEntity

Source code in PyCloudSim\entity\v_gateway.py
class vGateway(PhysicalEntity):
    def __init__(
        self,
        at: Union[int, float, Callable] = simulation.now,
        after: Optional[Entity | List[Entity]] = None,
        label: Optional[str] = None,
    ):
        """Create a virtual gateway, which is the entry/exit point of the simulated cluster.

        Args:
            at (Union[int, float, Callable], optional): same as the entity. Defaults to simulation.now.
            after (Optional[Entity  |  List[Entity]], optional): same as the entity. Defaults to None.
            label (Optional[str], optional): same as the entity. Defaults to None.
        """
        super().__init__(
            num_cpu_cores=1,
            ipc=1,
            frequency=1000,
            ram=1,
            rom=1,
            delay=0.01,
            at=at,
            after=after,
            label=label,
        )

    def creation(self):
        """Creation process of the virtual gateway."""
        return super().creation()

    def termination(self):
        """Termination process of the virtual gateway."""
        return super().termination()

    def _power_on(self):
        """Power on the virtual gateway."""
        super()._power_on()

    def _power_off(self):
        """Power off the virtual gateway."""
        super()._power_off()

    def cache_packet(self, packet: vPacket):
        """Cache a packet in the virtual gateway, no packet handler vProcess will be created."""
        self.packets.append(packet)
        if not packet.scheduled:
            packet.status.append(SCHEDULED)
            packet._scheduled_at = simulation.now
        packet.status.append(QUEUED)
        packet.status.append(DECODED)
        packet._current_hop = self
        if packet.path[-1] is self:
            packet.complete()
        self.send_packets()
        LOGGER.info(
            f"{simulation.now:0.2f}:\t{self.__class__.__name__} {self.label} cached packet {packet.label}."
        )

__init__(at=simulation.now, after=None, label=None)

Create a virtual gateway, which is the entry/exit point of the simulated cluster.

Parameters:

Name Type Description Default
at Union[int, float, Callable]

same as the entity. Defaults to simulation.now.

now
after Optional[Entity | List[Entity]]

same as the entity. Defaults to None.

None
label Optional[str]

same as the entity. Defaults to None.

None
Source code in PyCloudSim\entity\v_gateway.py
def __init__(
    self,
    at: Union[int, float, Callable] = simulation.now,
    after: Optional[Entity | List[Entity]] = None,
    label: Optional[str] = None,
):
    """Create a virtual gateway, which is the entry/exit point of the simulated cluster.

    Args:
        at (Union[int, float, Callable], optional): same as the entity. Defaults to simulation.now.
        after (Optional[Entity  |  List[Entity]], optional): same as the entity. Defaults to None.
        label (Optional[str], optional): same as the entity. Defaults to None.
    """
    super().__init__(
        num_cpu_cores=1,
        ipc=1,
        frequency=1000,
        ram=1,
        rom=1,
        delay=0.01,
        at=at,
        after=after,
        label=label,
    )

cache_packet(packet)

Cache a packet in the virtual gateway, no packet handler vProcess will be created.

Source code in PyCloudSim\entity\v_gateway.py
def cache_packet(self, packet: vPacket):
    """Cache a packet in the virtual gateway, no packet handler vProcess will be created."""
    self.packets.append(packet)
    if not packet.scheduled:
        packet.status.append(SCHEDULED)
        packet._scheduled_at = simulation.now
    packet.status.append(QUEUED)
    packet.status.append(DECODED)
    packet._current_hop = self
    if packet.path[-1] is self:
        packet.complete()
    self.send_packets()
    LOGGER.info(
        f"{simulation.now:0.2f}:\t{self.__class__.__name__} {self.label} cached packet {packet.label}."
    )

creation()

Creation process of the virtual gateway.

Source code in PyCloudSim\entity\v_gateway.py
def creation(self):
    """Creation process of the virtual gateway."""
    return super().creation()

termination()

Termination process of the virtual gateway.

Source code in PyCloudSim\entity\v_gateway.py
def termination(self):
    """Termination process of the virtual gateway."""
    return super().termination()