From owner-freebsd-net@freebsd.org Thu Nov 26 12:14:11 2015 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0D611A39A4A for ; Thu, 26 Nov 2015 12:14:11 +0000 (UTC) (envelope-from wuhao.thu@gmail.com) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id E2D411A60 for ; Thu, 26 Nov 2015 12:14:10 +0000 (UTC) (envelope-from wuhao.thu@gmail.com) Received: by mailman.ysv.freebsd.org (Postfix) id DFBD0A39A48; Thu, 26 Nov 2015 12:14:10 +0000 (UTC) Delivered-To: net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C558EA39A47; Thu, 26 Nov 2015 12:14:10 +0000 (UTC) (envelope-from wuhao.thu@gmail.com) Received: from mail-lf0-x233.google.com (mail-lf0-x233.google.com [IPv6:2a00:1450:4010:c07::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4EB551A5E; Thu, 26 Nov 2015 12:14:10 +0000 (UTC) (envelope-from wuhao.thu@gmail.com) Received: by lfs39 with SMTP id 39so92891988lfs.3; Thu, 26 Nov 2015 04:14:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=IbG9KZdhjTjxNiP+DBXerQIsDZzErEqKKQEN9i5GhVM=; b=0ZO1wOrOT8N4z84DW+iRDS1+WI0DSfinaSmiMAOMB5bOGjzMhpQ3sHZytlxPXpXjDe +r2m2xJIi2pIqMGs9+AWHqVBOfoGTlm2ssLGBqPMWirrw5DBYk5cNbXvz8G+2Y0FuW0H ulJIZ+6O8T7bRPDKfVxuTsXC/QluoHiGrVLWTCG6TqfovTdDqSlZ5VL8htft56jlX/g1 L6EhQGbLhpwcBktqjCpyZgmz3fKMZOOUgzcKA3kqvgyK7oQH8BIwj9xO0owgzI/jndwW wqbDsr5Y4+xN26mmvG0xadpAFnjX6q90msrTuZwPd7JoQFP+83ZGpSAHtmKmKOzecH1v BCwA== MIME-Version: 1.0 X-Received: by 10.112.199.4 with SMTP id jg4mr14915780lbc.59.1448540048159; Thu, 26 Nov 2015 04:14:08 -0800 (PST) Received: by 10.25.148.213 with HTTP; Thu, 26 Nov 2015 04:14:08 -0800 (PST) In-Reply-To: <9b7b2eb25fd42295d3f2f8a46d2a3c1e@siag.nu> References: <9b7b2eb25fd42295d3f2f8a46d2a3c1e@siag.nu> Date: Thu, 26 Nov 2015 20:14:08 +0800 Message-ID: Subject: Re: Can I send the Ethernet frames with particular payload via Netmap? From: Hao Wu To: ulric@siag.nu Cc: net@freebsd.org, owner-freebsd-net@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Nov 2015 12:14:11 -0000 Hi Ulric, Got it! Many thanks :) +++++++++++++++++ Best, Hao On Thu, Nov 26, 2015 at 6:25 PM, wrote: > > > 2015-11-25 15:30 skrev Hao Wu: > >> Hi all, >> >> I just start using Netmap. I want to know can I build the Ethernet >> frames and send out via Netmap? I used to build the Ethernet frames via >> Libnet, but it is too slow. So I turn to Netmap now. But I have no idea on >> how to write the code using Netmap or what functions should I call? >> >> Any replay is highly appreciated! >> > > > It's crazy simple. To open a netmap descriptor: > > d = nm_open(ifname, NULL, 0, 0); > > To receive a frame: > > uint8_t *b = nm_nextpkt(d, &h); > > To send a frame: > > int n = nm_inject(d, b, len); > > Working example from Pen: > > https://github.com/UlricE/pen/blob/master/dsr.c > > Ulric >