Skip to content

Commit 77688d3

Browse files
committed
update version to 26.02.1 and fix PCAP rate calculation to use average packet size
Signed-off-by: Keith Wiles <keith.wiles@intel.com>
1 parent fa66480 commit 77688d3

File tree

6 files changed

+30
-14
lines changed

6 files changed

+30
-14
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
26.02.0
1+
26.02.1

app/pktgen-pcap.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ pcap_get_info(pcap_info_t *pcap)
8282
pcap->info.network = ntohl(pcap->info.network);
8383
}
8484

85-
pcap->max_pkt_size = 0;
85+
pcap->max_pkt_size = 0;
86+
pcap->avg_pkt_size = 0;
87+
uint64_t total_size = 0;
8688
/* count the number of packets and get the largest size packet */
8789
for (;;) {
8890
if (fread(&hdr, 1, sizeof(pcap_record_hdr_t), pcap->fp) != sizeof(hdr))
@@ -97,9 +99,15 @@ pcap_get_info(pcap_info_t *pcap)
9799
pcap->pkt_count++;
98100
if (hdr.incl_len > pcap->max_pkt_size)
99101
pcap->max_pkt_size = hdr.incl_len;
102+
103+
total_size += hdr.incl_len;
100104
}
101105
printf("PCAP: Max Packet Size: %d\n", pcap->max_pkt_size);
102106

107+
pcap->avg_pkt_size = total_size / pcap->pkt_count;
108+
109+
printf("PCAP: Avg Packet Size: %d\n", pcap->avg_pkt_size);
110+
103111
pcap_rewind(pcap);
104112
}
105113

app/pktgen-pcap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ typedef struct pcap_info_s {
4141
struct rte_mempool *mp; /**< Mempool for storing packets */
4242
uint32_t convert; /**< Endian flag value if 1 convert to host endian format */
4343
uint32_t max_pkt_size; /**< largest packet found in pcap file */
44+
uint32_t avg_pkt_size; /**< average packet size in pcap file */
4445
uint32_t pkt_count; /**< Number of packets in pcap file */
4546
uint32_t pkt_index; /**< Index of current packet in pcap file */
4647
pcap_hdr_t info; /**< information on the PCAP file */

app/pktgen.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pktgen_wire_size(port_info_t *pinfo)
6464
if (pktgen_tst_port_flags(pinfo, SEND_PCAP_PKTS)) {
6565
pcap_info_t *pcap = l2p_get_pcap(pinfo->pid);
6666

67-
size = WIRE_SIZE(pcap->max_pkt_size, uint64_t);
67+
size = WIRE_SIZE(pcap->avg_pkt_size, uint64_t);
6868
} else {
6969
if (unlikely(pinfo->seqCnt > 0)) {
7070
for (i = 0; i < pinfo->seqCnt; i++)
@@ -111,11 +111,10 @@ pktgen_packet_rate(port_info_t *port)
111111
pps = (((link_speed / pktgen_wire_size(port)) * (port->tx_rate / txcnt)) / 100);
112112
pps = ((pps > 0) ? pps : 1);
113113

114-
// cycles per burst is hz divided by pps times burst count
115-
cpb = (rte_get_timer_hz() / pps) * (uint64_t)port->tx_burst; /* Cycles per Burst */
116-
117-
// divide up the work between the number of transmit queues, so multiple by queue count.
118-
port->tx_cycles = cpb * (uint64_t)txcnt;
114+
// Do all multiplications first to reduce rounding errors.
115+
// Add pps/2 to do rounding instead of truncation.
116+
cpb = (pps / 2 + (uint64_t)txcnt * port->tx_burst * rte_get_timer_hz()) / pps;
117+
port->tx_cycles = cpb;
119118
port->tx_pps = pps;
120119
}
121120

@@ -1070,9 +1069,11 @@ pktgen_main_rxtx_loop(void)
10701069
curr_tsc = pktgen_get_time();
10711070

10721071
/* Determine when is the next time to send packets */
1073-
if (curr_tsc >= tx_next_cycle) {
1074-
tx_next_cycle = curr_tsc + pinfo->tx_cycles;
1075-
1072+
const int64_t max_tx_lag =
1073+
DEFAULT_MAX_TX_LAG; // Allow some lag, ideally make this configurable.
1074+
int64_t dt = curr_tsc - tx_next_cycle;
1075+
if (dt >= 0) {
1076+
tx_next_cycle = curr_tsc + pinfo->tx_cycles - (dt <= max_tx_lag ? dt : 0);
10761077
// Process TX
10771078
pktgen_main_transmit(pinfo, tx_qid);
10781079
}
@@ -1124,8 +1125,11 @@ pktgen_main_tx_loop(void)
11241125
curr_tsc = pktgen_get_time();
11251126

11261127
/* Determine when is the next time to send packets */
1127-
if (unlikely(curr_tsc >= tx_next_cycle)) {
1128-
tx_next_cycle = curr_tsc + pinfo->tx_cycles;
1128+
const int64_t max_tx_lag =
1129+
DEFAULT_MAX_TX_LAG; // Allow some lag, ideally make this configurable.
1130+
int64_t dt = curr_tsc - tx_next_cycle;
1131+
if (dt >= 0) {
1132+
tx_next_cycle = curr_tsc + pinfo->tx_cycles - (dt <= max_tx_lag ? dt : 0);
11291133

11301134
// Process TX
11311135
pktgen_main_transmit(pinfo, tx_qid);

app/pktgen.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ enum {
167167
COLUMN_WIDTH_1 = 24,
168168
COLUMN_WIDTH_3 = 24,
169169

170+
DEFAULT_MAX_TX_LAG = 20000, /* Allow some lag, ideally make this configurable. */
171+
170172
/* Row locations for start of data */
171173
PAGE_TITLE_ROWS = 1,
172174
PORT_FLAGS_ROWS = 1,

changelog.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Pktgen-DPDK - Traffic Generator powered by DPDK
66
** (Pktgen) Sounds like 'Packet-Gen'**
77

88
**=== Modifications ===**
9-
- 26.02.3 - Add better cli-autocomplete support
9+
- 26.02.1 - Fix PCAP rate issues not using the average size packet.
10+
- 26.02.0 - Add better cli-autocomplete support
1011
- 25.08.2 - Fix race condition in CLI.
1112
- 25.08.1 - Fix DPDK 25.11 ethdev queue changes
1213
Fix running multiple Tx queues and stats are reported incorrectly.

0 commit comments

Comments
 (0)