pellegre / libcrafter

A high level C++ network packet sniffing and crafting library.
298 stars 88 forks source link

Sendrecv #24

Closed oliviertilmans closed 9 years ago

oliviertilmans commented 9 years ago

the libpcap read timeout (to_ms), is the number of ms during which read calls should be delayed, to be able to batch successive packets (e.g. be more efficient if we want to capture a large number of packets). In this case, we only care about the response, so it is set to 1ms (0 would block indefinitely -- until the OS receive buffer is full which is likely to never happen in our case), and we explicitely set the immediate_mode.

As for the timeout handling, we simply fallback on using select()

Overall this yields much better performance when chaining mutliple sendrecv calls, as these will return as soon as a packet is receive (instead of waiting for timeout expiratoin every time).