Score:2

How to simulate what happens inside the packet buffer of a simple switch?

ro flag

I'm debugging a case of UDP packets lost in a store-and-forward gigabit switch and I wanted to visualize what happens inside the switch to better understand the gist of the problem.

The scenario is simple - two bursty data streams come through 2 ports inside the switch and both want to leave it via a third port (common to both). So the switch needs to hold some data in the packet buffer for a while.

The problem is: based on my simple calculations, the buffers should be large enough to handle the case I'm examining. One data stream sends bursts of 25 kB (divided to 1514 B packets) every 1.56 ms, the other one sends bursts of 60 kB every 1 ms. Now, even a soho switch like Netgear GS105E has buffer of size 128 kB. So the simple math (25+60 < 128) tells it should work even if the streams come to ingress at the same time (given there is no other substantial traffic).

The real tests show that a lot of packets from both streams get lost on some switches (it seems to be bound to buffer size, but not only to it). In my simulation, I cannot get the buffer to overfill when set to 128 kB.

I recorded this animation for a 24 kB-sized buffer where there is the overfill. However, you can easily see that increasing the buffer just a few bytes would resolve the issue and all packets would go through.

I did a few simplifications in this simulation. All packets have the same QoS (that is also in the real case). So I left out QoS queues from the simulation and I'm treating all traffic as equally important. Next, I left out memory management of the buffer. I can imagine it is an important part of the problem, but I'd be surprised if my simplification with perfect allocations would be more than 10% wrong from the real case. I also pretend that the switch knows the frame length when it receives its first bytes so that it reserves all the needed memory on the beginning. As I could not find any documentation about the size of ingress/egress queues of the ports, I assume they are all placed in the shared packet buffer and they can take as large part of the buffer as needed (although I think the culprit may be somewhere here). I've set the processing delay of each packet to 512 ns (the propagation delay of a 64 B packet).

I'm not sure if it plays a role, but the streams consist of fragmented UDP packets (i.e. the 25 kB burst is a single UDP packet fragmented to 17 IP fragments). The second stream creates the burst as 2 or 3 20 kB UDP packets, each fragmented to 14 IP fragments.

Iperf 3.7 commands to replicate streams similar to the real ones are:

iperf3 -c sink -u -b 128M -t 600 -l 25256 --pacing-timer 1560
iperf3 -c sink -u -b 400M -t 600 -l 20k --pacing-timer 1000

Do you have any ideas what else did I forget to take into account that could cause the simulation to be so far from reality? Thank you for help!

Source code for the animation is at https://gist.github.com/peci1/a0346538acc6c289b2c6d596b184ad21 .

simulation of data flow through the switch

Here is my result table from the real experiments. Data stream one is fixed - 128 Mbps in 25 kB UDP packets each 1.56 ms. I was changing parameters of the second stream trying to find the limit where packets of the first stream will start getting lost by the switch. I was changing the -l (length) parameter specifying size of the UDP packet, and the -b (bandwidth) parameter specifying what bandwidth should these packets generate. --pacing-timer was always set to 1000 for the second stream. You can see that the D-Link and Netgear GS105 cannot cope with the 60 kB bursts at all. GS108 does much better than GS105, while it has almost the same switch chip (the same "family", just different number of ports and a bit larger buffer).

Switch Buffer size [kB] Max traffic 1.5kB burst Max traffic 20kB burst Max traffic 60kB burst
Gigablox Rugged (VSC7512) 220 825 Mbps 825 Mbps 825 Mbps
Gigablox (RTL8367N-VB-CG) 250 730 Mbps 750 Mbps 790 Mbps
D-Link DIS-100G-5W (QCA8337N-AL3C) 128 110 Mbps 1 Mbps every burst loses packets
Zyxel XGS 1210-12 (RTL9302B) 1500 800 Mbps 830 Mbps 830 Mbps
Netgear GS310-TP (RTL8380M) 520 830 Mbps 830 Mbps 835 Mbps
Netgear GS308T (RTL8380M) 520 830 Mbps 835 Mbps 835 Mbps
Netgear GS108 v3 (BCM53118) 192 630 Mbps 660 Mbps 710 Mbps
Netgear GS105E (BCM53114) 128 120 Mbps 1 Mbps every burst loses packets
Renkforce RF-4270245 ? 740 Mbps 760 Mbps 800 Mbps
Mikrotik RB260GS (AR8327) 128 835 Mbps 835 Mbps 835 Mbps
Juniper EX2300 4 GB? 800 Mbps 830 Mbps 830 Mbps

(This question has been migrated from https://networkengineering.stackexchange.com/questions/78529/how-to-simulate-what-happens-inside-the-packet-buffer-of-a-simple-switch where it was marked as off-topic).

paladin avatar
id flag
The MTU size for Ethernet packages is 1500Bytes and not 1514Bytes. Look at --> https://en.wikipedia.org/wiki/Maximum_transmission_unit#MTUs_for_common_media
paladin avatar
id flag
PS should you really send packages with a MTU size of 1514Bytes over Ethernet, those packages will be spitted into 2 packages (1500Bytes + 14Bytes), effectively halving the buffer of your switch.
Martin Pecka avatar
ro flag
1514 is including the overhead. IP packet size is 1500 bytes.
paladin avatar
id flag
I've just read that `iperf` doesn't work 100% precise. It functionality depends on your used hardware. If you want more precise results, use a smaller `--pacing-timer` value. In short, `iperf` cannot guarantee to achieve the desired bit-rate.
Martin Pecka avatar
ro flag
@paladin Thank you for the info. I verified the bitrate and packet stream properties at the receiving side and they look as expected.
Zac67 avatar
ru flag
I can create various models but *you cannot truly replicate what's going on inside the switch without detail information* about its implementation. Various developers and vendors may use very different approaches to this problem. Buffers may be allocated statically to ports, etc. Unless you're very lucky you won't have that information ever. Correspondingly, your question only leads to guesswork which is off-topic here. If the switch doesn't work use a better one. If you have *very* specific requirements contact the vendor first or evaluate in a lab.
Martin Pecka avatar
ro flag
@Zac67 Thank you for your insight. This is what I feared (and I hoped there will be e.g. a few "standard approaches" from which the vendors can choose...). "If the switch doesn't work, use a better one" - that's exactly what I'd want, but ideally I'd like to have a way to evaluate the behavior before buying the switch, or at least guesstimate its behavior...
Zac67 avatar
ru flag
@MartinPecka Sadly, you won't find that by creating theoretical models but only by either asking the vendor about your use case or by rigid testing.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.