1*eab35989SSoham Chakradeo// SPDX-License-Identifier: GPL-2.0 2*eab35989SSoham Chakradeo// Test tx timestamping for partial writes (IPv4). 3*eab35989SSoham Chakradeo`./defaults.sh 4*eab35989SSoham Chakradeo` 5*eab35989SSoham Chakradeo 6*eab35989SSoham Chakradeo// Create a socket and set it to non-blocking. 7*eab35989SSoham Chakradeo 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 8*eab35989SSoham Chakradeo +0 fcntl(3, F_GETFL) = 0x2 (flags O_RDWR) 9*eab35989SSoham Chakradeo +0 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0 10*eab35989SSoham Chakradeo 11*eab35989SSoham Chakradeo// Establish connection and verify that there was no error. 12*eab35989SSoham Chakradeo +0 connect(3, ..., ...) = -1 EINPROGRESS (Operation now in progress) 13*eab35989SSoham Chakradeo +0 > S 0:0(0) <mss 1460,sackOK,TS val 100 ecr 0,nop,wscale 8> 14*eab35989SSoham Chakradeo +.01 < S. 0:0(0) ack 1 win 2000 <mss 1000,sackOK,TS val 700 ecr 100,nop,wscale 7> 15*eab35989SSoham Chakradeo +0 > . 1:1(0) ack 1 <nop,nop,TS val 200 ecr 700> 16*eab35989SSoham Chakradeo +0 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0 17*eab35989SSoham Chakradeo 18*eab35989SSoham Chakradeo +0 setsockopt(3, SOL_SOCKET, SO_SNDBUF, [1000], 4) = 0 19*eab35989SSoham Chakradeo +0 setsockopt(3, SOL_SOCKET, SO_TIMESTAMPING, 20*eab35989SSoham Chakradeo [SOF_TIMESTAMPING_TX_SCHED | SOF_TIMESTAMPING_TX_SOFTWARE | 21*eab35989SSoham Chakradeo SOF_TIMESTAMPING_TX_ACK | SOF_TIMESTAMPING_SOFTWARE | 22*eab35989SSoham Chakradeo SOF_TIMESTAMPING_OPT_ID], 4) = 0 23*eab35989SSoham Chakradeo 24*eab35989SSoham Chakradeo// We have a partial write. 25*eab35989SSoham Chakradeo +0 write(3, ..., 10000) = 2964 26*eab35989SSoham Chakradeo +0 > . 1:989(988) ack 1 <nop,nop,TS val 110 ecr 700> 27*eab35989SSoham Chakradeo +0 > P. 989:1977(988) ack 1 <nop,nop,TS val 110 ecr 700> 28*eab35989SSoham Chakradeo +.01 < . 1:1(0) ack 1977 win 92 <nop,nop,TS val 800 ecr 200> 29*eab35989SSoham Chakradeo +0 > P. 1977:2965(988) ack 1 <nop,nop,TS val 114 ecr 800> 30*eab35989SSoham Chakradeo +.01 < . 1:1(0) ack 2965 win 92 <nop,nop,TS val 800 ecr 200> 31*eab35989SSoham Chakradeo 32*eab35989SSoham Chakradeo// Make sure that internal TCP timestamps are not overwritten and we have sane 33*eab35989SSoham Chakradeo// RTT measurement. 34*eab35989SSoham Chakradeo +0 %{ 35*eab35989SSoham Chakradeoassert 5000 <= tcpi_rtt <= 20000, 'srtt=%d us' % tcpi_rtt 36*eab35989SSoham Chakradeo}% 37*eab35989SSoham Chakradeo 38*eab35989SSoham Chakradeo// SCM_TSTAMP_SCHED for the first chunk should be received almost immediately 39*eab35989SSoham Chakradeo// after the first ack at t=20ms. 40*eab35989SSoham Chakradeo +0 recvmsg(3, {msg_name(...)=..., 41*eab35989SSoham Chakradeo msg_iov(1)=[{...,0}], 42*eab35989SSoham Chakradeo msg_flags=MSG_ERRQUEUE|MSG_TRUNC, 43*eab35989SSoham Chakradeo msg_control=[ 44*eab35989SSoham Chakradeo {cmsg_level=SOL_SOCKET, 45*eab35989SSoham Chakradeo cmsg_type=SCM_TIMESTAMPING, 46*eab35989SSoham Chakradeo cmsg_data={scm_sec=0,scm_nsec=20000000}}, 47*eab35989SSoham Chakradeo {cmsg_level=CMSG_LEVEL_IP, 48*eab35989SSoham Chakradeo cmsg_type=CMSG_TYPE_RECVERR, 49*eab35989SSoham Chakradeo cmsg_data={ee_errno=ENOMSG, 50*eab35989SSoham Chakradeo ee_origin=SO_EE_ORIGIN_TIMESTAMPING, 51*eab35989SSoham Chakradeo ee_type=0, 52*eab35989SSoham Chakradeo ee_code=0, 53*eab35989SSoham Chakradeo ee_info=SCM_TSTAMP_SCHED, 54*eab35989SSoham Chakradeo ee_data=2963}} 55*eab35989SSoham Chakradeo ]}, MSG_ERRQUEUE) = 0 56*eab35989SSoham Chakradeo// SCM_TSTAMP_SND for the first chunk should be received almost immediately 57*eab35989SSoham Chakradeo// after the first ack at t=20ms. 58*eab35989SSoham Chakradeo +0 recvmsg(3, {msg_name(...)=..., 59*eab35989SSoham Chakradeo msg_iov(1)=[{...,0}], 60*eab35989SSoham Chakradeo msg_flags=MSG_ERRQUEUE|MSG_TRUNC, 61*eab35989SSoham Chakradeo msg_control=[ 62*eab35989SSoham Chakradeo {cmsg_level=SOL_SOCKET, 63*eab35989SSoham Chakradeo cmsg_type=SCM_TIMESTAMPING, 64*eab35989SSoham Chakradeo cmsg_data={scm_sec=0,scm_nsec=20000000}}, 65*eab35989SSoham Chakradeo {cmsg_level=CMSG_LEVEL_IP, 66*eab35989SSoham Chakradeo cmsg_type=CMSG_TYPE_RECVERR, 67*eab35989SSoham Chakradeo cmsg_data={ee_errno=ENOMSG, 68*eab35989SSoham Chakradeo ee_origin=SO_EE_ORIGIN_TIMESTAMPING, 69*eab35989SSoham Chakradeo ee_type=0, 70*eab35989SSoham Chakradeo ee_code=0, 71*eab35989SSoham Chakradeo ee_info=SCM_TSTAMP_SND, 72*eab35989SSoham Chakradeo ee_data=2963}} 73*eab35989SSoham Chakradeo ]}, MSG_ERRQUEUE) = 0 74*eab35989SSoham Chakradeo// SCM_TSTAMP_ACK for the first chunk should be received after the last ack at 75*eab35989SSoham Chakradeo// t=30ms. 76*eab35989SSoham Chakradeo +0 recvmsg(3, {msg_name(...)=..., 77*eab35989SSoham Chakradeo msg_iov(1)=[{...,0}], 78*eab35989SSoham Chakradeo msg_flags=MSG_ERRQUEUE|MSG_TRUNC, 79*eab35989SSoham Chakradeo msg_control=[ 80*eab35989SSoham Chakradeo {cmsg_level=SOL_SOCKET, 81*eab35989SSoham Chakradeo cmsg_type=SCM_TIMESTAMPING, 82*eab35989SSoham Chakradeo cmsg_data={scm_sec=0,scm_nsec=30000000}}, 83*eab35989SSoham Chakradeo {cmsg_level=CMSG_LEVEL_IP, 84*eab35989SSoham Chakradeo cmsg_type=CMSG_TYPE_RECVERR, 85*eab35989SSoham Chakradeo cmsg_data={ee_errno=ENOMSG, 86*eab35989SSoham Chakradeo ee_origin=SO_EE_ORIGIN_TIMESTAMPING, 87*eab35989SSoham Chakradeo ee_type=0, 88*eab35989SSoham Chakradeo ee_code=0, 89*eab35989SSoham Chakradeo ee_info=SCM_TSTAMP_ACK, 90*eab35989SSoham Chakradeo ee_data=2963}} 91*eab35989SSoham Chakradeo ]}, MSG_ERRQUEUE) = 0 92