```
// Testing AccECN handshakes
// Both Client and Server, as well as parallel SYN
--tolerance_usecs=2000000
// Set sysctl defaults
0.0 `sysctl net.inet.tcp.cc.algorithm=newreno`
+0.1 `sysctl net.inet.tcp.functions_default=freebsd`
+0.1 `sysctl net.inet.tcp.initcwnd_segments=10`
+0.1 `sysctl net.inet.tcp.ecn.enable=4`
+0.1 `sysctl net.inet.tcp.hostcache.purgenow=1`
+0.1 `dmesg -c`
// Test Server side
// Establish a regular TCP ECN connection.
+0.0 `echo 'server: regular ECN'`
+0.50 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0.01 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_LINGER, {onoff=1, linger=0}, 8) = 0
+0.01 bind(3, ..., ...) = 0
+0.01 listen(3, 1) = 0
+0.04 <[noecn] SEW 0:0(0) win 65535 <mss 1000, wscale 10, eol >
+0.00 >[noecn] SE. 0:0(0) ack 1 win 65535 <...>
+0.00 <[noecn] . 1:1(0) ack 1 win 65535
+0.00 accept(3, ..., ...) = 4
+0.00 close(4) = 0
+0.00 >[noecn] R. 1:1(0) ack 1 win 0
+0.00 close(3) = 0
// Establish a AccECN TCP session, non-ECT
+0.0 `echo 'server: AccECN non-ECT'`
+0.50 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0.01 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_LINGER, {onoff=1, linger=0}, 8) = 0
+0.01 bind(3, ..., ...) = 0
+0.01 listen(3, 1) = 0
+0.04 <[noecn] S7 0:0(0) win 65535 <mss 1000, wscale 10, eol >
+0.00 >[noecn] SW. 0:0(0) ack 1 win 65535 <...>
+0.00 <[noecn] . 1:1(0) ack 1 win 65535
+0.00 accept(3, ..., ...) = 5
+0.00 close(5) = 0
+0.00 >[noecn] R. 1:1(0) ack 1 win 0
+0.00 close(3) = 0
// Establish a AccECN TCP session, ECT0
+0.0 `echo 'server: AccECN ECT0'`
+0.50 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0.01 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_LINGER, {onoff=1, linger=0}, 8) = 0
+0.01 bind(3, ..., ...) = 0
+0.01 listen(3, 1) = 0
+0.04 <[ect0] S7 0:0(0) win 65535 <mss 1000, wscale 10, eol >
+0.00 >[noecn] SA. 0:0(0) ack 1 win 65535 <...>
+0.00 <[noecn] . 1:1(0) ack 1 win 65535
+0.00 accept(3, ..., ...) = 6
+0.00 close(6) = 0
+0.00 >[noecn] R. 1:1(0) ack 1 win 0
+0.00 close(3) = 0
// Establish a AccECN TCP session, ECT1
+0.0 `echo 'server: AccECN ECT1'`
+0.50 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0.01 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_LINGER, {onoff=1, linger=0}, 8) = 0
+0.01 bind(3, ..., ...) = 0
+0.01 listen(3, 1) = 0
+0.04 <[ect1] S7 0:0(0) win 65535 <mss 1000, wscale 10, eol >
+0.00 >[noecn] SEW. 0:0(0) ack 1 win 65535 <...>
+0.00 <[noecn] . 1:1(0) ack 1 win 65535
+0.00 accept(3, ..., ...) = 7
+0.00 close(7) = 0
+0.00 >[noecn] R. 1:1(0) ack 1 win 0
+0.00 close(3) = 0
// Establish a AccECN TCP session, CE
+0.0 `echo 'server: AccECN CE'`
+0.50 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0.01 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_LINGER, {onoff=1, linger=0}, 8) = 0
+0.01 bind(3, ..., ...) = 0
+0.01 listen(3, 1) = 0
+0.04 <[ce] S7 0:0(0) win 65535 <mss 1000, wscale 10, eol >
+0.00 >[noecn] SAW. 0:0(0) ack 1 win 65535 <...>
+0.00 <[noecn] . 1:1(0) ack 1 win 65535
+0.00 accept(3, ..., ...) = 8
+0.00 close(8) = 0
+0.00 >[noecn] R. 1:1(0) ack 1 win 0
+0.00 close(3) = 0
// Test Client Side
// Establish a regular TCP connection.
+0.0 `echo 'client: no ECN'`
+0.50 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0.01 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_LINGER, {onoff=1, linger=0}, 8) = 0
+0.04 connect(3, ..., ...) = -1 // EINPROGRESS
+0.00 >[noecn] S 0:0(0) win 65535 <...>
+0.00 <[noecn] S. 0:0(0) ack 1 win 65535
+0.00 >[noecn] . 1:1(0) ack 1 win 65535
+0.01 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
+0.01 fcntl(3, F_SETFL, O_RDWR) = 0
+0.00 close(3) = 0
+0.0 `echo 'client: AccECN to non-ECN'`
+0.10 `sysctl net.inet.tcp.ecn.enable=3`
+0.40 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0.01 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_LINGER, {onoff=1, linger=0}, 8) = 0
+0.04 connect(3, ..., ...) = -1 // EINPROGRESS
+0.00 >[noecn] S7 0:0(0) win 65535 <...>
+0.00 <[noecn] S. 0:0(0) ack 1 win 65535
+0.00 >[noecn] . 1:1(0) ack 1 win 65535
+0.01 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
+0.01 fcntl(3, F_SETFL, O_RDWR) = 0
+0.00 close(3) = 0
+0.0 `echo 'client: AccECN to RFC3168 ECN'`
+0.50 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0.01 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_LINGER, {onoff=1, linger=0}, 8) = 0
+0.04 connect(3, ..., ...) = -1 // EINPROGRESS
+0.00 >[noecn] S7 0:0(0) win 65535 <...>
+0.00 <[noecn] SE. 0:0(0) ack 1 win 65535
+0.00 >[noecn] . 1:1(0) ack 1 win 65535
+0.01 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
+0.01 fcntl(3, F_SETFL, O_RDWR) = 0
+0.00 close(3) = 0
// Establish a AccECN TCP session, non-ECT
+0.0 `echo 'client: AccECN non-ECT SYNACK'`
+0.50 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0.01 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_LINGER, {onoff=1, linger=0}, 8) = 0
+0.04 connect(3, ..., ...) = -1 // EINPROGRESS
+0.00 >[noecn] S7 0:0(0) win 65535 <...>
+0.00 <[noecn] SW. 0:0(0) ack 1 win 65535
+0.00 >[noecn] .2 1:1(0) ack 1 win 65535
+0.00 <[noecn] .5 1:2(1) ack 1 win 65535
+0.04 >[noecn] .5 1:1(0) ack 2 win 65535
+0.01 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
+0.01 fcntl(3, F_SETFL, O_RDWR) = 0
+0.00 close(3) = 0
// Establish a AccECN TCP session, ECT0
+0.0 `echo 'client: AccECN ECT0 SYNACK'`
+0.50 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0.01 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_LINGER, {onoff=1, linger=0}, 8) = 0
+0.04 connect(3, ..., ...) = -1 // EINPROGRESS
+0.00 >[noecn] S7 0:0(0) win 65535 <...>
+0.00 <[ect0] SW. 0:0(0) ack 1 win 65535
+0.00 >[noecn] .4 1:1(0) ack 1 win 65535
+0.00 <[noecn] .5 1:2(1) ack 1 win 65535
+0.04 >[noecn] .5 1:1(0) ack 2 win 65535
+0.01 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
+0.01 fcntl(3, F_SETFL, O_RDWR) = 0
+0.00 close(3) = 0
// Establish a AccECN TCP session, ECT1
+0.0 `echo 'client: AccECN ECT1 SYNACK'`
+0.50 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0.01 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_LINGER, {onoff=1, linger=0}, 8) = 0
+0.04 connect(3, ..., ...) = -1 // EINPROGRESS
+0.00 >[noecn] S7 0:0(0) win 65535 <...>
+0.00 <[ect1] SW. 0:0(0) ack 1 win 65535
+0.00 >[noecn] .3 1:1(0) ack 1 win 65535
+0.00 <[noecn] .5 1:2(1) ack 1 win 65535
+0.04 >[noecn] .5 1:1(0) ack 2 win 65535
+0.01 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
+0.01 fcntl(3, F_SETFL, O_RDWR) = 0
+0.00 close(3) = 0
// Establish a AccECN TCP session, CE
+0.0 `echo 'client: AccECN CE SYNACK'`
+0.50 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0.01 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_LINGER, {onoff=1, linger=0}, 8) = 0
+0.04 connect(3, ..., ...) = -1 // EINPROGRESS
+0.00 >[noecn] S7 0:0(0) win 65535 <...>
+0.00 <[ce] SW. 0:0(0) ack 1 win 65535
+0.00 >[noecn] .6 1:1(0) ack 1 win 65535
+0.00 <[noecn] .5 1:2(1) ack 1 win 65535
+0.04 >[noecn] .6 1:1(0) ack 2 win 65535
+0.01 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
+0.01 fcntl(3, F_SETFL, O_RDWR) = 0
+0.00 close(3) = 0
// Simultaneous Open
// Establish a regular TCP ECN connection.
+0.0 `echo 'parallel open: ECN'`
+0.10 `sysctl net.inet.tcp.ecn.enable=1`
+0.40 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0.01 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_LINGER, {onoff=1, linger=0}, 8) = 0
+0.04 connect(3, ..., ...) = -1 // EINPROGRESS
+0.00 >[noecn] SEW 0:0(0) win 65535 <...>
+0.00 <[noecn] SEW 0:0(0) ack 1 win 65535 <mss 1000>
+0.00 >[noecn] SE. 0:0(0) ack 1 win 65535 <...>
+0.00 <[noecn] SE. 0:0(0) ack 1 win 65535 <mss 1000>
+0.00 >[noecn] . 1:1(0) ack 1 win 65535
+0.01 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
+0.01 fcntl(3, F_SETFL, O_RDWR) = 0
+0.05 write(3, ..., 1000) = 1000
+0.00 >[ect0] PW. 1:1001(1000) ack 1 win 65535
+0.00 <[noecn] E. 1:1(0) ack 1001 win 65535
+0.05 write(3, ..., 1000) = 1000
+0.00 >[ect0] PW. 1001:2001(1000) ack 1 win 65535
+0.00 <[ce] . 1:2(1) ack 2001 win 65535
// rack: ect0??
+0.00 >[noecn] E. 2001:2001(0) ack 2 win 65535
+0.00 close(3) = 0
// Establish an AccECN TCP ECN without ECT
+0.0 `echo 'parallel open: AccECN non-ECT'`
+0.10 `sysctl net.inet.tcp.ecn.enable=3`
+0.40 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0.01 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_LINGER, {onoff=1, linger=0}, 8) = 0
+0.04 connect(3, ..., ...) = -1 // EINPROGRESS
+0.00 >[noecn] S7 0:0(0) win 65535 <...>
+0.00 <[noecn] S7 0:0(0) ack 1 win 65535 <mss 1000>
+0.00 >[noecn] SW. 0:0(0) ack 1 win 65535 <...>
+0.00 <[noecn] SW. 0:0(0) ack 1 win 65535 <mss 1000>
+0.00 >[noecn] .5 1:1(0) ack 1 win 65535
+0.00 <[ce] .5 1:2(1) ack 1 win 65535
+0.04 >[noecn] .6 1:1(0) ack 2 win 65535
+0.05 write(3, ..., 1000) = 1000
+0.00 >[ect0] P.6 1:1001(1000) ack 2 win 65535
+0.00 <[ce] .5 2:3(1) ack 1001 win 65535
+0.00 >[noecn] .7 1001:1001(0) ack 3 win 65535
+0.01 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
+0.01 fcntl(3, F_SETFL, O_RDWR) = 0
+0.00 close(3) = 0
// Establish an AccECN TCP ECN with ECT0
+0.0 `echo 'parallel open: AccECN ECT0'`
+0.40 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0.01 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_LINGER, {onoff=1, linger=0}, 8) = 0
+0.04 connect(3, ..., ...) = -1 // EINPROGRESS
+0.00 >[noecn] S7 0:0(0) win 65535 <...>
+0.00 <[ect0] S7 0:0(0) ack 1 win 65535 <mss 1000>
+0.00 >[noecn] SA. 0:0(0) ack 1 win 65535 <...>
+0.00 <[noecn] SW. 0:0(0) ack 1 win 65535 <mss 1000>
+0.00 >[noecn] .5 1:1(0) ack 1 win 65535
+0.00 <[ce] .5 1:2(1) ack 1 win 65535
+0.04 >[noecn] .6 1:1(0) ack 2 win 65535
+0.05 write(3, ..., 1000) = 1000
+0.00 >[ect0] P.6 1:1001(1000) ack 2 win 65535
+0.00 <[ce] .5 2:3(1) ack 1001 win 65535
+0.00 >[noecn] .7 1001:1001(0) ack 3 win 65535
+0.01 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
+0.01 fcntl(3, F_SETFL, O_RDWR) = 0
+0.00 close(3) = 0
// Establish an AccECN TCP ECN with ECT1
+0.0 `echo 'parallel open: AccECN ECT1'`
+0.40 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0.01 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_LINGER, {onoff=1, linger=0}, 8) = 0
+0.04 connect(3, ..., ...) = -1 // EINPROGRESS
+0.00 >[noecn] S7 0:0(0) win 65535 <...>
+0.00 <[ect1] S7 0:0(0) ack 1 win 65535 <mss 1000>
+0.00 >[noecn] SEW. 0:0(0) ack 1 win 65535 <...>
+0.00 <[noecn] SW. 0:0(0) ack 1 win 65535 <mss 1000>
+0.00 >[noecn] .5 1:1(0) ack 1 win 65535
+0.00 <[ce] .5 1:2(1) ack 1 win 65535
+0.04 >[noecn] .6 1:1(0) ack 2 win 65535
+0.05 write(3, ..., 1000) = 1000
+0.00 >[ect0] P.6 1:1001(1000) ack 2 win 65535
+0.00 <[ce] .5 2:3(1) ack 1001 win 65535
+0.00 >[noecn] .7 1001:1001(0) ack 3 win 65535
+0.01 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
+0.01 fcntl(3, F_SETFL, O_RDWR) = 0
+0.00 close(3) = 0
// Establish an AccECN TCP ECN with CE
+0.0 `echo 'parallel open: AccECN CE'`
+0.40 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0.01 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0.01 setsockopt(3, SOL_SOCKET, SO_LINGER, {onoff=1, linger=0}, 8) = 0
+0.04 connect(3, ..., ...) = -1 // EINPROGRESS
+0.00 >[noecn] S7 0:0(0) win 65535 <...>
+0.00 <[ce] S7 0:0(0) ack 1 win 65535 <mss 1000>
+0.00 >[noecn] SAW. 0:0(0) ack 1 win 65535 <...>
+0.00 <[noecn] SW. 0:0(0) ack 1 win 65535 <mss 1000>
+0.00 >[noecn] .6 1:1(0) ack 1 win 65535
+0.00 <[ce] .5 1:2(1) ack 1 win 65535
+0.04 >[noecn] .7 1:1(0) ack 2 win 65535
+0.05 write(3, ..., 1000) = 1000
+0.00 >[ect0] P.7 1:1001(1000) ack 2 win 65535
+0.00 <[ce] .5 2:3(1) ack 1001 win 65535
+0.00 >[noecn] .0 1001:1001(0) ack 3 win 65535
+0.01 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
+0.01 fcntl(3, F_SETFL, O_RDWR) = 0
+0.00 close(3) = 0
`{
dmesg
sysctl net.inet.tcp.functions_default=freebsd;
sysctl net.inet.tcp.cc.algorithm=newreno;
sysctl net.inet.tcp.initcwnd_segments=10;
sysctl net.inet.tcp.rfc3465=1;
sysctl net.inet.tcp.rfc1323=1;
sysctl net.inet.tcp.sack.enable=1;
sysctl net.inet.tcp.rexmit_slop=200;
sysctl net.inet.tcp.rexmit_min=30;
sysctl net.inet.tcp.rexmit_initial=1000;
sysctl net.inet.tcp.ecn.enable=2;
}`
```