From owner-freebsd-current@FreeBSD.ORG Sat Jul 30 03:20:21 2005 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 39CE016A41F for ; Sat, 30 Jul 2005 03:20:21 +0000 (GMT) (envelope-from snort_sam@yahoo.com) Received: from web54406.mail.yahoo.com (web54406.mail.yahoo.com [206.190.49.136]) by mx1.FreeBSD.org (Postfix) with SMTP id 0E38F43D49 for ; Sat, 30 Jul 2005 03:20:19 +0000 (GMT) (envelope-from snort_sam@yahoo.com) Received: (qmail 5482 invoked by uid 60001); 30 Jul 2005 03:20:19 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=D3r2MAbWv70onN5TFEg/fyZf3iVZVhvDcGA5RjOkC/fX0IVVxQiOSYcD6moeuYBDPlTePJ51Wd0/LTD+YjvOLLYjRRVpETmO63sYP0C3460//RK+kxfhU5IaC7LVrV+B+zkmZ6WAUZ5rRoLNrvLLNn/9KqYZbj9HSCLPU4t57mg= ; Message-ID: <20050730032019.5480.qmail@web54406.mail.yahoo.com> Received: from [203.201.96.175] by web54406.mail.yahoo.com via HTTP; Fri, 29 Jul 2005 20:20:19 PDT Date: Fri, 29 Jul 2005 20:20:19 -0700 (PDT) From: Bsderss To: Maksim Yevmenkin In-Reply-To: <42EA89CC.9050203@savvis.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Cc: freebsd-current@freebsd.org, freebsd-stable@freebsd.org, Tobias Roth Subject: why tun/tap but instead ordinary ethernet device (eg. fxp) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jul 2005 03:20:21 -0000 --- Maksim Yevmenkin wrote: > Hello, > > >>>As I want to learn how to use /dev/tap in > freebsd, > >> > >>I m > >> > >>>looking for a simple application that written for > >>>/dev/tap. OpenVPN is a bit too complicated for a > >>>newbie to get start. Can anyone tell me a link or > >>>reference for some of these examples? > >> > >>There are examples that come with the distribution > >>itself: > >> > >>http://vtun.sourceforge.net/tun/tun-1.1.tar.gz > >> > > > > Is this only for tun device? > > How much difference between tun and tap in terms > of > > programming when using the device? > > > > > >>(and this question would be better suited for > >>freebsd-questions, > >>if for any FreBSD=specific list at all) > >> > > > > Sorry, I currently don't have access to the > > frebsd.misc newsgroup, so I need to post the > question > > here. > > this type of question comes up quite often. its > really simple: a single > read(2) call on /dev/tapX will return entire > ethernet frame (if any) > received by tap interface (minus ethernet crc). a > single write(2) call > on /dev/tapX will put entire ethernet frame (w/out > ethernet crc) onto > tap interface outgoing queue. > > so, the "buf" parameter to the write(2) call on > /dev/tapX device should > point to a buffer with *complete* ethernet frame, > including ethernet > header and payload. payload could be IP packet, but > it does not have to > be. any protocol that uses ethernet as transport can > be tunneled with > tap(4) (i.e. ipx). > > the above is true for tun(4) with exception that > tun(4) operates on IP > packets. so you have to write/read complete IP > packets to/from /dev/tun. > Thanks for the detail explaination. As "man tap" pointed out, one can use tap drive as if using a pty device. I m not aware the obvious advantage of using tap over ordinarlly ethernet device for tunnelling programming (another example is ipsec). It may be because programming on tun/tap is alot of efficient and simpler. Can anyone pleaese explain? With vtun or openvpn, why they don't just simply use ordinary ethernet device driver but prefer tun or tap for tunneling or bridging network remote connection? Is it because applicaiton use tap or tun can send interrupt (with ioctl) to the remote client more efficiently? if so, can anyone please tell me what kind of efficiency does tun/tap over an ordianry ethernet device in terms of network programming? Thanks Sam > thanks, > max > ____________________________________________________ Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs