UDP broadcast packets across subnets

Yes, and no. It’s actually do-able, so long as the intervening routers don’t have no ip directed-broadcasts or similar configured. However these days that’s the default because allowing normal broadcasts to traverse routers is a DoS problem. If you really want to broadcast across subnets then you should be using IP Multicast instead. That still … Read more

C# UDP Broadcast and receive example

It can simply be done as int PORT = 9876; UdpClient udpClient = new UdpClient(); udpClient.Client.Bind(new IPEndPoint(IPAddress.Any, PORT)); var from = new IPEndPoint(0, 0); var task = Task.Run(() => { while (true) { var recvBuffer = udpClient.Receive(ref from); Console.WriteLine(Encoding.UTF8.GetString(recvBuffer)); } }); var data = Encoding.UTF8.GetBytes(“ABCD”); udpClient.Send(data, data.Length, “255.255.255.255”, PORT); task.Wait();

TCP stream vs UDP message

The interface/API presented to you the user(programmer) of these protocols are: UDP Message oriented, you have an API (send/recv and similar) that provide you with the ability to send one datagram, and receive one datagram. 1 send() call results in 1 datagram sent, and 1 recv() call will recieve exactly 1 datagram. TCP Stream oriented, … Read more

Why is SNMP usually run over UDP and not TCP/IP?

UDP is actually expected to work better than TCP in lossy networks (or congested networks). TCP is far better at transferring large quantities of data, but when the network fails it’s more likely that UDP will get through. (in fact, I recently did a study testing this and it found that SNMP over UDP succeeded … Read more