Created
December 3, 2024 05:18
-
-
Save wolfspider/6bb959083eec2ec55fedfd6f1e68e426 to your computer and use it in GitHub Desktop.
Formal RingBuffer 3: Getting Low and Getting Results
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn buildPacket() []const u8 { | |
// Define the packet components | |
const dest_mac: [6]u8 = [_]u8{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; // Destination MAC | |
const src_mac: [6]u8 = [_]u8{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // Source MAC | |
const ethertype: [2]u8 = [_]u8{ 0x08, 0x00 }; // EtherType (IPv4) | |
const payload: [46]u8 = [_]u8{0} ** 46; // Payload (46 bytes of zeroes) | |
// Combine all components into a single array | |
const packet: [60]u8 = [_]u8{ | |
// Destination MAC | |
dest_mac[0], dest_mac[1], dest_mac[2], dest_mac[3], dest_mac[4], dest_mac[5], | |
// Source MAC | |
src_mac[0], src_mac[1], src_mac[2], src_mac[3], src_mac[4], src_mac[5], | |
// EtherType | |
ethertype[0], ethertype[1], | |
// Payload | |
payload[0], payload[1], payload[2], payload[3], | |
payload[4], payload[5], payload[6], payload[7], payload[8], payload[9], | |
payload[10], payload[11], payload[12], payload[13], payload[14], payload[15], | |
payload[16], payload[17], payload[18], payload[19], payload[20], payload[21], | |
payload[22], payload[23], payload[24], payload[25], payload[26], payload[27], | |
payload[28], payload[29], payload[30], payload[31], payload[32], payload[33], | |
payload[34], payload[35], payload[36], payload[37], payload[38], payload[39], | |
payload[40], payload[41], payload[42], payload[43], payload[44], payload[45], | |
}; | |
// Return as a slice | |
return packet[0..]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The Python speeds are as follows for tx.py:
And now the new and improved Zig speed:
As you can see they are nearly the same because they are, for once, actually doing the same thing! Imagine that. After getting all excited I realized how seriously bad it was that I was sending these packets with a length of 60 and somehow saturating the connection. Basically, that's just not possible if everything is exactly the same. I finally do get packets on the other end of the vale switch using onepacket.py as well:
The number one primary thing to remember is that netmap does not make your network go faster! Despite this many applications using it are based around doing things fast- go figure.