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:
-
For a "vSwitch," the IP address attribute of its "vNIC" is set to none, and its "vNIC" can be connected to any entity.
-
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: PhysicalEntity
Source code in PyCloudSim\entity\v_switch.py
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
cpu: vCPU
property
returns the CPU of the vSwitch.
delay: float
property
returns the packet processing delay of the vSwitch.
ram: Resource
property
returns the RAM of the vSwitch.
subnet: IPv4Network
property
returns the subnet of the vSwitch.
usable_host_address: List[IPv4Address]
property
returns the usable host addresses of the vSwitch.
__init__(ipc, frequency, num_cpu_cores, ram, subnet, delay=0.01, at=simulation.now, after=None, label=None)
Create a virtual switch.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ipc |
Union[int, float]
|
the instructions per cycle of the CPU. |
required |
frequency |
Union[int, float]
|
the frequency of the CPU. |
required |
num_cpu_cores |
int
|
the number of CPU cores. |
required |
ram |
int
|
the amount of RAM in MiB. |
required |
subnet |
str
|
the subnet of the switch. |
required |
delay |
float
|
the packet proccessing dekay. Defaults to 0.01. |
0.01
|
at |
Union[int, float, Callable]
|
same as entity. Defaults to simulation.now. |
now
|
after |
Optional[Entity | List[Entity]]
|
same as entity. Defaults to None. |
None
|
label |
Optional[str]
|
same as entity. Defaults to None. |
None
|
Source code in PyCloudSim\entity\v_switch.py
cache_packet(packet)
Cache a packet and engage the packet processing. This function is automatically called by the vNIC upon receiving any packet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
packet |
vPacket
|
description |
required |
Source code in PyCloudSim\entity\v_switch.py
connect_device(device, bandwidth=1000)
Connect a device to the vSwitch. A new vNIC will be created as a "Port" of the switch.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
device |
Union[vHost, vRouter]
|
the device to connect to the switch. |
required |
bandwidth |
int
|
the bandwidth of this link. Defaults to 1000. |
1000
|