tt_Gantz tt_Gantz - 1 year ago 142
Python Question

QDISC_BYPASS in Python (Raw Sockets)

How do I set the socket options on a raw socket to have QDISC_BYPASS enabled? I saw examples in C but wasn't able to understand clearly how to implement it in Python.
I constructed the socket with AF_PACKET and SOCK_RAW settings.

I understand that I need to use socket.setsockopt() method but I'm not sure how to call it correctly in this case.

Answer Source

Figured this out myself. You need linux kernel 3.14 or higher installed for it to work

sock.setsockopt(263, 20, 0);

263 (int) is a reference to SOL_PACKET

20 (int) is a reference to QDISC_BYPASS

I wrote out the numbers in case they are not defined in your socket module (i.e. socket.SOL_PACKET doesn't exist)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download