-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Bryan Wyatt edited this page Dec 14, 2024
·
5 revisions
This project was started as a way to both learn and teach how networks work at the protocol level in a human-friendly time scale. As such, there are some "interesting" deviations from reality, particularly the "physical" layer and time, it is a simulation, after all. No code in here should be considered "production quality", and should be expected to contain vulnerabilities that have been patched in real-world implementations (but these could be fun to "exploit" in the simulation).
python3 -m venv networksim
source networksim/bin/activate
pip install git+https://github.com/brwyatt/NetworkSim.git#egg=networksim
(These are still a WIP)
- The time units analogue in the simulation are "steps".
- Cable lengths are measured in the number of "steps" for packets to taverse the length of the cable
- Interface buffers are based on the number of "steps" worth of packets that can be stored (relative to their bandwidth)
- Cables (Physical layer oddities)
- These decisions were made in order to make it easy to simulate/control and keep the focus on the higher level protocols, and the actual implementation here actually doesn't matter, as the protocols are intended to be run over different physical layers, and do in the real world (2- or 4-pair copper CAT cables, Multi-/Single-Mode fiber, and encapsulated protocols such as GPON (fiber internet), DOCSIS (cable internet), and VPN)
- Unlike the real world, packets "exist" on the cable in discrete units (rather than conducting electical signals between ends)
- Cables are "active" in that they are actually the entity in the simulation pulling packets off of interface outbound buffers and placing them on interface inbound buffers, rather than just being a conduit for electrical signals or light transmitted from the interface and received on the other end.
- the "bandwidth" is the number of packets per "step" along the cable. This would be most analagous to the higher frequency of CAT cables that higher-rated cables (and interfaces) use to achieve higher bandwidth.
- Packets are the fundamental unit
- Unlike the real world, packets are transmitted as a single discrete unit, irrelevant of size.
- Packets are also structured Python objects, for ease of inspection and exploration/understanding of protocols, rather than being raw binary data. The idea is to teach "IP Packets are encapsulated in an Ethernet packet have a source and destination IP address" rather than "these x bytes of the IP data frame portion of the packet contains y data".
- Device packet processing
- By default, devices are configured to be able to read the combined bandwidth of all interfaces every step. This will, by default, ensure the inbound buffers can never fill. This can be tweaked to slow the processing of packets to allow for "overwhelming" a host and dropping packets.
- On switches, this default can easily lead to overflowing of outbound buffers on popular destination interfaces, unless those are manually increased.
- For simplicity, "applications" listening on a host, can process and respond to a packet (or multiple packets) within the same step, without any kind of time delay for processing like the real world would normally see.
- By default, devices are configured to be able to read the combined bandwidth of all interfaces every step. This will, by default, ensure the inbound buffers can never fill. This can be tweaked to slow the processing of packets to allow for "overwhelming" a host and dropping packets.