1// SPDX-License-Identifier: GPL-2.0 2// Test tx timestamping for server-side (IPv4). 3`./defaults.sh 4` 5 6// Initialize connection 7 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 8 +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 9 +0 bind(3, ..., ...) = 0 10 +0 listen(3, 1) = 0 11 12 +0 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 10> 13 +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8> 14 +.01 < . 1:1(0) ack 1 win 514 15 16 +0 accept(3, ..., ...) = 4 17 +0 setsockopt(4, SOL_SOCKET, SO_TIMESTAMPING, 18 [SOF_TIMESTAMPING_TX_SCHED | SOF_TIMESTAMPING_TX_SOFTWARE | 19 SOF_TIMESTAMPING_TX_ACK | SOF_TIMESTAMPING_SOFTWARE | 20 SOF_TIMESTAMPING_OPT_ID], 4) = 0 21 22// Write two 2KB chunks. 23// setsockopt(..., [SOF_TIMESTAMPING_SOFTWARE | SOF_TIMESTAMPING_OPT_ID], ...) 24// is called after when SYN is acked. So, we expect the last byte of the first 25// and the second chunks to have timestamp keys of 1999 (i.e., 2000 - 1) and 26// 3999 (i.e., 4000 - 1) respectively. 27 +0 write(4, ..., 2000) = 2000 28 +0 write(4, ..., 2000) = 2000 29 +0 > P. 1:2001(2000) ack 1 30 +0 > P. 2001:4001(2000) ack 1 31 +.01 < . 1:1(0) ack 2001 win 514 32 +.01 < . 1:1(0) ack 4001 win 514 33 34// Make sure that internal TCP timestamps are not overwritten and we have sane 35// RTT measurement. 36 +0 %{ 37assert 5000 <= tcpi_rtt <= 20000, 'srtt=%d us' % tcpi_rtt 38}% 39 40// SCM_TSTAMP_SCHED for the first chunk should be received almost immediately 41// after write at t=10ms. 42 +0 recvmsg(4, {msg_name(...)=..., 43 msg_iov(1)=[{...,0}], 44 msg_flags=MSG_ERRQUEUE|MSG_TRUNC, 45 msg_control=[ 46 {cmsg_level=SOL_SOCKET, 47 cmsg_type=SCM_TIMESTAMPING, 48 cmsg_data={scm_sec=0,scm_nsec=10000000}}, 49 {cmsg_level=CMSG_LEVEL_IP, 50 cmsg_type=CMSG_TYPE_RECVERR, 51 cmsg_data={ee_errno=ENOMSG, 52 ee_origin=SO_EE_ORIGIN_TIMESTAMPING, 53 ee_type=0, 54 ee_code=0, 55 ee_info=SCM_TSTAMP_SCHED, 56 ee_data=1999}} 57 ]}, MSG_ERRQUEUE) = 0 58// SCM_TSTAMP_SND for the first chunk should be received almost immediately 59// after write at t=10ms. 60 +0 recvmsg(4, {msg_name(...)=..., 61 msg_iov(1)=[{...,0}], 62 msg_flags=MSG_ERRQUEUE|MSG_TRUNC, 63 msg_control=[ 64 {cmsg_level=SOL_SOCKET, 65 cmsg_type=SCM_TIMESTAMPING, 66 cmsg_data={scm_sec=0,scm_nsec=10000000}}, 67 {cmsg_level=CMSG_LEVEL_IP, 68 cmsg_type=CMSG_TYPE_RECVERR, 69 cmsg_data={ee_errno=ENOMSG, 70 ee_origin=SO_EE_ORIGIN_TIMESTAMPING, 71 ee_type=0, 72 ee_code=0, 73 ee_info=SCM_TSTAMP_SND, 74 ee_data=1999}} 75 ]}, MSG_ERRQUEUE) = 0 76// SCM_TSTAMP_SCHED for the second chunk should be received almost immediately 77// after that at t=10ms. 78 +0 recvmsg(4, {msg_name(...)=..., 79 msg_iov(1)=[{...,0}], 80 msg_flags=MSG_ERRQUEUE|MSG_TRUNC, 81 msg_control=[ 82 {cmsg_level=SOL_SOCKET, 83 cmsg_type=SCM_TIMESTAMPING, 84 cmsg_data={scm_sec=0,scm_nsec=10000000}}, 85 {cmsg_level=CMSG_LEVEL_IP, 86 cmsg_type=CMSG_TYPE_RECVERR, 87 cmsg_data={ee_errno=ENOMSG, 88 ee_origin=SO_EE_ORIGIN_TIMESTAMPING, 89 ee_type=0, 90 ee_code=0, 91 ee_info=SCM_TSTAMP_SCHED, 92 ee_data=3999}} 93 ]}, MSG_ERRQUEUE) = 0 94// SCM_TSTAMP_SND for the second chunk should be received almost immediately 95// after that at t=10ms. 96 +0 recvmsg(4, {msg_name(...)=..., 97 msg_iov(1)=[{...,0}], 98 msg_flags=MSG_ERRQUEUE|MSG_TRUNC, 99 msg_control=[ 100 {cmsg_level=SOL_SOCKET, 101 cmsg_type=SCM_TIMESTAMPING, 102 cmsg_data={scm_sec=0,scm_nsec=10000000}}, 103 {cmsg_level=CMSG_LEVEL_IP, 104 cmsg_type=CMSG_TYPE_RECVERR, 105 cmsg_data={ee_errno=ENOMSG, 106 ee_origin=SO_EE_ORIGIN_TIMESTAMPING, 107 ee_type=0, 108 ee_code=0, 109 ee_info=SCM_TSTAMP_SND, 110 ee_data=3999}} 111 ]}, MSG_ERRQUEUE) = 0 112// SCM_TSTAMP_ACK for the first chunk should be received at t=20ms. 113 +0 recvmsg(4, {msg_name(...)=..., 114 msg_iov(1)=[{...,0}], 115 msg_flags=MSG_ERRQUEUE|MSG_TRUNC, 116 msg_control=[ 117 {cmsg_level=SOL_SOCKET, 118 cmsg_type=SCM_TIMESTAMPING, 119 cmsg_data={scm_sec=0,scm_nsec=20000000}}, 120 {cmsg_level=CMSG_LEVEL_IP, 121 cmsg_type=CMSG_TYPE_RECVERR, 122 cmsg_data={ee_errno=ENOMSG, 123 ee_origin=SO_EE_ORIGIN_TIMESTAMPING, 124 ee_type=0, 125 ee_code=0, 126 ee_info=SCM_TSTAMP_ACK, 127 ee_data=1999}} 128 ]}, MSG_ERRQUEUE) = 0 129// SCM_TSTAMP_ACK for the second chunk should be received at t=30ms. 130 +0 recvmsg(4, {msg_name(...)=..., 131 msg_iov(1)=[{...,0}], 132 msg_flags=MSG_ERRQUEUE|MSG_TRUNC, 133 msg_control=[ 134 {cmsg_level=SOL_SOCKET, 135 cmsg_type=SCM_TIMESTAMPING, 136 cmsg_data={scm_sec=0,scm_nsec=30000000}}, 137 {cmsg_level=CMSG_LEVEL_IP, 138 cmsg_type=CMSG_TYPE_RECVERR, 139 cmsg_data={ee_errno=ENOMSG, 140 ee_origin=SO_EE_ORIGIN_TIMESTAMPING, 141 ee_type=0, 142 ee_code=0, 143 ee_info=SCM_TSTAMP_ACK, 144 ee_data=3999}} 145 ]}, MSG_ERRQUEUE) = 0 146