emmericp / MoonGen

MoonGen is a fully scriptable high-speed packet generator built on DPDK and LuaJIT. It can saturate a 10 Gbit/s connection with 64 byte packets on a single CPU core while executing user-provided Lua scripts for each packet. Multi-core support allows for even higher rates. It also features precise and accurate timestamping and rate control.
MIT License
1.04k stars 234 forks source link

Computation of (with framing) throughput in l3-load-latency.lua #285

Closed harshgondaliya closed 3 years ago

harshgondaliya commented 3 years ago

From the libmoon/lua/stats.lua file, I got to know that 160 bits per packet are being incremented to compute the with framing throughput.

    local mbit = (bytes - self.totalBytes) / elapsed / 10^6 * 8
    local wireRate = mbit + (mpps * 20 * 8)

Are these 160 bits added to count the 8 bytes Preamble and 12 bytes Inter Frame Gap?

Also, why do we need to separately add these 160 bits? Won't the bytes - self.totalBytes be able to give us overall bytes including everything?

emmericp commented 3 years ago

Yes, that's exactly where these additional 20 bytes come from :)

We need to add them because the NIC hardware counters do not account for them---at least not on any NIC that I've encountered, most do include CRC (but not all).

So what we have is: Number of packets, total size of all packets but 20 bytes short for each packet.

And what we want is something that adds up to exactly line rate under full load, otherwise it's confusing