I am creating a program that creates a RAW socket to read all traffic. Between calling socket () and recvfrom () (the last one is in a loop to get all packets out of the buffer). I wait 5 seconds.
When I run the program, I send about 200 packets with the hping3 command to "faster mode" (to quickly fill the buffer) in my program. As soon as 5 seconds have passed, my program will extract about 150 packets from the buffer.
I am trying to resize the receive buffer to get the best result:
int a = 65535; if ( (setsockopt(sockfd, 0, SO_RCVBUF, &a ,sizeof(int)) ) < 0 ) { fprintf(stderr, "Error setting sock opts..\n"); }
However, regardless of the value of "a", 1 or 10,000,000, nothing seems to change, I still get ~ 150 packets from the buffer.
What is the problem?
Edit: The value of "a" is checked when getsockopt
called.
source share