Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Jul 2012 18:37:21 +0300
From:      Nikolay Denev <ndenev@gmail.com>
To:        Budnev Vladimir <vladimir.budnev@gmail.com>
Cc:        freebsd-questions@freebsd.org, net@freebsd.org
Subject:   Re: how to correctly distinguish broadcast udp packets vs unicast (socket, pcap or bpf)?
Message-ID:  <07EA7CC9-19CF-4EFE-A9E2-6A94DCA3F1AC@gmail.com>
In-Reply-To: <4FF45C81.3030907@gmail.com>
References:  <4FF45C81.3030907@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On Jul 4, 2012, at 6:08 PM, Budnev Vladimir wrote:

> Good day to all.
>=20
> 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?
>=20
> 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.
>=20
> 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.
>=20
> 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?
>=20
>=20
> _______________________________________________
> 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.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?07EA7CC9-19CF-4EFE-A9E2-6A94DCA3F1AC>