New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sending with pcap_sendqueue_transmit sometimes takes a long time to return #113
Comments
npcap-0.9995.exe, npcap-sdk-1.05. |
The API documentation says the function should respect the packet timestamps only if the ...
do{
// Send the data to the driver
//TODO Res is NEVER checked, this is REALLY bad.
Res = (BOOLEAN)DeviceIoControl(AdapterObject->hFile,
(Sync)?BIOCSENDPACKETSSYNC:BIOCSENDPACKETSNOSYNC,
(PCHAR)PacketBuff + TotBytesTransfered,
Size - TotBytesTransfered,
NULL,
0,
&BytesTransfered,
NULL);
// Exit from the loop on error
if(Res != TRUE)
break;
TotBytesTransfered += BytesTransfered;
// Exit from the loop if we have transferred everything
if(TotBytesTransfered >= Size)
break;
// calculate the time interval to wait before sending the next packet
TargetTicks.QuadPart = StartTicks.QuadPart +
(LONGLONG)
((((struct timeval*)((PCHAR)PacketBuff + TotBytesTransfered))->tv_sec - BufStartTime.tv_sec) * 1000000 +
(((struct timeval*)((PCHAR)PacketBuff + TotBytesTransfered))->tv_usec - BufStartTime.tv_usec)) *
(TimeFreq.QuadPart) / 1000000;
// Wait until the time interval has elapsed
while( CurTicks.QuadPart <= TargetTicks.QuadPart )
QueryPerformanceCounter(&CurTicks);
}
while(TRUE);
... It looks like the packet timestamps are unconditionally respected. The @dmiller-nmap: Should the inner busy-while condition be |
@zirahvi Thanks for that analysis. The
This results in a return back to |
Also, the wait time is being calculated assuming a fixed 1000000 ticks per second, even though we call |
Well, I guess that's not technically true. I misread the parentheses, but we're risking an overflow by trying to accumulate the number of microseconds and multiplying by the tick count before dividing by 1M. Changed it to just get the number of ticks in each term and add those last. By my guesstimation, the tick count would get high enough to overflow this after 10 days. |
Environment: npcap-0.9987.exe, npcap-sdk-1.04.
I use pcap_sendqueue_transmit to send data, sending 500 packets each time, sending a total of 10,000 times. Most of the time the function returns in about 10 milliseconds, but occasionally (less than 10 times) the function takes more than 10 seconds to return.
The third parameter of pcap_sendqueue_transmit is 0.
DiagReport-20200305-110303.txt
install.log
NPFInstall.log
The text was updated successfully, but these errors were encountered: