Skip to content

vSwitch

The class "vSwitch" and "vRouter" are the implementation of the switch and router in the simulated network topology. "vSwitch" and "vRouter" will create a scheduling process to schedule all "vPacket" in the queue to "vNIC" for transmission based on the priority of "vPacket" when a "vPacket" arrived or has been transmitted. The scheduling process is implemented as an "event and only one scheduling process for each "vSwitch" or "vRouter" can exist at any time. If a "vSwitch" or "vRouter" does not have enough RAM to accommodate a "vPacket" upon receiving it, the "vPacket" will be dropped. The difference between "vSwitch" and "vRouter" are:

  1. For a "vSwitch," the IP address attribute of its "vNIC" is set to none, and its "vNIC" can be connected to any entity.

  2. For a "vRouter," the IP address of each of its "vNIC" instances must belong to a unique network and its "vNIC" cannot be connected to a "vHost" entity.

Bases: vHardwareEntity

Source code in PyCloudSim\entity\v_switch.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
class vSwitch(vHardwareEntity):
    def __init__(
        self,
        ipc: int | Callable[..., Any],
        frequency: int | Callable[..., Any],
        num_cores: int | Callable[..., Any],
        cpu_tdps: int | float | Callable[..., Any],
        cpu_mode: int,
        ram: int | Callable[..., Any],
        rom: int | Callable[..., Any],
        subnet: IPv4Network,
        architecture: str = Constants.X86,
        label: str | None = None,
        create_at: int
        | float
        | Callable[..., int]
        | Callable[..., float]
        | None = None,
        terminate_at: int
        | float
        | Callable[..., int]
        | Callable[..., float]
        | None = None,
        precursor: Entity | List[Entity] | None = None,
    ) -> None:
        super().__init__(
            ipc,
            frequency,
            num_cores,
            cpu_tdps,
            cpu_mode,
            ram,
            rom,
            architecture,
            label,
            create_at,
            terminate_at,
            precursor,
        )
        self._subnet = subnet
        self._available_ip_addresses = list(subnet.hosts())

    @property
    def subnet(self) -> IPv4Network:
        """Returns the subnet of the vSwitch"""
        return self._subnet

    @property
    def available_ip_addresses(self) -> list[IPv4Address]:
        """Returns a list of available IP addresses in the subnet."""
        return self._available_ip_addresses

available_ip_addresses: list[IPv4Address] property

Returns a list of available IP addresses in the subnet.

subnet: IPv4Network property

Returns the subnet of the vSwitch