[dpdk-dev] How can I calculate/estimate pps(packet per seocond) and bps(bit per second) in DPDK pktg
Polehn, Mike A
mike.a.polehn at intel.com
Wed Nov 4 15:21:54 CET 2015
The change in tsc value from rte_rdtsc() needs to be multiplied by the scale to convert from clocks to get change in seconds.
For example from below:
elapse_us = (rte_rdtsc() - entry->tsc_first_packet) * flow_time_scale_us;
The bit rate requires the number of bytes passed in the time period then adjusted by the overhead of the number of packets transferred in the time period.
#define FLOWD_PERF_PACKET_OVERHEAD 24 /* CRC + Preamble + SOF + Interpacket gap */
Bits = (Bytes + (Packets*FLOWD_PERF_PACKET_OVERHEAD)) * 8;
Data_Rate = (((double)Bits) / Time_us) * 1e6;
Integer math is very tricky and often is not any faster than floating point math when using multiplies except on the very low performance processors.
Mike
From: 최익성 [mailto:pnk003 at naver.com]
Sent: Tuesday, November 3, 2015 5:45 PM
To: Polehn, Mike A; Wiles, Keith; Van Haaren, Harry; dev at dpdk.org
Subject: RE: [dpdk-dev] How can I calculate/estimate pps(packet per seocond) and bps(bit per second) in DPDK pktg
Dear Wiles, Keith , Van Haaren, Harry, Polehn, Mike A, Stephen Hemminger, Kyle Larose, and DPDK experts.
I really appreciate for your precious answers and advices.
I will find and study the corresponding codes and CRC checking.
Last night, I tried to estimate bps and pps by using the following code.
// rte_distributor_process() gets 64 mbufs packets at a time.
// rte_distributor_process() gets packets from Intel® 82599ES 10 Gigabit Ethernet 2 port Controller (2 10gbE ports).
int rte_distributor_process(struct rte_distributor *d, struct rte_mbuf **mbufs, unsigned num_mbufs)
{
uint64_t ticks_per_ms = rte_get_tsc_hz()/1000 ;
uint64_t ticks_per_s = rte_get_tsc_hz() ;
uint64_t ticks_per_s_div_8 = rte_get_tsc_hz()/8 ;
uint64_t cur_tsc = 0, last_tsc = 0, sum_len, bps, pps ;
cur_tsc = rte_rdtsc();
sum_len = 0 ;
for (l=0; l < num_mbufs; l++ ) { sum_len += mbufs[l]->pkt_len ; }
if ((cur_tsc - last_tsc)!=0) {
bps = (sum_len * ticks_per_s_div_8 ) / (cur_tsc - last_tsc) ;
pps = num_mbufs * ticks_per_s / (cur_tsc - last_tsc) ;
} else bps = pps = 0 ;
last_tsc = cur_tsc ;
}
I got max. bit per second = 6,835,440,833 for 20 Gbps 1500 bytes packet traffic, and got max. bit per second = 6,808,524,220 for 2 Gbps 1500 bytes packet traffic.
I guess there can be packet burst, however the estimated value has too many errors.
I will try the methods you proposed.
Thank you very much.
Sincerely Yours,
Ick-Sung Choi.
-----Original Message-----
From: "Polehn, Mike A"<mike.a.polehn at intel.com<mailto:mike.a.polehn at intel.com>>
To: "Wiles, Keith"<keith.wiles at intel.com<mailto:keith.wiles at intel.com>>; "Van Haaren, Harry"<harry.van.haaren at intel.com<mailto:harry.van.haaren at intel.com>>; "???"<pnk003 at naver.com<mailto:pnk003 at naver.com>>; "dev at dpdk.org<mailto:dev at dpdk.org>"<dev at dpdk.org<mailto:dev at dpdk.org>>;
Cc:
Sent: 2015-11-04 (수) 00:59:34
Subject: RE: [dpdk-dev] How can I calculate/estimate pps(packet per seocond) and bps(bit per second) in DPDK pktg
I used the following code snip-it with the i40e device, with 1 second sample time had very high accuracy for IPv4 UDP packets:
#define FLOWD_PERF_PACKET_OVERHEAD 24 /* CRC + Preamble + SOF + Interpacket gap */
#define FLOWD_REF_NETWORK_SPEED 10e9
double Ave_Bytes_per_Packet, Data_Rate, Net_Rate;
uint64_t Bits;
uint64_t Bytes = pFlow->flow.n_bytes - pMatch_Prev->flow.n_bytes;
uint64_t Packets = pFlow->flow.n_packets - pMatch_Prev->flow.n_packets;
uint64_t Time_us = pFlow->flow.flow_time_us - pMatch_Prev->flow.flow_time_us;
if (Bytes == 0)
Ave_Bytes_per_Packet = 0.0;
else
Ave_Bytes_per_Packet = ((double)Bytes / (double)Packets) + 4.0;
Bits = (Bytes + (Packets*FLOWD_PERF_PACKET_OVERHEAD)) * 8;
if (Bits == 0)
Data_Rate = 0.0;
else
Data_Rate = (((double)Bits) / Time_us) * 1e6;
if (Data_Rate == 0.0)
Net_Rate = 0.0;
else
Net_Rate = Data_Rate / FLOWD_REF_NETWORK_SPEED;
For packet rate: double pk_rate = (((double)Packets)/ ((double)Time_us)) * 1e6;
To calculate elapsed time in DPDK app, used CPU counter (will not work if counter is being modified):
Initialization:
double flow_time_scale_us;
...
flow_time_scale_us = 1e6/rte_get_tsc_hz();
Elapsed time (uSec) example:
elapse_us = (rte_rdtsc() - entry->tsc_first_packet) *
flow_time_scale_us; /* calc total elapsed us */
-----Original Message-----
From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Wiles, Keith
Sent: Tuesday, November 3, 2015 6:33 AM
To: Van Haaren, Harry; ???; dev at dpdk.org<mailto:dev at dpdk.org>
Subject: Re: [dpdk-dev] How can I calculate/estimate pps(packet per seocond) and bps(bit per second) in DPDK pktg
On 11/3/15, 8:30 AM, "Van Haaren, Harry" <harry.van.haaren at intel.com<mailto:harry.van.haaren at intel.com>> wrote:
>Hi Keith,
>
>> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Wiles, Keith
><snip>
>> Hmm, I just noticed I did not include the FCS bytes. Does the NIC
>> include FCS bytes in the counters? Need to verify that one and if not then it becomes a bit more complex.
>
>The Intel NICs count packet sizes inclusive of CRC / FCS, from eg the ixgbe/82599 datasheet:
>"This register includes bytes received in a packet from the <Destination Address> field through the <CRC> field, inclusively."
Thanks I assumed I had known that at the time :-)
>
>-Harry
>
Regards,
Keith
[http://mail.naver.com/readReceipt/notify/?img=b9KqKAIOWNISaAMrFomsaAtmF6uqpxUqFAICpAEXKrMXMxUqF430K6t9tzFXp6UmFLl5WLl51zlqDBFdp6d5MreRhoRR16R074u5bzenp6C5tz05%2Bzkn74FTWt%3D%3D.gif]
More information about the dev
mailing list