From owner-freebsd-net@FreeBSD.ORG Sun Apr 28 15:58:59 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 6F44BE28 for ; Sun, 28 Apr 2013 15:58:59 +0000 (UTC) (envelope-from sodynet1@gmail.com) Received: from mail-pa0-f44.google.com (mail-pa0-f44.google.com [209.85.220.44]) by mx1.freebsd.org (Postfix) with ESMTP id 4847C1AFD for ; Sun, 28 Apr 2013 15:58:58 +0000 (UTC) Received: by mail-pa0-f44.google.com with SMTP id rl6so82266pac.17 for ; Sun, 28 Apr 2013 08:58:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=rrcfrJiKq5dEf9gPCgoKoNUPNdBYhLCG5fd7+6QgkK8=; b=Stu8WNjOlco1alo2LWE4O7qo6LAXY+cmDlV6kGShMf1Xjx+4FB8ZHEFR7YovoEL5tG IT5zXTSbCjOOega/YVgCGfcSv7HykQrVDE0aAiGL16tpr7snjqlVVDbRp92Be9TLaxzT mUf10Zy2GocopQAHGAQv6BAolYs1TOKdwlqgKKjRC2yfiKIElJgW7mdFGVFRU0FjvFl/ 8nNOkVZ8zWSZRyetQKQvEQf+dbwZBK8X9a7Oot0AXgeaWrca08Ku+Z+yJV/Jx+xHxb9Y 5MvicoNeYPzcWuLF6+7l7rlnY0r2NXU6WmVVYLBc4PcOFGcUKC/dT1bY/IWAJ/iMoa6P ya4Q== MIME-Version: 1.0 X-Received: by 10.66.159.234 with SMTP id xf10mr39376957pab.203.1367164738523; Sun, 28 Apr 2013 08:58:58 -0700 (PDT) Received: by 10.70.100.132 with HTTP; Sun, 28 Apr 2013 08:58:58 -0700 (PDT) Received: by 10.70.100.132 with HTTP; Sun, 28 Apr 2013 08:58:58 -0700 (PDT) In-Reply-To: <20130426082457.GA33737@onelab2.iet.unipi.it> References: <20130426082457.GA33737@onelab2.iet.unipi.it> Date: Sun, 28 Apr 2013 18:58:58 +0300 Message-ID: Subject: Re: using netmap From: Sami Halabi To: Luigi Rizzo Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: freebsd-net@freebsd.org, Andreas Nilsson , Eitan Adler X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Apr 2013 15:58:59 -0000 Thank you. I've started using pkt-gen in virtualbox, 2 machines singlwe core-i7 3612QM core, with em cards internal. I see that the sender send about 950 kpps but the receiver is far less (around 200kpps max). Any suggestions why this? Sami On Apr 26, 2013 11:23 AM, "Luigi Rizzo" wrote: > On Fri, Apr 26, 2013 at 09:23:35AM +0300, Sami Halabi wrote: > > Hi Eitan, > > Thank your for your response. > > the ioctl is the example was in Luigi netmap page... maybe Luigi can help > > here??????? > > the thing i suggest is take the pkt-gen source from the FreeBSD tree > > tools/tools/netmap/ > > and start modifying that one. The samples on my web page are > 2 years old, and probably wrong in various ways even then. > They were meant to be something to put on a slide, so a lot of > details were missing. pkt-gen.c, on the other hand, is supposed > to build and be usable. > > As others pointed out, the snippets of code you posted have a lot > of very basic programming errors which suggest that the problems > you are seeing are not related to netmap. > > Of course we may be wrong, but the odds are against you, > so it is better to start from something known-working. > > Try to build your code with "cc -O2 -Wall -Werror" so the > compiler will find at least the most egregious bugs > and abort the compilation until you fix them. > > cheers > luigi > > > can you say why the print's are wrong? > > > > > > i fetched wrking headers from other tools without too much checking, > maybe > > some > > are irrelevant but for my tests i didn't worry about it yet, so here is > it: > > =================================================== > > #include > > #include /* signal */ > > #include > > #include > > #include /* PRI* macros */ > > #include /* strcmp */ > > #include /* open */ > > #include /* close */ > > #include /* getifaddrs */ > > > > #include /* PROT_* */ > > #include /* ioctl */ > > #include > > #include /* sockaddr.. */ > > #include /* ntohs */ > > #include > > #include /* sysctl */ > > #include /* timersub */ > > > > #include > > #include /* ifreq */ > > > > #include > > #include > > #include > > > > #include > > #include > > > > #ifndef MY_PCAP /* use the system's pcap if available */ > > > > #ifdef NO_PCAP > > #define PCAP_ERRBUF_SIZE 512 > > typedef void pcap_t; > > struct pcap_pkthdr; > > #define pcap_inject(a,b,c) ((void)a, (void)b, (void)c, -1) > > #define pcap_dispatch(a, b, c, d) (void)c > > #define pcap_open_live(a, b, c, d, e) ((void)e, NULL) > > #else /* !NO_PCAP */ > > #include // XXX do we need it ? > > #endif /* !NO_PCAP */ > > > > #endif // XXX hack > > > > #include /* pthread_* */ > > #include /* le64toh */ > > #include > > > > #include /* pthread w/ affinity */ > > #include /* cpu_set */ > > #include /* LLADDR */ > > =================================================== > > > > > > Thanks in advance, > > Sami > > > > > > On Fri, Apr 26, 2013 at 6:43 AM, Eitan Adler > wrote: > > > > > [ please bottom post or reply inline ] > > > > > > On 25 April 2013 17:48, Sami Halabi wrote: > > > > Okay, > > > > i figured out the includes, now it runs and seg faults: > > > > > > Don't forget to show the working headers ;) > > > > > > > any ideas? > > > > > > > > here is the new code: > > > > int main() { > > > > > > > > struct netmap_if *nifp = NULL; > > > > struct nmreq req; > > > > int i, len, fd; > > > > char *buf, *mem, *txt; > > > > > > > > printf("Starting...\n"); > > > > fd = open("/dev/netmap", 0); > > > > strcpy(req.nr_name, "em0"); // register the interface > > > > printf("em0 registered...\n"); > > > > ioctl(fd, NIOCREGIF, &req); // offset of the structure > > > > > > is req fully initialized? > > > > > > I don't think this ioctl is correct. Everything goes wrong after this > > > as a result. > > > > > > > printf("sysctl passed\n"); > > > > > > Things will not always crash if you make a wrong call. Try checking > > > return codes before printing something like this. > > > > > > > mem = mmap(NULL, req.nr_memsize, PROT_READ|PROT_WRITE, 0, fd, 0); > > > > printf("mem mapped...\n"); > > > > > > > > nifp = NETMAP_IF(mem, req.nr_offset); > > > > printf("nifp mapped...%u\n",(long)nifp); > > > > > > this seems wrong: ^^ ^^^^^^ > > > > > > > > > > for (;;) { > > > > struct pollfd x[1]; > > > > printf("rx ring def...\n"); > > > > struct netmap_ring *ring; > > > > printf("rx ring start...\n"); > > > > ring = NETMAP_RXRING(nifp, 0); > > > > printf("rx ring polled...\n"); > > > > > > > > x[0].fd = fd; > > > > x[0].events = POLLIN; > > > > poll(x, 1, 1000); > > > > for ( ; ring->avail > 0 ; ring->avail--) { > > > > i = ring->cur; > > > > printf("i=%d\n",&i); > > > > > > I think this is wrong. > > > > > > > buf = NETMAP_BUF(ring, i); > > > > printf("buff read...\n"); > > > > //use_data(buf, ring->slot[i].len); > > > > txt = malloc(sizeof(char) * ring->slot[i].len +1); > > > > strncpy(txt,buf,ring->slot[i].len); > > > > txt[ring->slot[i].len]='\0'; > > > > printf("len is: %d\n",&ring->slot[i].len); > > > > > > Also this. > > > > > > > ring->cur = NETMAP_RING_NEXT(ring, i); > > > > } > > > > } > > > > > > > > return 0; > > > > } > > > > > > > > > > > > -- > > > Eitan Adler > > > > > > > > > > > -- > > Sami Halabi > > Information Systems Engineer > > NMS Projects Expert > > FreeBSD SysAdmin Expert > > _______________________________________________ > > freebsd-net@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/freebsd-net > > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" >