From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <keith.wiles@intel.com>
Received: from mga01.intel.com (mga01.intel.com [192.55.52.88])
 by dpdk.org (Postfix) with ESMTP id 86F381B225
 for <dev@dpdk.org>; Mon,  9 Oct 2017 19:12:48 +0200 (CEST)
Received: from fmsmga006.fm.intel.com ([10.253.24.20])
 by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 09 Oct 2017 10:12:47 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.42,501,1500966000"; d="scan'208";a="161107762"
Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205])
 by fmsmga006.fm.intel.com with ESMTP; 09 Oct 2017 10:12:47 -0700
Received: from fmsmsx101.amr.corp.intel.com (10.18.124.199) by
 fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS)
 id 14.3.319.2; Mon, 9 Oct 2017 10:12:47 -0700
Received: from fmsmsx102.amr.corp.intel.com ([169.254.10.122]) by
 fmsmsx101.amr.corp.intel.com ([169.254.1.172]) with mapi id 14.03.0319.002;
 Mon, 9 Oct 2017 10:12:46 -0700
From: "Wiles, Keith" <keith.wiles@intel.com>
To: Shailja Pandey <csz168117@iitd.ac.in>
CC: "dev@dpdk.org" <dev@dpdk.org>
Thread-Topic: [dpdk-dev] How to update the sequence number in TCP packets
 using	DPDK-pktgen?
Thread-Index: AQHTQQSaTyal7/PnuECNKbdGHs9r9aLcNvWA
Date: Mon, 9 Oct 2017 17:12:45 +0000
Message-ID: <99AABA1F-637E-45FA-8F38-3688749B048D@intel.com>
References: <c8dde074-7192-e7dd-b8b8-857f370e4649@iitd.ac.in>
In-Reply-To: <c8dde074-7192-e7dd-b8b8-857f370e4649@iitd.ac.in>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [10.254.126.92]
Content-Type: text/plain; charset="us-ascii"
Content-ID: <3B9ECA9890FF204FBF0794F95ADD3850@intel.com>
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Subject: Re: [dpdk-dev] How to update the sequence number in TCP packets
 using	DPDK-pktgen?
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Mon, 09 Oct 2017 17:12:48 -0000



> On Oct 9, 2017, at 8:42 AM, Shailja Pandey <csz168117@iitd.ac.in> wrote:
>=20
> Hi,
>=20
> In the DPDK application, I am maintaining some state and due to that I ne=
ed to generate the packets with monotonically increasing sequence numbers. =
As shown in the code below,
>=20
> /tip->tcp.seq        =3D htonl(DEFAULT_PKT_NUMBER);/
>=20
> DPDK is putting some default number as a sequence number in the TCP packe=
t and not using as defined by TCP protocol. I tried various workarounds but=
 due to multi-threaded nature of the pktgen application, I am facing some i=
ssues and unable to put sequence numbers in increasing order. I tried threa=
d_local and pthread_mutex_lock etc to generate packets with increasing sequ=
ence number.
>=20
> I am not very sure what am I missing, Please help me in this matter.

The way pktgen was written was for performance, which means I setup the mbu=
fs at start time and do not touch them again till another start command. Th=
is causes packets to be sent out of order as I do not know when mbufs are r=
eturned to the free pool.

The only way to send a given sequence is to modified each packet as it is s=
ent, which will impact performance. The random mode does just this type of =
packet mods and it would be a good model to look at if you want to modify t=
he code.

>=20
> _Function:_
>=20
> void
> pktgen_tcp_hdr_ctor(pkt_seq_t *pkt, tcpip_t *tip, int type __rte_unused)
> {
>         uint16_t tlen;
>=20
>         /* Zero out the header space */
>         memset((char *)tip, 0, sizeof(tcpip_t));
>=20
>         /* Create the TCP header */
>         tip->ip.src         =3D htonl(pkt->ip_src_addr.addr.ipv4.s_addr);
>         tip->ip.dst         =3D htonl(pkt->ip_dst_addr.addr.ipv4.s_addr);
>         tlen                =3D pkt->pktSize -
>                 (pkt->ether_hdr_size + sizeof(ipHdr_t));
>=20
>         tip->ip.len         =3D htons(tlen);
>         tip->ip.proto       =3D pkt->ipProto;
>=20
>         tip->tcp.sport      =3D htons(pkt->sport);
>         tip->tcp.dport      =3D htons(pkt->dport);
>=20
> *tip->tcp.seq        =3D htonl(DEFAULT_PKT_NUMBER);*
>=20
>         tip->tcp.ack        =3D htonl(DEFAULT_ACK_NUMBER);
>         tip->tcp.offset     =3D ((sizeof(tcpHdr_t) / sizeof(uint32_t)) <<=
 4);     /* Offset in words */
>         tip->tcp.flags      =3D ACK_FLAG;                                =
         /* ACK */
>         tip->tcp.window     =3D htons(DEFAULT_WND_SIZE);
>         tip->tcp.urgent     =3D 0;
>=20
>         tlen                =3D pkt->pktSize - pkt->ether_hdr_size;
>=20
>         tip->tcp.cksum      =3D cksum(tip, tlen, 0);
> }
>=20
> --=20
>=20
> Thanks,
> Shailja
>=20

Regards,
Keith