{"id":183692,"date":"2013-06-18T12:07:03","date_gmt":"2013-06-18T08:07:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=183692"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=183692","title":{"rendered":"<span class=\"post_title\">TCP(syn-flood)-netmap-generator \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e 1,5 mpps<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t<b>\u0414\u0430\u043d\u043e:<\/b>  <\/p>\n<pre><code class=\"bash\"># pciconf -lv | grep -i device | grep -i network     device     = I350 Gigabit Network Connection # dmesg | grep CPU:     CPU: Intel(R) Core(TM)2 Duo CPU     E7300  @ 2.66GHz (2666.69-MHz K8-class CPU) # uname -orp     FreeBSD 9.1-RELEASE amd64 <\/code><\/pre>\n<p>  <b>\u0417\u0430\u0434\u0430\u0447\u0430: <\/b><br \/>  \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u0438 \u041e\u0421 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0430\u0433\u0440\u0443\u0437\u043e\u0447\u043d\u0443\u044e \u0432\u0438\u043b\u043a\u0443 \u0432 \u0432\u0438\u0434\u0435 tcp(syn)-\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 500kpps.<\/p>\n<p>  <b>\u0420\u0435\u0448\u0435\u043d\u0438\u0435:<\/b><br \/>  <a name=\"habracut\"><\/a><br \/>  \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u0438 \u0431\u044b\u043b\u0430 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u044f\u0442\u0430 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"http:\/\/www.hping.org\/\">hping<\/a>.<br \/>  \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 tcl. \u041f\u0438\u0448\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442:<\/p>\n<pre><code>while {1} {   hping send &quot;ip(saddr=10.0.0.1,daddr=10.0.0.2)+tcp(sport=14000,dport=80,flags=s)&quot;   } <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:  <\/p>\n<pre><code class=\"bash\"># hping exec .\/synflood1.htcl <\/code><\/pre>\n<p>  \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c:  <\/p>\n<pre><code class=\"bash\"># netstat -w1 -I igb0             input         (igb0)           output    packets  errs idrops      bytes    packets  errs      bytes colls      21384     0     0    1283040      21582     0    1165428     0      21264     0     0    1275840      21464     0    1159056     0      21361     0     0    1281660      21559     0    1164186     0 <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0435 10 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0441\u043c\u043e\u0433\u043b\u0438 \u00ab\u0440\u0430\u0441\u043a\u0430\u0447\u0430\u0442\u044c\u00bb \u0434\u043e 55kpps, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0431\u0430 \u044f\u0434\u0440\u0430 \u0431\u044b\u043b\u0438 \u0443\u0442\u0438\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b.  <\/p>\n<pre><code class=\"bash\"># top -PSCH last pid:  1691;  load averages: 10.02,  6.83,  3.32                        up 0+00:59:11  12:31:18 125 processes: 13 running, 86 sleeping, 26 waiting CPU 0: 77.2% user,  0.0% nice, 17.1% system,  5.7% interrupt,  0.0% idle CPU 1: 76.4% user,  0.0% nice, 10.6% system, 13.0% interrupt,  0.0% idle <\/code><\/pre>\n<p>  \u0422\u044e\u043d\u0438\u043d\u0433 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b \u0435\u0449\u0451 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0440\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043d\u043e \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0435 \u0446\u0438\u0444\u0440\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438\u0441\u044c \u043d\u0430 ~125kpps.<\/p>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a <a href=\"http:\/\/info.iet.unipi.it\/~luigi\/netmap\/\">netmap<\/a> \u043e\u0442 Luigi Rizzo \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0430\u0444\u0438\u0448\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u0432 \u043e\u0431\u0437\u043e\u0440\u0430\u0445 9-\u043a\u0438, \u043d\u043e \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0435\u0433\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0440\u0443\u043d\u0435\u0442\u0435 \u044f \u043d\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b. <br \/>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0440\u0430\u0442\u044c \u044f\u0434\u0440\u043e \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c:  <\/p>\n<pre><code class=\"bash\">device netmap <\/code><\/pre>\n<p>  \u0417\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0432\u0437\u044f\u0442 \u043a\u043e\u0434 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432 \u043e\u0442 \u0441\u0430\u043c\u043e\u0433\u043e \u0430\u0432\u0442\u043e\u0440\u0430 \u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0432 \u043e\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f tcp-\u043f\u0430\u043a\u0435\u0442\u0430. \u041f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u0439, \u0431\u0435\u0437 \u043a\u0443\u043f\u044e\u0440.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">tcp-gen.c<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">\/*  * \u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0433\u043e  * tcp-\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 netmap  *\/  const char *default_payload = \t&quot;netmap pkt-gen Luigi Rizzo and Matteo Landi\\n&quot; &quot;http:\/\/info.iet.unipi.it\/~luigi\/netmap\/ &quot;;  #include &lt;pthread.h&gt;\t\/* pthread_* *\/ #include &lt;pthread_np.h&gt;\t\/* pthread w\/ affinity *\/ #include &lt;stdlib.h&gt; #include &lt;stdio.h&gt; #include &lt;inttypes.h&gt;\t\/* PRI* macros *\/ #include &lt;string.h&gt;\t\/* strcmp *\/ #include &lt;fcntl.h&gt;\t\/* open *\/ #include &lt;unistd.h&gt;\t\/* close *\/ #include &lt;ifaddrs.h&gt;\t\/* getifaddrs *\/  #include &lt;sys\/mman.h&gt;\t\/* PROT_* *\/ #include &lt;sys\/ioctl.h&gt;\t\/* ioctl *\/ #include &lt;sys\/poll.h&gt; #include &lt;arpa\/inet.h&gt;\t\/* ntohs *\/ #include &lt;sys\/sysctl.h&gt;\t\/* sysctl *\/  #include &lt;net\/ethernet.h&gt; #include &lt;net\/if.h&gt;\t\/* ifreq *\/ #include &lt;net\/if_dl.h&gt;\t\/* LLADDR *\/  #include &lt;netinet\/in.h&gt; #include &lt;netinet\/ip.h&gt; #include &lt;netinet\/tcp.h&gt;  #include &lt;net\/netmap.h&gt; #include &lt;net\/netmap_user.h&gt;  static inline int min(int a, int b) { \treturn a &lt; b ? a : b; }  \/* debug support *\/ #define D(format, ...)\t\t\t\t\\ \tfprintf(stderr, &quot;%s [%d] &quot; format &quot;\\n&quot;, \t\\ \t__FUNCTION__, __LINE__, ##__VA_ARGS__)  #ifndef EXPERIMENTAL #define EXPERIMENTAL 0 #endif  #define MAX_QUEUES 64\t\/* no need to limit *\/  #define SKIP_PAYLOAD 1 \/* do not check payload. *\/  inline void prefetch(const void *x) { \t__asm volatile(&quot;prefetcht0 %0&quot; :: &quot;m&quot;(*(const unsigned long *)x)); }  \/*  * sum_w()  *  * Do the one's complement sum thing over a range of words  * Ideally, this should get replaced by an assembly version.  *\/  static u_int32_t \t\/* static inline u_int32_t *\/ \tsum_w(u_int16_t *buf, int nwords) { \tregister u_int32_t sum = 0;  \twhile (nwords &gt;= 16) { \t\tsum += (u_int16_t) ntohs(*buf++); \t\tsum += (u_int16_t) ntohs(*buf++); \t\tsum += (u_int16_t) ntohs(*buf++); \t\tsum += (u_int16_t) ntohs(*buf++); \t\tsum += (u_int16_t) ntohs(*buf++); \t\tsum += (u_int16_t) ntohs(*buf++); \t\tsum += (u_int16_t) ntohs(*buf++); \t\tsum += (u_int16_t) ntohs(*buf++); \t\tsum += (u_int16_t) ntohs(*buf++); \t\tsum += (u_int16_t) ntohs(*buf++); \t\tsum += (u_int16_t) ntohs(*buf++); \t\tsum += (u_int16_t) ntohs(*buf++); \t\tsum += (u_int16_t) ntohs(*buf++); \t\tsum += (u_int16_t) ntohs(*buf++); \t\tsum += (u_int16_t) ntohs(*buf++); \t\tsum += (u_int16_t) ntohs(*buf++); \t\tnwords -= 16; \t} \twhile (nwords--) \t\tsum += (u_int16_t) ntohs(*buf++); \treturn (sum); }  int tcp_csum(struct ip *ip, struct tcphdr * const tcp) { \t\/\/ struct tcphdr\t*const tcp = (struct tcphdr *) ((long *) ip + ip-&gt;ip_hl); \tu_int32_t sum; \tint tcp_len;  \t\/* Calculate total length of the TCP segment *\/  \ttcp_len = (u_int16_t) ntohs(ip-&gt;ip_len) - (ip-&gt;ip_hl &lt;&lt; 2);  \t\/* Do pseudo-header first *\/  \tsum = sum_w((u_int16_t*)&ip-&gt;ip_src, 4);  \tsum += (u_int16_t) IPPROTO_TCP; \tsum += (u_int16_t) tcp_len;  \t\/* Sum up tcp part *\/  \tsum += sum_w((u_int16_t*) tcp, tcp_len &gt;&gt; 1); \tif (tcp_len & 1) \t\tsum += (u_int16_t)(((u_char *) tcp)[tcp_len - 1] &lt;&lt; 8);  \t\/* Flip it & stick it *\/  \tsum = (sum &gt;&gt; 16) + (sum & 0xFFFF); \tsum += (sum &gt;&gt; 16); \tsum = ~sum;  \ttcp-&gt;th_sum = htons(sum);  \treturn tcp-&gt;th_sum; }  \/\/ XXX only for multiples of 32 bytes, non overlapped. static inline void pkt_copy(void *_src, void *_dst, int l) { \tuint64_t *src = _src; \tuint64_t *dst = _dst; #define likely(x)       __builtin_expect(!!(x), 1) #define unlikely(x)       __builtin_expect(!!(x), 0) \tif (unlikely(l &gt;= 1024)) { \t\tbcopy(src, dst, l); \t\treturn; \t} \tfor (; l &gt; 0; l -= 64) { \t\t*dst++ = *src++; \t\t*dst++ = *src++; \t\t*dst++ = *src++; \t\t*dst++ = *src++; \t\t*dst++ = *src++; \t\t*dst++ = *src++; \t\t*dst++ = *src++; \t\t*dst++ = *src++; \t} }  struct pkt { \tstruct ether_header eh; \tstruct ip ip;  \tstruct tcphdr tcp;  \tuint8_t body[2048]; \/\/ XXX hardwired } __attribute__((__packed__));  \/*  * global arguments for all threads  *\/ struct glob_arg { \tconst char *src_ip; \tconst char *dst_ip; \tconst char *src_mac; \tconst char *dst_mac; \tint pkt_size; \tint burst; \tint nthreads; \tint cpus; };  struct mystat { \tuint64_t containers[8]; };  \/*  * Arguments for a new thread. The same structure is used by  * the source and the sink  *\/ struct targ { \tstruct glob_arg *g; \tint used; \tint completed; \tint fd; \tstruct nmreq nmr; \tstruct netmap_if *nifp; \tuint16_t qfirst, qlast; \/* range of queues to scan *\/ \tuint64_t count; \tstruct timeval tic, toc; \tint me; \tpthread_t thread; \tint affinity;  \tuint8_t dst_mac[6]; \tuint8_t src_mac[6]; \tu_int dst_mac_range; \tu_int src_mac_range; \tuint32_t dst_ip; \tuint32_t src_ip; \tu_int dst_ip_range; \tu_int src_ip_range;  \tstruct pkt pkt; };  static struct targ *targs; static int global_nthreads;  \/* control-C handler *\/ static void sigint_h(__unused int sig) { \tfor (int i = 0; i &lt; global_nthreads; i++) { \t\t\/* cancel active threads. *\/ \t\tif (targs[i].used == 0) \t\t\tcontinue;  \t\tD(&quot;Cancelling thread #%d\\n&quot;, i); \t\tpthread_cancel(targs[i].thread); \t\ttargs[i].used = 0; \t}  \tsignal(SIGINT, SIG_DFL); }  \/* sysctl wrapper to return the number of active CPUs *\/ static int system_ncpus(void) { \tint mib[2], ncpus; \tsize_t len;  \tmib[0] = CTL_HW; \tmib[1] = HW_NCPU; \tlen = sizeof(mib); \tsysctl(mib, 2, &ncpus, &len, NULL, 0);  \treturn (ncpus); }  \/*  * locate the src mac address for our interface, put it  * into the user-supplied buffer. return 0 if ok, -1 on error.  *\/ static int source_hwaddr(const char *ifname, char *buf) { \tstruct ifaddrs *ifaphead, *ifap; \tint l = sizeof(ifap-&gt;ifa_name);  \tif (getifaddrs(&ifaphead) != 0) { \t\tD(&quot;getifaddrs %s failed&quot;, ifname); \t\treturn (-1); \t}  \tfor (ifap = ifaphead; ifap; ifap = ifap-&gt;ifa_next) { \t\tstruct sockaddr_dl *sdl = (struct sockaddr_dl*)ifap-&gt;ifa_addr; \t\tuint8_t *mac;  \t\tif (!sdl || sdl-&gt;sdl_family != AF_LINK) \t\t\tcontinue; \t\tif (strncmp(ifap-&gt;ifa_name, ifname, l) != 0) \t\t\tcontinue; \t\tmac = (uint8_t*)LLADDR(sdl); \t\tsprintf(buf, &quot;%02x:%02x:%02x:%02x:%02x:%02x&quot;, mac[0], mac[1], mac[2], \t\t\tmac[3], mac[4], mac[5]); \t\tbreak; \t} \tfreeifaddrs(ifaphead); \treturn ifap ? 0 : 1; }  \/* set the thread affinity. *\/ static int setaffinity(pthread_t me, int i) { \tcpuset_t cpumask;  \tif (i == -1) \t\treturn 0;  \t\/* Set thread affinity affinity. *\/ \tCPU_ZERO(&cpumask); \tCPU_SET(i, &cpumask);  \tif (pthread_setaffinity_np(me, sizeof(cpuset_t), &cpumask) != 0) { \t\tD(&quot;Unable to set affinity&quot;); \t\treturn 1; \t} \treturn 0; }  \/* Compute the checksum of the given ip header. *\/ static uint16_t checksum(const void *data, uint16_t len) { \tconst uint8_t *addr = data; \tuint32_t sum = 0;  \twhile (len &gt; 1) { \t\tsum += addr[0] * 256 + addr[1]; \t\taddr += 2; \t\tlen -= 2; \t}  \tif (len == 1) \t\tsum += *addr * 256;  \tsum = (sum &gt;&gt; 16) + (sum & 0xffff); \tsum += (sum &gt;&gt; 16);  \tsum = htons(sum);  \treturn ~sum; }  \/*  * Fill a packet with some payload.  *\/ static void initialize_packet(struct targ *targ) { \tstruct pkt *pkt = &targ-&gt;pkt; \tstruct ether_header *eh; \tstruct ip *ip; \tstruct tcphdr *tcp; \t\/\/ uint16_t paylen = targ-&gt;g-&gt;pkt_size - sizeof(*eh) - sizeof(*ip); \tuint16_t paylen = targ-&gt;g-&gt;pkt_size -sizeof(*eh)-sizeof(*ip); \tint i, l, l0 = strlen(default_payload); \tchar *p;  \tfor (i = 0; i &lt; paylen;) { \t\tl = min(l0, paylen - i); \t\tbcopy(default_payload, pkt-&gt;body + i, l); \t\ti += l; \t} \tpkt-&gt;body[i - 1] = '\\0';  \ttcp = &pkt-&gt;tcp;  \ttcp-&gt;th_sport = htons(14000); \/\/ Contains the source port. \ttcp-&gt;th_dport = htons(80); \/\/ Contains the destination port. \ttcp-&gt;th_seq = ntohl(rand()); \/\/ Contains the sequence number. \ttcp-&gt;th_ack = rand(); \/\/ Contains the acknowledgement number. \ttcp-&gt;th_x2 = 0; \/\/ Unused. \ttcp-&gt;th_off = 5; \/\/ Contains the data offset.  \ttcp-&gt;th_flags = TH_SYN; \/\/ Contains one of the following values: \t\/* \t Flag \tValue \tDescription \t TH_FIN \t0x01\tIndicates that the transmission is finishing. \t TH_SYN\t0x02\tIndicates that sequence numbers are being synchronized. \t TH_RST\t0x04\tIndicates that the connection is being reset. \t TH_PUSH\t0x08\tIndicataes that data is being pushed to the application level. \t TH_ACK\t0x10\tIndicates that the acknowledge field is valid. \t TH_URG\t0x20\tIndicates that urgent data is present. \t *\/ \ttcp-&gt;th_win = htons(512); \/\/ Contains the window size. \t\/\/ tcp-&gt;th_sum = 0; \t\t\/\/ Contains the checksum. \ttcp-&gt;th_urp = 0; \/\/ Contains the urgent pointer.  \tip = &pkt-&gt;ip; \tip-&gt;ip_v = 4; \tip-&gt;ip_hl = 5; \tip-&gt;ip_id = 0; \tip-&gt;ip_tos = IPTOS_LOWDELAY; \tip-&gt;ip_len = ntohs(sizeof(struct ip)+sizeof(struct tcphdr)); \tip-&gt;ip_off = htons(IP_DF); \/* Don't fragment *\/ \tip-&gt;ip_ttl = IPDEFTTL; \t\/\/ ip-&gt;ip_ttl = 255; \tip-&gt;ip_p = IPPROTO_TCP; \tinet_aton(targ-&gt;g-&gt;src_ip, (struct in_addr *)&ip-&gt;ip_src); \tinet_aton(targ-&gt;g-&gt;dst_ip, (struct in_addr *)&ip-&gt;ip_dst); \ttarg-&gt;dst_ip = ip-&gt;ip_dst.s_addr; \ttarg-&gt;src_ip = ip-&gt;ip_src.s_addr; \tp = index(targ-&gt;g-&gt;src_ip, '-'); \tif (p) { \t\ttarg-&gt;dst_ip_range = atoi(p + 1); \t\tD(&quot;dst-ip sweep %d addresses&quot;, targ-&gt;dst_ip_range); \t} \tip-&gt;ip_sum = checksum(ip, sizeof(*ip)); \ttcp-&gt;th_sum = tcp_csum(ip, tcp);  \teh = &pkt-&gt;eh; \tbcopy(ether_aton(targ-&gt;g-&gt;src_mac), targ-&gt;src_mac, 6); \tbcopy(targ-&gt;src_mac, eh-&gt;ether_shost, 6); \tp = index(targ-&gt;g-&gt;src_mac, '-'); \tif (p) \t\ttarg-&gt;src_mac_range = atoi(p + 1);  \tbcopy(ether_aton(targ-&gt;g-&gt;dst_mac), targ-&gt;dst_mac, 6); \tbcopy(targ-&gt;dst_mac, eh-&gt;ether_dhost, 6); \tp = index(targ-&gt;g-&gt;dst_mac, '-'); \tif (p) \t\ttarg-&gt;dst_mac_range = atoi(p + 1); \teh-&gt;ether_type = htons(ETHERTYPE_IP);  }  \/*  * create and enqueue a batch of packets on a ring.  * On the last one set NS_REPORT to tell the driver to generate  * an interrupt when done.  *\/ static int send_packets(struct netmap_ring *ring, struct pkt *pkt, int size, \tu_int count) { \tu_int sent, cur = ring-&gt;cur;  \tif (ring-&gt;avail &lt; count) \t\tcount = ring-&gt;avail;  \tfor (sent = 0; sent &lt; count; sent++) { \t\tstruct netmap_slot *slot = &ring-&gt;slot[cur]; \t\tchar *p = NETMAP_BUF(ring, slot-&gt;buf_idx);  \t\tpkt_copy(pkt, p, size);  \t\tslot-&gt;len = size; \t\tif (sent == count - 1) \t\t\tslot-&gt;flags |= NS_REPORT; \t\tcur = NETMAP_RING_NEXT(ring, cur); \t} \tring-&gt;avail -= sent; \tring-&gt;cur = cur;  \treturn (sent); }  static void * sender_body(void *data) { \tstruct targ *targ = (struct targ*) data; \tstruct pollfd fds[1]; \tstruct netmap_if *nifp = targ-&gt;nifp; \tstruct netmap_ring *txring; \tint i, sent = 0; \tD(&quot;start&quot;); \tif (setaffinity(targ-&gt;thread, targ-&gt;affinity)) \t\tgoto quit; \t\/* setup poll(2) mechanism. *\/ \tmemset(fds, 0, sizeof(fds)); \tfds[0].fd = targ-&gt;fd; \tfds[0].events = (POLLOUT);  \t\/* main loop. *\/ \tgettimeofday(&targ-&gt;tic, NULL); { \t\twhile (1) { \t\t\t\/* \t\t\t * wait for available room in the send queue(s) \t\t\t *\/ \t\t\tif (poll(fds, 1, 2000) &lt;= 0) { \t\t\t\tD(&quot;poll error\/timeout on queue %d\\n&quot;, targ-&gt;me); \t\t\t\tgoto quit; \t\t\t} \t\t\t\/* \t\t\t * scan our queues and send on those with room \t\t\t *\/ \t\t\tfor (i = targ-&gt;qfirst; i &lt; targ-&gt;qlast; i++) { \t\t\t\t\/\/ int m, limit = targ-&gt;g-&gt;burst; \t\t\t\tint m, limit = 512;  \t\t\t\ttxring = NETMAP_TXRING(nifp, i); \t\t\t\tif (txring-&gt;avail == 0) \t\t\t\t\tcontinue;  \t\t\t\tm = send_packets(txring, &targ-&gt;pkt, targ-&gt;g-&gt;pkt_size, limit); \t\t\t\tsent += m; \t\t\t\ttarg-&gt;count = sent; \t\t\t} \t\t} \t\t\/* flush any remaining packets *\/ \t\tioctl(fds[0].fd, NIOCTXSYNC, NULL);  \t\t\/* final part: wait all the TX queues to be empty. *\/ \t\tfor (i = targ-&gt;qfirst; i &lt; targ-&gt;qlast; i++) {  \t\t\ttxring = NETMAP_TXRING(nifp, i); \t\t\twhile (!NETMAP_TX_RING_EMPTY(txring)) { \t\t\t\tioctl(fds[0].fd, NIOCTXSYNC, NULL); \t\t\t\tusleep(1); \/* wait 1 tick *\/ \t\t\t} \t\t} \t}  \tgettimeofday(&targ-&gt;toc, NULL); \ttarg-&gt;completed = 1; \ttarg-&gt;count = sent;  quit: \t\/* reset the ``used`` flag. *\/ \ttarg-&gt;used = 0;  \treturn (NULL); }  static void usage(void) { \tconst char *cmd = &quot;pkt-gen&quot;; \tfprintf(stderr, \t\t&quot;Usage:\\n&quot; &quot;%s arguments\\n&quot; &quot;\\t-i interface\t\tinterface name\\n&quot; \t\t&quot;\\t-l pkts_size\t\tin bytes excluding CRC\\n&quot; &quot;\\t-d dst-ip\t\tend with %%n to sweep n addresses\\n&quot; \t\t&quot;\\t-s src-ip\t\tend with %%n to sweep n addresses\\n&quot; &quot;\\t-D dst-mac\t\tend with %%n to sweep n addresses\\n&quot; \t\t&quot;\\t-S src-mac\t\tend with %%n to sweep n addresses\\n&quot; &quot;&quot;, cmd);  \texit(0); }  int main(int arc, char **argv) { \tint i, fd;  \tstruct glob_arg g;  \tstruct nmreq nmr; \tvoid *mmap_addr; \/* the mmap address *\/ \tvoid *(*td_body)(void *) = sender_body; \tint ch; \tint report_interval = 1000; \/* report interval *\/ \tchar *ifname = NULL; \t\/\/ int wait_link = 2; \tint devqueues = 1; \/* how many device queues *\/  \t\/* initialize random seed: *\/ \tsrand(time(NULL));  \tbzero(&g, sizeof(g));  \tg.src_ip = &quot;10.0.0.1&quot;; \tg.dst_ip = &quot;10.0.0.2&quot;; \tg.dst_mac = &quot;ff:ff:ff:ff:ff:ff&quot;; \t\/\/ g.dst_mac = NULL; \tg.src_mac = NULL; \tg.pkt_size = 60; \tg.burst = 512; \/\/ default \tg.nthreads = 2; \/\/ \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0432 2 \u043f\u043e\u0442\u043e\u043a\u0430 \t\/\/ g.cpus = 1; \tg.cpus = system_ncpus(); \/\/ \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u043c \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u044b  \twhile ((ch = getopt(arc, argv, &quot;i:l:d:s:D:S:v&quot;)) != -1) { \t\tswitch (ch) { \t\tdefault: \t\t\tD(&quot;bad option %c %s&quot;, ch, optarg); \t\t\tusage(); \t\t\tbreak; \t\tcase 'i': \/* interface *\/ \t\t\tifname = optarg; \t\t\tbreak; \t\tcase 'l': \/* pkt_size *\/ \t\t\tg.pkt_size = atoi(optarg); \t\t\tbreak; \t\tcase 'd': \t\t\tg.dst_ip = optarg; \t\t\tbreak; \t\tcase 's': \t\t\tg.src_ip = optarg; \t\t\tbreak; \t\tcase 'D': \/* destination mac *\/ \t\t\tg.dst_mac = optarg; \t\t\tstruct ether_addr *mac = ether_aton(g.dst_mac); \t\t\tD(&quot;ether_aton(%s) gives %p&quot;, g.dst_mac, mac); \t\t\tbreak; \t\tcase 'S': \/* source mac *\/ \t\t\tg.src_mac = optarg; \t\t\tbreak; \t\t} \t}  \tif (ifname == NULL) { \t\tD(&quot;missing ifname&quot;); \t\tusage(); \t} { \t\tint n = system_ncpus(); \t\tif (g.cpus &lt; 0 || g.cpus &gt; n) { \t\t\tD(&quot;%d cpus is too high, have only %d cpus&quot;, g.cpus, n); \t\t\tusage(); \t\t} \t\tif (g.cpus == 0) \t\t\tg.cpus = n; \t} \tif (g.pkt_size &lt; 16 || g.pkt_size &gt; 1536) { \t\tD(&quot;bad pktsize %d\\n&quot;, g.pkt_size); \t\tusage(); \t}  \tif (td_body == sender_body && g.src_mac == NULL) { \t\tstatic char mybuf[20] = &quot;ff:ff:ff:ff:ff:ff&quot;; \t\t\/* retrieve source mac address. *\/ \t\tif (source_hwaddr(ifname, mybuf) == -1) { \t\t\tD(&quot;Unable to retrieve source mac&quot;); \t\t\t\/\/ continue, fail later \t\t} \t\tg.src_mac = mybuf; \t}  \t{ \t\tbzero(&nmr, sizeof(nmr)); \t\tnmr.nr_version = NETMAP_API; \t\t\/* \t\t * Open the netmap device to fetch the number of queues of our \t\t * interface. \t\t * \t\t * The first NIOCREGIF also detaches the card from the \t\t * protocol stack and may cause a reset of the card, \t\t * which in turn may take some time for the PHY to \t\t * reconfigure. \t\t *\/ \t\tfd = open(&quot;\/dev\/netmap&quot;, O_RDWR); \t\tif (fd == -1) { \t\t\tD(&quot;Unable to open \/dev\/netmap&quot;); \t\t\t\/\/ fail later \t\t} \t\telse { \t\t\tif ((ioctl(fd, NIOCGINFO, &nmr)) == -1) { \t\t\t\tD(&quot;Unable to get if info without name&quot;); \t\t\t} \t\t\telse { \t\t\t\tD(&quot;map size is %d Kb&quot;, nmr.nr_memsize &gt;&gt; 10); \t\t\t} \t\t\tbzero(&nmr, sizeof(nmr)); \t\t\tnmr.nr_version = NETMAP_API; \t\t\tstrncpy(nmr.nr_name, ifname, sizeof(nmr.nr_name)); \t\t\tif ((ioctl(fd, NIOCGINFO, &nmr)) == -1) { \t\t\t\tD(&quot;Unable to get if info for %s&quot;, ifname); \t\t\t} \t\t\tdevqueues = nmr.nr_rx_rings; \t\t}  \t\t\/* validate provided nthreads. *\/ \t\tif (g.nthreads &lt; 1 || g.nthreads &gt; devqueues) { \t\t\tD(&quot;bad nthreads %d, have %d queues&quot;, g.nthreads, devqueues); \t\t\t\/\/ continue, fail later \t\t}  \t\t\/* \t\t * Map the netmap shared memory: instead of issuing mmap() \t\t * inside the body of the threads, we prefer to keep this \t\t * operation here to simplify the thread logic. \t\t *\/ \t\tD(&quot;mmapping %d Kbytes&quot;, nmr.nr_memsize &gt;&gt; 10); \t\tmmap_addr = (struct netmap_d*) mmap(0, nmr.nr_memsize, \t\t\tPROT_WRITE | PROT_READ, MAP_SHARED, fd, 0); \t\tif (mmap_addr == MAP_FAILED) { \t\t\tD(&quot;Unable to mmap %d KB&quot;, nmr.nr_memsize &gt;&gt; 10); \t\t\t\/\/ continue, fail later \t\t}  \t\t\/* \t\t * Register the interface on the netmap device: from now on, \t\t * we can operate on the network interface without any \t\t * interference from the legacy network stack. \t\t * \t\t * We decide to put the first interface registration here to \t\t * give time to cards that take a long time to reset the PHY. \t\t *\/ \t\tnmr.nr_version = NETMAP_API; \t\tif (ioctl(fd, NIOCREGIF, &nmr) == -1) { \t\t\tD(&quot;Unable to register interface %s&quot;, ifname); \t\t\t\/\/ continue, fail later \t\t}  \t\t\/* Print some debug information. *\/ \t\tfprintf(stdout, &quot;%s %s: %d queues, %d threads and %d cpus.\\n&quot;, \t\t\t(td_body == sender_body) ? &quot;Sending on&quot; : &quot;Receiving from&quot;, ifname, \t\t\tdevqueues, g.nthreads, g.cpus); \t\tif (td_body == sender_body) { \t\t\tfprintf(stdout, &quot;%s -&gt; %s (%s -&gt; %s)\\n&quot;, g.src_ip, g.dst_ip, \t\t\t\tg.src_mac, g.dst_mac); \t\t}  \t\t\/* Exit if something went wrong. *\/ \t\tif (fd &lt; 0) { \t\t\tD(&quot;Aborting&quot;); \t\t\tusage(); \t\t} \t}  \t\/\/ &quot;Wait 3 secs for phy reset&quot; \t\/\/ sleep(wait_link); \tsleep(3); \tD(&quot;Ready...&quot;);  \t\/* Install ^C handler. *\/ \tglobal_nthreads = g.nthreads; \tsignal(SIGINT, sigint_h);  \ttargs = calloc(g.nthreads, sizeof(*targs)); \t\/* \t * Now create the desired number of threads, each one \t * using a single descriptor. \t *\/ \tfor (i = 0; i &lt; g.nthreads; i++) { \t\tstruct netmap_if *tnifp; \t\tstruct nmreq tifreq; \t\tint tfd;  \t\t\/* register interface. *\/ \t\ttfd = open(&quot;\/dev\/netmap&quot;, O_RDWR); \t\tif (tfd == -1) { \t\t\tD(&quot;Unable to open \/dev\/netmap&quot;); \t\t\tcontinue; \t\t}  \t\tbzero(&tifreq, sizeof(tifreq)); \t\tstrncpy(tifreq.nr_name, ifname, sizeof(tifreq.nr_name)); \t\ttifreq.nr_version = NETMAP_API; \t\ttifreq.nr_ringid = (g.nthreads &gt; 1) ? (i | NETMAP_HW_RING) : 0;  \t\tif ((ioctl(tfd, NIOCREGIF, &tifreq)) == -1) { \t\t\tD(&quot;Unable to register %s&quot;, ifname); \t\t\tcontinue; \t\t} \t\ttnifp = NETMAP_IF(mmap_addr, tifreq.nr_offset);  \t\t\/* start threads. *\/ \t\tbzero(&targs[i], sizeof(targs[i])); \t\ttargs[i].g = &g; \t\ttargs[i].used = 1; \t\ttargs[i].completed = 0; \t\ttargs[i].fd = tfd; \t\ttargs[i].nmr = tifreq; \t\ttargs[i].nifp = tnifp; \t\ttargs[i].qfirst = (g.nthreads &gt; 1) ? i : 0; \t\ttargs[i].qlast = (g.nthreads &gt; 1) ? i + 1 : tifreq.nr_tx_rings; \t\ttargs[i].me = i; \t\ttargs[i].affinity = g.cpus ? i % g.cpus : -1; \t\tif (td_body == sender_body) { \t\t\t\/* initialize the packet to send. *\/ \t\t\tinitialize_packet(&targs[i]); \t\t}  \t\tif (pthread_create(&targs[i].thread, NULL, td_body, &targs[i]) == -1) { \t\t\tD(&quot;Unable to create thread %d&quot;, i); \t\t\ttargs[i].used = 0; \t\t} \t}  \t{ \t\tuint64_t my_count = 0, prev = 0; \t\tuint64_t count = 0; \t\tstruct timeval tic, toc; \t\tgettimeofday(&toc, NULL); \t\tfor (; ;) {  \t\t\tstruct timeval now, delta; \t\t\tuint64_t pps; \t\t\tint done = 0;  \t\t\tdelta.tv_sec = report_interval \/ 1000; \t\t\tdelta.tv_usec = (report_interval % 1000) * 1000; \t\t\tselect(0, NULL, NULL, NULL, &delta); \t\t\tgettimeofday(&now, NULL); \t\t\ttimersub(&now, &toc, &toc); \t\t\tmy_count = 0; \t\t\tfor (i = 0; i &lt; g.nthreads; i++) { \t\t\t\tmy_count += targs[i].count; \t\t\t\tif (targs[i].used == 0) \t\t\t\t\tdone++; \t\t\t} \t\t\tpps = toc.tv_sec * 1000000 + toc.tv_usec; \t\t\tif (pps &lt; 10000) \t\t\t\tcontinue; \t\t\tpps = (my_count - prev) * 1000000 \/ pps; \t\t\tD(&quot;%&quot; PRIu64 &quot; pps&quot;, pps); \t\t\tprev = my_count; \t\t\ttoc = now; \t\t\tif (done == g.nthreads) \t\t\t\tbreak; \t\t}  \t\ttimerclear(&tic); \t\ttimerclear(&toc); \t\tfor (i = 0; i &lt; g.nthreads; i++) { \t\t\t\/* \t\t\t * Join active threads, unregister interfaces and close \t\t\t * file descriptors. \t\t\t *\/ \t\t\tpthread_join(targs[i].thread, NULL); \t\t\tioctl(targs[i].fd, NIOCUNREGIF, &targs[i].nmr); \t\t\tclose(targs[i].fd);  \t\t\tif (targs[i].completed == 0) \t\t\t\tcontinue;  \t\t\t\/* \t\t\t * Collect threads output and extract information about \t\t\t * how long it took to send all the packets. \t\t\t *\/ \t\t\tcount += targs[i].count; \t\t\tif (!timerisset(&tic) || timercmp(&targs[i].tic, &tic, &lt;)) \t\t\t\ttic = targs[i].tic; \t\t\tif (!timerisset(&toc) || timercmp(&targs[i].toc, &toc, &gt;)) \t\t\t\ttoc = targs[i].toc; \t\t}  \t}  \tioctl(fd, NIOCUNREGIF, &nmr); \tmunmap(mmap_addr, nmr.nr_memsize); \tclose(fd);  \treturn (0); } \/* end of file *\/ <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c.<\/p>\n<pre><code class=\"bash\"># .\/tcp-gen -i igb0 -d 10.0.0.2 -D 00:1b:21:a3:5f:fc -s 10.0.0.1 -l 60 main [543] ether_aton(00:1b:21:a3:5f:fc) gives 0x800fac8d2 main [600] map size is 207712 Kb main [622] mmapping 207712 Kbytes Sending on igb0: 2 queues, 2 threads and 2 cpus. 10.0.0.1 -&gt; 10.0.0.2 (a0:36:9f:06:81:d6 -&gt; 00:1b:21:a3:5f:fc) main [663] Ready... sender_body [422] start sender_body [422] start main [746] 1003502 pps main [746] 1488140 pps main [746] 1488132 pps main [746] 1488135 pps main [746] 1488136 pps main [746] 1488137 pps main [746] 1488141 pps main [746] 1488132 pps main [746] 1488134 pps main [746] 1488134 pps ^Csigint_h [215] Cancelling thread #0  sigint_h [215] Cancelling thread #1  main [746] 1296740 pps  <\/code><\/pre>\n<p>  \u0423\u0442\u0438\u043b\u0438\u0442\u0430 \u043e\u0442\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e \u0431\u0435\u0437 \u043c\u0430\u043b\u043e\u0433\u043e 1,5mpps. \u041d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442:  <\/p>\n<pre><code class=\"bash\">last pid:  1789;  load averages:  1.17,  0.43,  0.95                        up 0+01:23:20  12:55:27 108 processes: 5 running, 77 sleeping, 26 waiting CPU 0:  5.9% user,  0.0% nice, 90.9% system,  3.1% interrupt,  0.0% idle CPU 1:  0.0% user,  0.0% nice, 95.3% system,  4.7% interrupt,  0.0% idle Mem: 18M Active, 14M Inact, 313M Wired, 14M Buf, 3545M Free Swap: 2572M Total, 2572M Free    PID USERNAME PRI NICE   SIZE    RES STATE   C   TIME    CPU COMMAND  1765 root     102    0   217M  6040K RUN     1   0:53 99.46% pkt-gen{pkt-gen}  1765 root     102    0   217M  6040K CPU0    0   0:53 99.37% pkt-gen{pkt-gen}    12 root     -92    -     0K   416K WAIT    0   0:14  2.29% intr{irq256: igb0:que}    12 root     -92    -     0K   416K WAIT    1   0:43  1.86% intr{irq257: igb0:que}    11 root     155 ki31     0K    32K RUN     0  74:15  0.00% idle{idle: cpu0}    11 root     155 ki31     0K    32K RUN     1  74:04  0.00% idle{idle: cpu1}  <\/code><\/pre>\n<p>  \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043b\u0435\u0442\u0430\u044e\u0449\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u044b:  <\/p>\n<pre><code class=\"bash\">tcpdump -i em1 -n -vvv 13:14:44.814897 IP (tos 0x10, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 40)     10.0.0.1.14000 &gt; 10.0.0.2.80: Flags [S], cksum 0x4ae2 (correct), seq 1103125611, win 512 <\/code><\/pre>\n<p>  \u0417\u0430\u043c\u0435\u0440\u044f\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c. \u0410\u0442\u0430\u043a\u0443\u0435\u043c\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043e\u0442\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u043e 700kpps, \u043d\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u0434\u043e\u0437\u0440\u0435\u043d\u0438\u0435 \u0447\u0442\u043e \u043e\u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u0440\u0430\u0444\u0438\u043a, \u043f\u043e\u0442\u043e\u043c\u0443 \u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0439 \u043a\u043e\u043c\u043c\u0443\u0442\u0430\u0442\u043e\u0440 \u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0442\u043e-\u0436\u0435 \u0432\u0440\u0451\u0442:<br \/>  <img decoding=\"async\" src=\"http:\/\/nord.by\/files\/des3612.PNG\" alt=\"image\"\/><br \/>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u043d\u0430 \u043a\u043e\u043c\u043c\u0443\u0442\u0430\u0442\u043e\u0440\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u00ab\u043f\u0440\u043e\u0438\u0437\u0432\u0451\u043b\u00bb \u043f\u043e\u0447\u0442\u0438 \u043f\u043e\u043b\u0442\u043e\u0440\u0430 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430 \u043f\u0430\u043a\u0435\u0442\u043e\u0432. \u0422\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0442\u0440\u0430\u0444\u0438\u043a \u0432 3 \u0440\u0430\u0437\u0430 \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443, \u0437\u0430 \u0447\u0442\u043e \u0432\u044b\u043a\u0430\u0437\u044b\u0432\u0430\u044e \u043e\u0433\u0440\u043e\u043c\u043d\u0443\u044e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u043d\u043e\u0441\u0442\u044c \u0433-\u043d\u0443 Luigi Rizzo.<\/p>\n<p>  \u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u0441\u044f \u043e\u0434\u0438\u043d \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u2014 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 netmap \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043a\u0430\u0440\u0442\u0443 \u043e\u0442 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0441\u0442\u0435\u043a\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u044f \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 netmap-\u0440\u0435\u0436\u0438\u043c. \u0418\u043d\u043e\u0433\u0434\u0430 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043d\u0435 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0435\u043c\u0443 down\/up. \u041e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043a\u0430\u0440\u0442\u0430\u0445 igb (\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0442\u0430\u043a\u0436\u0435 em \u0438 re). \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044d\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043b\u0438\u0448\u044c \u0434\u0430\u043d\u043d\u043e\u0439 \u043a\u0430\u0440\u0442\u044b\/\u043f\u0430\u0440\u0442\u0438\u0438.<\/p>\n<p>  \u0421\u0441\u044b\u043b\u043a\u0438:<br \/>  \u0421\u0430\u0439\u0442 \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u2014 <a href=\"http:\/\/info.iet.unipi.it\/\">info.iet.unipi.it\/<\/a>~luigi\/netmap\/<br \/>  GoogleTechTalks video on netmap \u2014 <a href=\"http:\/\/www.youtube.com\/watch?v=SPtoXNW9yEQ\">www.youtube.com\/watch?v=SPtoXNW9yEQ<\/a> \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/183692\/\"> http:\/\/habrahabr.ru\/post\/183692\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t<b>\u0414\u0430\u043d\u043e:<\/b>  <\/p>\n<pre><code class=\"bash\"># pciconf -lv | grep -i device | grep -i network     device     = I350 Gigabit Network Connection # dmesg | grep CPU:     CPU: Intel(R) Core(TM)2 Duo CPU     E7300  @ 2.66GHz (2666.69-MHz K8-class CPU) # uname -orp     FreeBSD 9.1-RELEASE amd64 <\/code><\/pre>\n<p>  <b>\u0417\u0430\u0434\u0430\u0447\u0430: <\/b><br \/>  \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u0438 \u041e\u0421 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0430\u0433\u0440\u0443\u0437\u043e\u0447\u043d\u0443\u044e \u0432\u0438\u043b\u043a\u0443 \u0432 \u0432\u0438\u0434\u0435 tcp(syn)-\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 500kpps.<\/p>\n<p>  <b>\u0420\u0435\u0448\u0435\u043d\u0438\u0435:<\/b>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-183692","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/183692","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=183692"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/183692\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=183692"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=183692"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=183692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}