Index: net/pkt-gen/Makefile =================================================================== --- /dev/null +++ net/pkt-gen/Makefile @@ -0,0 +1,31 @@ +# $FreeBSD$ + +PORTNAME= pkt-gen +PORTVERSION= 2017.08.06 +CATEGORIES= net + +MAINTAINER= shurd@freebsd.org +COMMENT= Packet sink/source using the netmap API + +LICENSE= BSD2CLAUSE + +USE_GITHUB= yes +GH_ACCOUNT= luigirizzo +GH_PROJECT= netmap +GH_TAGNAME= 3c3ab5faa2ab9c89db09cd8339d0e96a1a78c41a +USES= gmake +MAKEFILE= GNUmakefile +WRKSRC_SUBDIR= apps/pkt-gen/ + +OPTIONS_DEFINE= PCAP +PCAP_DESC= Support loading packets from pcap file +OPTIONS_DEFAULT=PCAP +PCAP_MAKE_ARGS= WITH_PCAP=1 + +PLIST_FILES= bin/pkt-gen + +do-install: + ${INSTALL_PROGRAM} ${WRKDIR}/${GH_PROJECT}-${GH_TAGNAME_EXTRACT}/apps/pkt-gen/pkt-gen \ + ${STAGEDIR}${PREFIX}/bin + +.include Index: net/pkt-gen/distinfo =================================================================== --- /dev/null +++ net/pkt-gen/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1503625986 +SHA256 (luigirizzo-netmap-2017.08.06-3c3ab5faa2ab9c89db09cd8339d0e96a1a78c41a_GH0.tar.gz) = 755f0b7d195cfdd7148591ef01ae4da569cae3e323ffded74dfbaa571dc267f3 +SIZE (luigirizzo-netmap-2017.08.06-3c3ab5faa2ab9c89db09cd8339d0e96a1a78c41a_GH0.tar.gz) = 544000 Index: net/pkt-gen/files/patch-apps_include_ctrs.h =================================================================== --- /dev/null +++ net/pkt-gen/files/patch-apps_include_ctrs.h @@ -0,0 +1,36 @@ +--- ../include/ctrs.h.orig 2017-08-06 18:26:36 UTC ++++ ../include/ctrs.h +@@ -16,21 +16,27 @@ struct my_ctrs { + * Caller has to make sure that the buffer is large enough. + */ + static const char * +-norm2(char *buf, double val, char *fmt) ++norm2(char *buf, double val, char *fmt, int normalize) + { + char *units[] = { "", "K", "M", "G", "T" }; + u_int i; +- +- for (i = 0; val >=1000 && i < sizeof(units)/sizeof(char *) - 1; i++) +- val /= 1000; ++ if (normalize) ++ for (i = 0; val >=1000 && i < sizeof(units)/sizeof(char *) - 1; i++) ++ val /= 1000; ++ else ++ i=0; + sprintf(buf, fmt, val, units[i]); + return buf; + } + + static __inline const char * +-norm(char *buf, double val) ++norm(char *buf, double val, int normalize) + { +- return norm2(buf, val, "%.3f %s"); ++ ++ if (normalize) ++ return norm2(buf, val, "%.3f %s", normalize); ++ else ++ return norm2(buf, val, "%.0f %s", normalize); + } + + static __inline int Index: net/pkt-gen/files/patch-apps_pkt-gen_pkt-gen.c =================================================================== --- /dev/null +++ net/pkt-gen/files/patch-apps_pkt-gen_pkt-gen.c @@ -0,0 +1,57 @@ +--- pkt-gen.c.orig 2017-08-06 18:26:36 UTC ++++ pkt-gen.c +@@ -186,6 +186,7 @@ const char *indirect_payload="netmap pkt + "http://info.iet.unipi.it/~luigi/netmap/ "; + + int verbose = 0; ++int normalize = 1; + + #define VIRT_HDR_1 10 /* length of a base vnet-hdr */ + #define VIRT_HDR_2 12 /* length of the extenede vnet-hdr */ +@@ -2209,7 +2210,7 @@ tx_output(struct my_ctrs *cur, double de + abs = cur->pkts / (double)(cur->events); + + printf("Speed: %spps Bandwidth: %sbps (raw %sbps). Average batch: %.2f pkts\n", +- norm(b1, pps), norm(b2, bw), norm(b3, raw_bw), abs); ++ norm(b1, pps, normalize), norm(b2, bw, normalize), norm(b3, raw_bw, normalize), abs); + } + + static void +@@ -2405,13 +2406,13 @@ main_thread(struct glob_arg *g) + ppsdev = sqrt(ppsdev); + + snprintf(b4, sizeof(b4), "[avg/std %s/%s pps]", +- norm(b1, ppsavg), norm(b2, ppsdev)); ++ norm(b1, ppsavg, normalize), norm(b2, ppsdev, normalize)); + } + + D("%spps %s(%spkts %sbps in %llu usec) %.2f avg_batch %d min_space", +- norm(b1, pps), b4, +- norm(b2, (double)x.pkts), +- norm(b3, (double)x.bytes*8), ++ norm(b1, pps, normalize), b4, ++ norm(b2, (double)x.pkts, normalize), ++ norm(b3, (double)x.bytes*8, normalize), + (unsigned long long)usec, + abs, (int)cur.min_space); + prev = cur; +@@ -2589,7 +2590,7 @@ main(int arc, char **argv) + g.virt_header = 0; + g.wait_link = 2; + +- while ((ch = getopt(arc, argv, "46a:f:F:n:i:Il:d:s:D:S:b:c:o:p:" ++ while ((ch = getopt(arc, argv, "46a:f:F:Nn:i:Il:d:s:D:S:b:c:o:p:" + "T:w:WvR:XC:H:e:E:m:rP:zZA")) != -1) { + + switch(ch) { +@@ -2606,6 +2607,10 @@ main(int arc, char **argv) + g.af = AF_INET6; + break; + ++ case 'N': ++ normalize = 0; ++ break; ++ + case 'n': + g.npackets = strtoull(optarg, NULL, 10); + break; Index: net/pkt-gen/pkg-descr =================================================================== --- /dev/null +++ net/pkt-gen/pkg-descr @@ -0,0 +1 @@ +A packet sink/source using the netmap API