DPDK usage discussions
 help / color / mirror / Atom feed
From: Ravi Tandon <ravi.tandon1982@gmail.com>
To: "Wiles, Keith" <keith.wiles@intel.com>
Cc: "users@dpdk.org" <users@dpdk.org>
Subject: Re: [dpdk-users] Replicating PCAP packets read by pktgen for multiple source addresses
Date: Mon, 14 Sep 2020 19:52:25 +0200
Message-ID: <CAKDHAW_rkRFbQNKLt-VzR+KEapoD1orU0CSSarEnoeaDCmNQhA@mail.gmail.com> (raw)
In-Reply-To: <CAKDHAW8KXt8=-fEFkgLK9uitai2aqVs=Z5khOq=60FckL1w8Hw@mail.gmail.com>

Dear Keith,

After updating the refcnt value, I am able to transmit packet with multiple
source IPs but the transmission stops after some time, even if I give
start command again, transmission never starts, please let me know if I
missed something, basically I want transmission forever unless stop command
is triggered.

The updated code is as below, I added 3 lines having num_src_ip in them to
see whether my packets are transmitted burst x num_src_ip times, but
transmission stopped after sometime, and I am unable to start it
unless I restart pktgen

static __inline__ void
pktgen_send_burst(port_info_t *info, uint16_t qid)
{
struct mbuf_table   *mtab = &info->q[qid].tx_mbufs;
struct rte_mbuf **pkts;
struct qstats_s *qstats;
uint32_t ret, cnt, tap, rnd, tstamp, i;
int32_t seq_idx;
*uint32_t num_src_ip = 5; /*Hard coded for timebeing*/*

if ((cnt = mtab->len) == 0)
return;

mtab->len = 0;
pkts = mtab->m_table;

if (pktgen_tst_port_flags(info, SEND_RANGE_PKTS))
seq_idx = RANGE_PKT;
else if (pktgen_tst_port_flags(info, SEND_RATE_PACKETS))
seq_idx = RATE_PKT;
else
seq_idx = SINGLE_PKT;

tap = pktgen_tst_port_flags(info, PROCESS_TX_TAP_PKTS);
rnd = pktgen_tst_port_flags(info, SEND_RANDOM_PKTS);
tstamp = pktgen_tst_port_flags(info, (SEND_LATENCY_PKTS |
SEND_RATE_PACKETS));

qstats = &info->qstats[qid];
qstats->txpkts += cnt;
for (i = 0; i < cnt; i++) {
qstats->txbytes += rte_pktmbuf_data_len(pkts[i]);
*rte_mbuf_refcnt_update(pkts[i], num_src_ip);*
}

/* Send all of the packets before we can exit this function */
while (cnt) {
if (rnd)
pktgen_rnd_bits_apply(info, pkts, cnt, NULL);

if (tstamp)
pktgen_tstamp_apply(info, pkts, cnt, seq_idx);


*for(i = 0; i < num_src_ip; i++) *ret = rte_eth_tx_burst(info->pid, qid,
pkts, cnt);

if (tap)
pktgen_do_tx_tap(info, pkts, ret);

pkts += (ret);
cnt -= (ret);
}
}


Regards,
Ravi

On Mon, Sep 14, 2020 at 6:03 PM Ravi Tandon <ravi.tandon1982@gmail.com>
wrote:

> Thanks Keith.
>
> I updated the refcnt and it worked.
>
> Regards,
> Ravi
>
> On Mon, Sep 14, 2020 at 3:30 PM Wiles, Keith <keith.wiles@intel.com>
> wrote:
>
>> You can edit the packet in the function below, but you have to do that
>> action everytime. Freeing the mbuf I sok, you can look into the refcnt
>> value in the mbuf if you want tx_burst to not free the packet completely.
>>
>>
>>
>> *From: *users <users-bounces@dpdk.org>
>> *Date: *Sunday, September 13, 2020 at 5:00 PM
>> *To: *users@dpdk.org <users@dpdk.org>
>> *Subject: *[dpdk-users] Replicating PCAP packets read by pktgen for
>> multiple source addresses
>>
>> Hi,
>>
>> I want to use pktgen to read a pcap file and play that pcap file say 10
>> times by editing the source IP address for each run, please let me know
>> what's the best way of doing this.
>>
>> I first thought of editing the source IP in the rte_mbuf pointed by pkts
>> before calling the rte_eth_tx_burst(info->pid, qid, pkts, cnt) function
>> but
>> it seems that rte_eth_tx_burst function frees up the rte_mbuf pointed by
>> pkts after sending the packet once so I cannot edit the pkts buffer again.
>>
>>
>> static __inline__ void
>> trafficgen_send_burst(port_info_t *info, uint16_t qid)
>> {
>> struct mbuf_table   *mtab = &info->q[qid].tx_mbufs;
>> struct rte_mbuf **pkts;
>> struct qstats_s *qstats;
>> uint32_t ret, cnt, tap, rnd, tstamp, i;
>> int32_t seq_idx;
>>
>> if ((cnt = mtab->len) == 0)
>> return;
>>
>> mtab->len = 0;
>> pkts = mtab->m_table;
>>
>> if (trafficgen_tst_port_flags(info, SEND_RANGE_PKTS))
>> seq_idx = RANGE_PKT;
>> else if (trafficgen_tst_port_flags(info, SEND_RATE_PACKETS))
>> seq_idx = RATE_PKT;
>> else
>> seq_idx = SINGLE_PKT;
>>
>> tap = trafficgen_tst_port_flags(info, PROCESS_TX_TAP_PKTS);
>> rnd = trafficgen_tst_port_flags(info, SEND_RANDOM_PKTS);
>> tstamp = trafficgen_tst_port_flags(info, (SEND_LATENCY_PKTS |
>> SEND_RATE_PACKETS));
>>
>> qstats = &info->qstats[qid];
>> qstats->txpkts += cnt;
>> for (i = 0; i < cnt; i++)
>> qstats->txbytes += rte_pktmbuf_data_len(pkts[i]);
>>
>> */*Inserting a for loop here doesn't help as rte_mbuf is freed by
>> rte_eth_tx_burst*/*
>> /* Send all of the packets before we can exit this function */
>> while (cnt) {
>>
>> if (rnd)
>> trafficgen_rnd_bits_apply(info, pkts, cnt, NULL);
>>
>> if (tstamp)
>> trafficgen_tstamp_apply(info, pkts, cnt, seq_idx);
>>
>> ret = rte_eth_tx_burst(info->pid, qid, pkts, cnt);
>>
>> if (tap)
>> trafficgen_do_tx_tap(info, pkts, ret);
>>
>> pkts += ret;
>> cnt -= ret;
>> }
>> }
>>
>> Basically, I want to resend buffers stored in rte_mbuf again and again,
>> after modifying source IP in each run.
>>
>> Thanks
>> Ravi
>>
>

  reply	other threads:[~2020-09-14 17:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-13 21:59 Ravi Tandon
2020-09-14 13:30 ` Wiles, Keith
2020-09-14 16:03   ` Ravi Tandon
2020-09-14 17:52     ` Ravi Tandon [this message]
2020-09-14 21:19       ` Ravi Tandon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKDHAW_rkRFbQNKLt-VzR+KEapoD1orU0CSSarEnoeaDCmNQhA@mail.gmail.com \
    --to=ravi.tandon1982@gmail.com \
    --cc=keith.wiles@intel.com \
    --cc=users@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK usage discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/users/0 users/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 users users/ https://inbox.dpdk.org/users \
		users@dpdk.org
	public-inbox-index users

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.users


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git