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