Skip to content

Instantly share code, notes, and snippets.

@shivansh
Last active August 13, 2016 16:02
Show Gist options
  • Save shivansh/e394c99f50c33cbd405314e446cd727c to your computer and use it in GitHub Desktop.
Save shivansh/e394c99f50c33cbd405314e446cd727c to your computer and use it in GitHub Desktop.
Verbose description of problems encountered during GSOC '16
diff --git a/gtests/net/packetdrill/code.c b/gtests/net/packetdrill/code.c
index e04a9ec..075012f 100644
--- a/gtests/net/packetdrill/code.c
+++ b/gtests/net/packetdrill/code.c
@@ -197,6 +197,10 @@ static void write_tcp_info(struct code_state *code,
emit_var(code, "tcpi_snd_ssthresh", info->tcpi_snd_ssthresh);
emit_var(code, "tcpi_snd_cwnd", info->tcpi_snd_cwnd);
emit_var(code, "tcpi_rcv_space", info->tcpi_rcv_space);
+ emit_var(code, "tcpi_sacked", info->__tcpi_sacked);
+ emit_var(code, "tcpi_unacked", info->__tcpi_unacked);
+ emit_var(code, "tcpi_retransmits", info->__tcpi_retransmits);
+ emit_var(code, "tcpi_retrans", info->__tcpi_retrans);
/* FreeBSD extensions to tcp_info. */
emit_var(code, "tcpi_snd_wnd", info->tcpi_snd_wnd);
▶ sudo ./packetdrill -v --tolerance_usecs=100000 ~/soc-16/fast_retransmit/fr-4pkt-sack-bsd.pkt
inbound injected packet: 0.000774 S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
outbound sniffed packet: 0.001263 S. 2147903419:2147903419(0) ack 1 win 65535 <mss 1000,nop,wscale 6,sackOK,eol,eol>
inbound injected packet: 0.106771 . 1:1(0) ack 2147903420 win 257
outbound sniffed packet: 0.107203 P. 2147903420:2147904420(1000) ack 1 win 1031
inbound injected packet: 0.206383 . 1:1(0) ack 2147904420 win 257
outbound sniffed packet: 0.206829 . 2147904420:2147905420(1000) ack 1 win 1031
outbound sniffed packet: 0.206836 . 2147905420:2147906420(1000) ack 1 win 1031
outbound sniffed packet: 0.206842 . 2147906420:2147907420(1000) ack 1 win 1031
outbound sniffed packet: 0.206850 P. 2147907420:2147908420(1000) ack 1 win 1031
inbound injected packet: 0.306769 . 1:1(0) ack 2147904420 win 257 <sack 2147905420:2147906420,nop,nop>
inbound injected packet: 0.307161 . 1:1(0) ack 2147904420 win 257 <sack 2147905420:2147907420,nop,nop>
inbound injected packet: 0.307413 . 1:1(0) ack 2147904420 win 257 <sack 2147905420:2147908420,nop,nop>
outbound sniffed packet: 0.307644 . 2147904420:2147905420(1000) ack 1 win 1031
inbound injected packet: 0.307958 . 1:1(0) ack 2147908420 win 257
import sys
import traceback
def excepthook(etype, value, tb):
sys.stderr.write("%s:%d: error in Python code\n" %
(_file, _line))
traceback.print_exception(etype, value, tb)
sys.excepthook = excepthook
tcpi_state = 1
tcpi_options = 2
tcpi_snd_wscale = 0
tcpi_rcv_wscale = 0
tcpi_rto = 3000000
tcpi_snd_mss = 536
tcpi_rcv_mss = 536
tcpi_last_data_recv = 0
tcpi_rtt = 0
tcpi_rttvar = 750000
tcpi_snd_ssthresh = 1073725440
tcpi_snd_cwnd = 1073725440
tcpi_rcv_space = 0
tcpi_sacked = 0
tcpi_unacked = 0
tcpi_retransmits = 0
tcpi_retrans = 0
tcpi_snd_wnd = 0
tcpi_snd_bwnd = 0
tcpi_snd_nxt = 0
tcpi_rcv_nxt = 0
tcpi_toe_tid = 0
tcpi_snd_rexmitpack = 0
tcpi_rcv_ooopack = 0
tcpi_snd_zerowin = 0
_file = '/home/zeebsd/soc-16/fast_retransmit/fr-4pkt-sack-bsd.pkt'
_line = 12
assert tcpi_snd_wnd == 32892
tcpi_state = 4
tcpi_options = 6
tcpi_snd_wscale = 7
tcpi_rcv_wscale = 6
tcpi_rto = 3000000
tcpi_snd_mss = 1000
tcpi_rcv_mss = 1000
tcpi_last_data_recv = 0
tcpi_rtt = 0
tcpi_rttvar = 750000
tcpi_snd_ssthresh = 1073725440
tcpi_snd_cwnd = 10001
tcpi_rcv_space = 66000
tcpi_sacked = 0
tcpi_unacked = 0
tcpi_retransmits = 0
tcpi_retrans = 0
tcpi_snd_wnd = 32896
tcpi_snd_bwnd = 0
tcpi_snd_nxt = 2147903420
tcpi_rcv_nxt = 1
tcpi_toe_tid = 0
tcpi_snd_rexmitpack = 0
tcpi_rcv_ooopack = 0
tcpi_snd_zerowin = 0
_file = '/home/zeebsd/soc-16/fast_retransmit/fr-4pkt-sack-bsd.pkt'
_line = 20
assert tcpi_snd_wnd == 32892
tcpi_state = 4
tcpi_options = 6
tcpi_snd_wscale = 7
tcpi_rcv_wscale = 6
tcpi_rto = 3000000
tcpi_snd_mss = 1000
tcpi_rcv_mss = 1000
tcpi_last_data_recv = 0
tcpi_rtt = 0
tcpi_rttvar = 750000
tcpi_snd_ssthresh = 1073725440
tcpi_snd_cwnd = 10001
tcpi_rcv_space = 66000
tcpi_sacked = 0
tcpi_unacked = 0
tcpi_retransmits = 0
tcpi_retrans = 0
tcpi_snd_wnd = 32896
tcpi_snd_bwnd = 0
tcpi_snd_nxt = 2147904420
tcpi_rcv_nxt = 1
tcpi_toe_tid = 0
tcpi_snd_rexmitpack = 0
tcpi_rcv_ooopack = 0
tcpi_snd_zerowin = 0
_file = '/home/zeebsd/soc-16/fast_retransmit/fr-4pkt-sack-bsd.pkt'
_line = 23
assert tcpi_snd_wnd == 32892
tcpi_state = 4
tcpi_options = 6
tcpi_snd_wscale = 7
tcpi_rcv_wscale = 6
tcpi_rto = 497000
tcpi_snd_mss = 1000
tcpi_rcv_mss = 1000
tcpi_last_data_recv = 1000
tcpi_rtt = 99000
tcpi_rttvar = 49500
tcpi_snd_ssthresh = 1073725440
tcpi_snd_cwnd = 11001
tcpi_rcv_space = 66000
tcpi_sacked = 0
tcpi_unacked = 0
tcpi_retransmits = 0
tcpi_retrans = 0
tcpi_snd_wnd = 32896
tcpi_snd_bwnd = 0
tcpi_snd_nxt = 2147908420
tcpi_rcv_nxt = 1
tcpi_toe_tid = 0
tcpi_snd_rexmitpack = 0
tcpi_rcv_ooopack = 0
tcpi_snd_zerowin = 0
_file = '/home/zeebsd/soc-16/fast_retransmit/fr-4pkt-sack-bsd.pkt'
_line = 30
assert tcpi_snd_wnd == 32892
tcpi_state = 4
tcpi_options = 6
tcpi_snd_wscale = 7
tcpi_rcv_wscale = 6
tcpi_rto = 497000
tcpi_snd_mss = 1000
tcpi_rcv_mss = 1000
tcpi_last_data_recv = 0
tcpi_rtt = 99000
tcpi_rttvar = 49500
tcpi_snd_ssthresh = 5000
tcpi_snd_cwnd = 1000
tcpi_rcv_space = 66000
tcpi_sacked = 0
tcpi_unacked = 0
tcpi_retransmits = 0
tcpi_retrans = 0
tcpi_snd_wnd = 32896
tcpi_snd_bwnd = 0
tcpi_snd_nxt = 2147908420
tcpi_rcv_nxt = 1
tcpi_toe_tid = 0
tcpi_snd_rexmitpack = 1
tcpi_rcv_ooopack = 0
tcpi_snd_zerowin = 0
_file = '/home/zeebsd/soc-16/fast_retransmit/fr-4pkt-sack-bsd.pkt'
_line = 43
assert tcpi_retrans == 0
running: '/usr/local/bin/python /tmp/code_0bqPia'
/home/zeebsd/soc-16/fast_retransmit/fr-4pkt-sack-bsd.pkt:12: error in Python code
Traceback (most recent call last):
File "/tmp/code_0bqPia", line 39, in <module>
assert tcpi_snd_wnd == 32892
AssertionError
/home/zeebsd/soc-16/fast_retransmit/fr-4pkt-sack-bsd.pkt: error executing code: '/usr/local/bin/python' returned non-zero status 1
// Test fast retransmit with 4 packets outstanding, receiver sending multiple SACKs.
// In this variant the receiver supports SACK.
// TODO~ Add sysctl for enabling fast retransmit.
// 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
0.000 %{ assert tcpi_snd_wnd == 32892 }%
0.000 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
0.000 > S. 0:0(0) ack 1 <...>
0.100 < . 1:1(0) ack 1 win 257
0.100 accept(3, ..., ...) = 4
// Send 1 data segment and get an ACK, so cwnd is now 4.
0.100 %{ assert tcpi_snd_wnd == 32892 }%
0.100 write(4, ..., 1000) = 1000
0.100 > P. 1:1001(1000) ack 1
0.100 %{ assert tcpi_snd_wnd == 32892 }%
0.200 < . 1:1(0) ack 1001 win 257
// Write 4 data segments.
0.200 write(4, ..., 4000) = 4000
0.200 > . 1001:2001(1000) ack 1
0.200 %{ assert tcpi_snd_wnd == 32892 }%
0.200 > . 2001:3001(1000) ack 1
0.200 > . 3001:4001(1000) ack 1
0.200 > P. 4001:5001(1000) ack 1
// Receiver sends 3 SACKs.
0.300 < . 1:1(0) ack 1001 win 257 <sack 2001:3001,nop,nop>
0.300 < . 1:1(0) ack 1001 win 257 <sack 2001:4001,nop,nop>
0.300 < . 1:1(0) ack 1001 win 257 <sack 2001:5001,nop,nop>
// We've received 3 duplicate ACKs, so we do a fast retransmit for the missing segment.
0.300 > . 1001:2001(1000) ack 1
0.300 %{
assert tcpi_retrans == 0
}%
// Receiver ACKs all data.
0.300 < . 1:1(0) ack 5001 win 257
// Test fast retransmit with 4 packets outstanding, receiver sending SACKs.
// In this variant the receiver supports SACK.
// Establish a connection.
0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0 bind(3, ..., ...) = 0
+0 listen(3, 1) = 0
+0 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
+0 > S. 0:0(0) ack 1 <...>
+.1 < . 1:1(0) ack 1 win 257
+0 accept(3, ..., ...) = 4
// Send 1 data segment and get an ACK, so cwnd is now 4.
+0 write(4, ..., 1000) = 1000
+0 > P. 1:1001(1000) ack 1
+.1 < . 1:1(0) ack 1001 win 257
// Write 4 data segments.
+0 write(4, ..., 4000) = 4000
+0 > . 1001:3001(2000) ack 1
+0 > P. 3001:5001(2000) ack 1
// Get 3 SACKs.
+.1 < . 1:1(0) ack 1001 win 257 <sack 2001:3001,nop,nop>
+0 < . 1:1(0) ack 1001 win 257 <sack 2001:4001,nop,nop>
+0 < . 1:1(0) ack 1001 win 257 <sack 2001:5001,nop,nop>
// We've received 3 duplicate ACKs, so we do a fast retransmit.
+0 > . 1001:2001(1000) ack 1
+0 %{
assert tcpi_retrans == 1
}%
// Receiver ACKs all data.
+.1 < . 1:1(0) ack 5001 win 257
▶ sudo ./packetdrill -v --tolerance_usecs=100000 tests/linux/fast_retransmit/fr-4pkt-sack-linux.pkt
inbound injected packet: 0.000032 S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
outbound sniffed packet: 0.000120 S. 2092882666:2092882666(0) ack 1 win 29200 <mss 1460,nop,nop,sackOK,nop,wscale 7>
inbound injected packet: 0.100281 . 1:1(0) ack 2092882667 win 257
outbound sniffed packet: 0.100376 P. 2092882667:2092883667(1000) ack 1 win 229
inbound injected packet: 0.200485 . 1:1(0) ack 2092883667 win 257
outbound sniffed packet: 0.200556 . 2092883667:2092885667(2000) ack 1 win 229
outbound sniffed packet: 0.200558 P. 2092885667:2092887667(2000) ack 1 win 229
inbound injected packet: 0.300716 . 1:1(0) ack 2092883667 win 257 <sack 2092884667:2092885667,nop,nop>
inbound injected packet: 0.300778 . 1:1(0) ack 2092883667 win 257 <sack 2092884667:2092886667,nop,nop>
inbound injected packet: 0.300794 . 1:1(0) ack 2092883667 win 257 <sack 2092884667:2092887667,nop,nop>
outbound sniffed packet: 0.300811 . 2092883667:2092884667(1000) ack 1 win 229
inbound injected packet: 0.401036 . 1:1(0) ack 2092887667 win 257
import sys
import traceback
def excepthook(etype, value, tb):
sys.stderr.write("%s:%d: error in Python code\n" %
(_file, _line))
traceback.print_exception(etype, value, tb)
sys.excepthook = excepthook
TCP_CA_Open = 0
TCP_CA_Disorder = 1
TCP_CA_CWR = 2
TCP_CA_Recovery = 3
TCP_CA_Loss = 4
TCPI_OPT_TIMESTAMPS = 1
TCPI_OPT_WSCALE = 4
TCPI_OPT_ECN = 8
tcpi_state = 1
tcpi_ca_state = 3
tcpi_retransmits = 0
tcpi_probes = 0
tcpi_backoff = 0
tcpi_options = 6
tcpi_snd_wscale = 7
tcpi_rcv_wscale = 7
tcpi_rto = 304000
tcpi_ato = 0
tcpi_snd_mss = 1000
tcpi_rcv_mss = 536
tcpi_unacked = 4
tcpi_sacked = 3
tcpi_lost = 1
tcpi_retrans = 1
tcpi_fackets = 4
tcpi_last_data_sent = 0
tcpi_last_ack_sent = 0
tcpi_last_data_recv = 33466876
tcpi_last_ack_recv = 0
tcpi_pmtu = 1500
tcpi_rcv_ssthresh = 29200
tcpi_rtt = 100132
tcpi_rttvar = 15999
tcpi_snd_ssthresh = 7
tcpi_snd_cwnd = 2
tcpi_advmss = 1460
tcpi_reordering = 3
tcpi_total_retrans = 1
tcpi_rcv_rtt = 0
tcpi_rcv_space = 29200
_file = 'tests/linux/fast_retransmit/fr-4pkt-sack-linux.pkt'
_line = 34
assert tcpi_retrans == 1
running: '/usr/bin/python /tmp/code_MWPOlS'
▶ sudo ./packetdrill -v --tolerance_usecs=100000 ~/soc-16/sack/test.pkt
inbound injected packet: 0.106674 S 0:0(0) win 65535 <mss 1460,sackOK,nop,nop,nop,wscale 7>
outbound sniffed packet: 0.106977 S. 3917768978:3917768978(0) ack 1 win 65535 <mss 1460,nop,wscale 6,sackOK,eol,eol>
inbound injected packet: 0.206174 . 1:1(0) ack 3917768979 win 65535
outbound sniffed packet: 0.206733 . 3917768979:3917770439(1460) ack 1 win 1026
outbound sniffed packet: 0.206741 . 3917770439:3917771899(1460) ack 1 win 1026
outbound sniffed packet: 0.206747 . 3917771899:3917773359(1460) ack 1 win 1026
outbound sniffed packet: 0.206753 . 3917773359:3917774819(1460) ack 1 win 1026
outbound sniffed packet: 0.206758 P. 3917774819:3917776279(1460) ack 1 win 1026
inbound injected packet: 0.306305 . 1:1(0) ack 3917768979 win 65535 <sack 3917770439:3917771899,nop,nop>
import sys
import traceback
def excepthook(etype, value, tb):
sys.stderr.write("%s:%d: error in Python code\n" %
(_file, _line))
traceback.print_exception(etype, value, tb)
sys.excepthook = excepthook
tcpi_state = 4
tcpi_options = 6
tcpi_snd_wscale = 7
tcpi_rcv_wscale = 6
tcpi_rto = 3000000
tcpi_snd_mss = 1460
tcpi_rcv_mss = 1460
tcpi_last_data_recv = 1000
tcpi_rtt = 0
tcpi_rttvar = 750000
tcpi_snd_ssthresh = 1073725440
tcpi_snd_cwnd = 14601
tcpi_rcv_space = 65700
tcpi_snd_wnd = 8388480
tcpi_snd_bwnd = 0
tcpi_snd_nxt = 3917776279
tcpi_rcv_nxt = 1
tcpi_toe_tid = 0
tcpi_snd_rexmitpack = 0
tcpi_rcv_ooopack = 0
tcpi_snd_zerowin = 0
tcpi_sacked = 0
tcpi_unacked = 0
_file = '/home/zeebsd/soc-16/sack/test.pkt'
_line = 20
assert tcpi_unacked == 5
assert tcpi_sacked == 0
tcpi_state = 4
tcpi_options = 6
tcpi_snd_wscale = 7
tcpi_rcv_wscale = 6
tcpi_rto = 3000000
tcpi_snd_mss = 1460
tcpi_rcv_mss = 1460
tcpi_last_data_recv = 0
tcpi_rtt = 0
tcpi_rttvar = 750000
tcpi_snd_ssthresh = 1073725440
tcpi_snd_cwnd = 14601
tcpi_rcv_space = 65700
tcpi_snd_wnd = 8388480
tcpi_snd_bwnd = 0
tcpi_snd_nxt = 3917776279
tcpi_rcv_nxt = 1
tcpi_toe_tid = 0
tcpi_snd_rexmitpack = 0
tcpi_rcv_ooopack = 0
tcpi_snd_zerowin = 0
tcpi_sacked = 0
tcpi_unacked = 0
_file = '/home/zeebsd/soc-16/sack/test.pkt'
_line = 26
assert tcpi_unacked == 4
assert tcpi_sacked == 1
running: '/usr/local/bin/python /tmp/code_r7jKoK'
/home/zeebsd/soc-16/sack/test.pkt:20: error in Python code
Traceback (most recent call last):
File "/tmp/code_r7jKoK", line 38, in <module>
assert tcpi_unacked == 5
AssertionError
/home/zeebsd/soc-16/sack/test.pkt: error executing code: '/usr/local/bin/python' returned non-zero status 1
/* Line 2669 net/ipv4/tcp.c */
if (info->tcpi_state == TCP_LISTEN) {
info->tcpi_unacked = sk->sk_ack_backlog; /* Line 410 include/net/sock.h */
info->tcpi_sacked = sk->sk_max_ack_backlog;
} else {
info->tcpi_unacked = tp->packets_out;
info->tcpi_sacked = tp->sacked_out;
}
info->tcpi_lost = tp->lost_out;
info->tcpi_retrans = tp->retrans_out;
info->tcpi_fackets = tp->fackets_out;
/* Line 306 include/net/sock.h
* Definition for struck sock
*/
/* Line 767 */
static inline void sk_acceptq_removed(struct sock *sk)
{
sk->sk_ack_backlog--;
}
packet_to_string.c:192: if (packet->tcp->urg)
tcp.h:102: urg:1,
tcp.h:111: urg:1,
tcp.h:122: __be16 urg_ptr;
tcp_packet.c:142: packet->tcp->urg_ptr = 0;
tcp_packet.c:148: packet->tcp->urg = 0;
run_packet.c:2234: check_field("tcp_urg",
run_packet.c:2235: script_tcp->urg,
run_packet.c:2236: actual_tcp->urg, error) ||
run_packet.c:2256: check_field("tcp_urg_ptr",
run_packet.c:2257: ntohs(script_tcp->urg_ptr),
run_packet.c:2258: ntohs(actual_tcp->urg_ptr), error))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment