Skip to content

Instantly share code, notes, and snippets.

View ian-p-cooke's full-sized avatar

Ian P. Cooke ian-p-cooke

View GitHub Profile
// So this code looks wrong to me. What the correct way to "switch" on ethertype to get the next layer?
let packet = // some bytes from a PCAP file
let ether = EthernetPacket::new(&packet).expect("could not parse Ethernet frame");
// I don't know if the next line is valid; what if there's no Vlan layer and it doesn't parse ether.payload()?
let vlan = VlanPacket::new(ether.payload()).expect("could not parse Vlan frame");
let payload = if ether.get_ethertype() == ethernet::EtherTypes::Vlan {
vlan.payload()
} else {
ether.payload()
BEFORE:
PS C:\Users\ipc\tmp\tonic> D:\apps\ghz.exe --insecure --proto .\examples\proto\helloworld\helloworld.proto --call helloworld.Greeter.SayHello -d '{\"name\":\"Joe\"}' -n 100000 --connections=1 localhost:50051
Summary:
Count: 100000
Total: 3.89 s
Slowest: 13.00 ms
Fastest: 0 ns
Average: 1.87 ms
Requests/sec: 25674.03