From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shailja Pandey Subject: How to update the sequence number in TCP packets using DPDK-pktgen? Date: Mon, 9 Oct 2017 19:12:49 +0530 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable To: dev@dpdk.org Return-path: Received: from smtp2.iitd.ac.in (smtp2.iitd.ac.in [103.27.10.44]) by dpdk.org (Postfix) with ESMTP id 1CD811B1BC for ; Mon, 9 Oct 2017 15:43:04 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.iitd.ac.in (Postfix) with ESMTP id 351F440B68 for ; Mon, 9 Oct 2017 19:13:03 +0530 (IST) Received: from smtp2.iitd.ac.in ([127.0.0.1]) by localhost (smtp2.iitd.ac.in [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id zJuPoDhgnoLQ for ; Mon, 9 Oct 2017 19:12:58 +0530 (IST) Received: from [10.237.23.243] (unknown [10.237.23.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: csz168117) by smtp2.iitd.ac.in (Postfix) with ESMTPSA id 392CD409D5 for ; Mon, 9 Oct 2017 19:12:58 +0530 (IST) Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi, In the DPDK application, I am maintaining some state and due to that I=20 need to generate the packets with monotonically increasing sequence=20 numbers. As shown in the code below, /tip->tcp.seq=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D htonl(DEFAULT= _PKT_NUMBER);/ DPDK is putting some default number as a sequence number in the TCP=20 packet and not using as defined by TCP protocol. I tried various=20 workarounds but due to multi-threaded nature of the pktgen application,=20 I am facing some issues and unable to put sequence numbers in increasing=20 order. I tried thread_local and pthread_mutex_lock etc to generate=20 packets with increasing sequence number. I am not very sure what am I missing, Please help me in this matter. _Function:_ void pktgen_tcp_hdr_ctor(pkt_seq_t *pkt, tcpip_t *tip, int type __rte_unused) { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uint16_t tlen; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Zero out the header space = */ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 memset((char *)tip, 0, sizeof= (tcpip_t)); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Create the TCP header */ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tip->ip.src=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D htonl(pkt->ip_src_addr.addr.ipv4.s_add= r); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tip->ip.dst=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D htonl(pkt->ip_dst_addr.addr.ipv4.s_add= r); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tlen=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D pkt->= pktSize - =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 (pkt->ether_hdr_size + sizeof(ipHdr_t)); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tip->ip.len=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D htons(tlen); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tip->ip.proto=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 =3D pkt->ipProto; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tip->tcp.sport=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 =3D htons(pkt->sport); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tip->tcp.dport=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 =3D htons(pkt->dport); *tip->tcp.seq=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D htonl(DEFAULT= _PKT_NUMBER);* =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tip->tcp.ack=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 =3D htonl(DEFAULT_ACK_NUMBER); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tip->tcp.offset=C2=A0=C2=A0=C2= =A0=C2=A0 =3D ((sizeof(tcpHdr_t) / sizeof(uint32_t)) <<=20 4);=C2=A0=C2=A0=C2=A0=C2=A0 /* Offset in words */ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tip->tcp.flags=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 =3D=20 ACK_FLAG;=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 /* ACK */ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tip->tcp.window=C2=A0=C2=A0=C2= =A0=C2=A0 =3D htons(DEFAULT_WND_SIZE); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tip->tcp.urgent=C2=A0=C2=A0=C2= =A0=C2=A0 =3D 0; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tlen=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D pkt->= pktSize - pkt->ether_hdr_size; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tip->tcp.cksum=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 =3D cksum(tip, tlen, 0); } --=20 Thanks, Shailja