Week 5 Updates
Scenario for the week -
- Blocking system calls
2016-06-28 @ 14:53:56
I have been told by Michael that blocking system calls are now supported in packetdrill as of this commit. To check this, I used the script which I wrote earlier for testing blocking system calls.
This is the test script that I am using -
// Test for blocking accept // Establish a connection 0.000 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 0.000 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 0.000 bind(3, ..., ...) = 0 0.000 listen(3, 1) = 0 // Initiate a blocking system call 0.000...0.200 accept(3, ..., ...) = 4 0.100 < S 0:0(0) win 65535 <mss 1460,sackOK,nop,nop,nop,wscale 7> 0.100 > S. 0:0(0) ack 1 <...> 0.200 < . 1:1(0) ack 1 win 65535 // The connection gets accepted at this point 0.300 write(4, ..., 1460) = 1460 0.300 > P. 1:1461(1460) ack 1 <...>
However, I am encountering an error while running the script.
▶ sudo ./packetdrill -v tests/bsd/tcp/blocking/blocking-accept.pkt inbound injected packet: 0.100015 S 0:0(0) win 65535 <mss 1460,sackOK,nop,nop,nop,wscale 7> outbound sniffed packet: 0.100375 S. 3095721538:3095721538(0) ack 1 win 65535 <mss 1460,nop,wscale 6,sackOK,eol,eol> inbound injected packet: 0.200015 . 1:1(0) ack 3095721539 win 65535 tests/bsd/tcp/blocking/blocking-accept.pkt:17: runtime error in write call: unable to find socket with script fd 4
Having a look, it seems as though the accept system call somehow isn't complete at the end of 200 ms. As a result, I tried changing the timestamp for the call to 0.000...0.300 However, I again got an error -
▶ sudo ./packetdrill -v tests/bsd/tcp/blocking/blocking-accept.pkt inbound injected packet: 0.100015 S 0:0(0) win 65535 <mss 1460,sackOK,nop,nop,nop,wscale 7> outbound sniffed packet: 0.100284 S. 848639177:848639177(0) ack 1 win 65535 <mss 1460,nop,wscale 6,sackOK,eol,eol> inbound injected packet: 0.200015 . 1:1(0) ack 848639178 win 65535 tests/bsd/tcp/blocking/blocking-accept.pkt:10: timing error: expected system call return at 0.300000 sec but happened at 0.200380 sec
Looking at this, it seems that the system call completed at 200.38 ms itself, which seems odd as in the previous case, we were not able to establish a connection after 0.200 ms since the file descriptor was missing.
Update
Just as Michael suggested, doing make clean && make fixed the issue.