From owner-freebsd-questions@FreeBSD.ORG Wed Jul 4 15:43:26 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2041C106566B; Wed, 4 Jul 2012 15:43:26 +0000 (UTC) (envelope-from vladimir.budnev@gmail.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id 57A218FC12; Wed, 4 Jul 2012 15:43:25 +0000 (UTC) Received: by lbon10 with SMTP id n10so13285429lbo.13 for ; Wed, 04 Jul 2012 08:43:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=oZxUEoyjjfJjgSd+4kyYvv0RFc08jvHr/v/h2JdnxaQ=; b=tzFafI/ODv10GnWtWltDXPs3Gb9c20IC77k7a8qr69aEh3DevSHmRO6kcLWLdOrQvS xPH2ss7ZF0m/KpJy2ZeMoNNvNu7g36frn3QV3SUjcwZ38CfduQFJqIiHCow53E7kycBG xgPRAVsMVWiMkJIxxsiV4gNynseWrRqX+Y0KnN6cSlj/6i5PhkXVK6ZNdo3FvGceuC2p M0iVF9Uw8jr5XPkWz3Eh6IBOw7L5cxvDRDAuBHxfQt/UIZdtr+HbjwfKzpUUEDePkayj q2/CiK1FIjZYDnDX6VMqKTshaLip2AaDiR+6qW1LaFbhaXwlei/oonv+BcH/j9KO4nrh frjA== Received: by 10.152.105.173 with SMTP id gn13mr22281587lab.20.1341416604098; Wed, 04 Jul 2012 08:43:24 -0700 (PDT) Received: from [192.168.66.106] ([80.253.27.98]) by mx.google.com with ESMTPS id hz16sm33362996lab.6.2012.07.04.08.43.22 (version=SSLv3 cipher=OTHER); Wed, 04 Jul 2012 08:43:23 -0700 (PDT) Message-ID: <4FF46498.2070901@gmail.com> Date: Wed, 04 Jul 2012 19:43:20 +0400 From: Budnev Vladimir User-Agent: Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: Nikolay Denev References: <4FF45C81.3030907@gmail.com> <07EA7CC9-19CF-4EFE-A9E2-6A94DCA3F1AC@gmail.com> In-Reply-To: <07EA7CC9-19CF-4EFE-A9E2-6A94DCA3F1AC@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Cc: freebsd-questions@freebsd.org, net@freebsd.org Subject: Re: how to correctly distinguish broadcast udp packets vs unicast (socket, pcap or bpf)? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jul 2012 15:43:26 -0000 07/04/12 19:37, Nikolay Denev пишет: > On Jul 4, 2012, at 6:08 PM, Budnev Vladimir wrote: > >> Good day to all. >> >> What is the correct way to distinguish udp packets that obtained by application and were send on 255.255.255.255 ip addr from those that were send to unicast ip? >> >> Seems it is impossible with read/recvfrom so we'v made that with libpcap. It coul be done with directly bpf api without pcap wrapper but i'm not sure about how big pcap overhead is. >> >> The questions is if we have about 1Gb incoming traffic and using pcap filter for specific port how big is impact of using pcap in such situation? Is it possbile to estimate? Target traffic is about 1Mbit and while testing CPU is about 1-2% but i'm not sure about all the conditions. >> >> recfrom recieves all the data without loss in such condition, is it possible that pcap because of its filtering nature(i dont know in details how bpf is realized deep in kernel:( ) will add big overhead while listening? >> >> >> _______________________________________________ >> 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" > > If I'm understanding your question correctly you can lookup the ip(4) manual page : > > If the IP_RECVDSTADDR option is enabled on a SOCK_DGRAM socket, the recvmsg call will return the destination IP address for a UDP datagram. The msg_control field in the msghdr structure points to a buffer > that contains a cmsghdr structure followed by the IP address. The cmsghdr fields have the following values: > > You can use this in you application and get the destination address of the packets be it unicast IP or the broadcast address. Tnx for fast response! Hm... seems if it will work it will help. I'll test that as soon as possbile!