Questions tagged [udp]

User Datagram Protocol is one of the messaging protocols of the IP protocol stack. With UDP, computer applications can send messages to other hosts on an Internet Protocol (IP) network without requiring prior communications to set up special transmission channels or data paths.

UDP uses a simple transmission model without implicit handshaking dialogues for providing reliability, ordering, or data integrity. Thus, UDP provides an unreliable service and datagrams may arrive out of order, appear duplicated, or go missing without notice.

UDP assumes that error checking and correction is either not necessary or performed in the application or at the hardware level (layer 1 and 2), avoiding the overhead of such processing at the network interface level.

Time-sensitive applications often use UDP because dropping packets is preferable to waiting for delayed packets, which may not be an option in a real-time system.

There is more information at the Wikipedia article on UDP.

10654 questions
36
votes
4 answers

Strange behaviour of netcat with UDP

I noticed a strange behaviour working with netcat and UDP. I start an instance (instance 1) of netcat that listens on a UDP port: nc -lu -p 10000 So i launch another instance of netcat (instance 2) and try to send datagrams to my process: nc -u…
MirkoBanchi
  • 2,173
  • 5
  • 35
  • 52
36
votes
4 answers

How to UDP Broadcast with C in Linux?

How to UDP Broadcast with C in Linux?
Daniel Silveira
  • 41,125
  • 36
  • 100
  • 121
36
votes
9 answers

Can TCP be implemented via UDP?

I had a strange idea. I heard of software which from my understanding uses UDP to transfer files decreasing the overhead found in TCP packets. If my app requires TCP and my LAN has software set up to communicate with another datacenter on the other…
user34537
35
votes
2 answers

When does a UDP sendto() block?

While using the default (blocking) behavior on an UDP socket, in which case will a call to sendto() block? I'm interested essentially in the Linux behavior. For TCP I understand that congestion control makes the send() call blocking if the sending…
Jocelyn delalande
  • 5,123
  • 3
  • 30
  • 34
35
votes
5 answers

Size of empty UDP and TCP packet?

What is the size of an empty UDP datagram? And that of an empty TCP packet? I can only find info about the MTU, but I want to know what is the "base" size of these, in order to estimate bandwidth consumption for protocols on top of them.
puccio
  • 3,054
  • 8
  • 29
  • 20
33
votes
5 answers

What would cause UDP packets to be dropped when being sent to localhost?

I'm sending very large (64000 bytes) datagrams. I realize that the MTU is much smaller than 64000 bytes (a typical value is around 1500 bytes, from my reading), but I would suspect that one of two things would happen - either no datagrams would make…
Thomas Owens
  • 114,398
  • 98
  • 311
  • 431
33
votes
4 answers

Setting the source IP for a UDP socket

I have a UDP socket that is bound to INADDR_ANY to listen to packets on all the IPs my server has. I'm sending out replies through the same socket. Right now the server chooses automatically which IP is used as the source IP when packets are sent…
Gene Vincent
  • 5,237
  • 9
  • 50
  • 86
32
votes
3 answers

Receiving Broadcast Packets in Python

I have the following code which sends a udp packet that is broadcasted in the subnet. from socket import * s=socket(AF_INET, SOCK_DGRAM) s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1) s.sendto('this is testing',('255.255.255.255',12345)) The following…
nitish712
  • 19,504
  • 5
  • 26
  • 34
32
votes
5 answers

Is sending data via UDP sockets on the same machine reliable?

If i use UDP sockets for interprocess communication, can i expect that all send data is received by the other process in the same order? I know this is not true for UDP in general.
Lothar
  • 12,537
  • 6
  • 72
  • 121
32
votes
4 answers

The most reliable and efficient udp packet size?

Would sending lots a small packets by UDP take more resources (cpu, compression by zlib, etc...). I read here that sending one big packet of ~65kBYTEs by UDP would probably fail so I'm thought that sending lots of smaller packets would succeed more…
pandoragami
  • 5,387
  • 15
  • 68
  • 116
31
votes
2 answers

When is IPPROTO_UDP required?

When is IPPROTO_UDP required? Is there ever a case where UDP is not the default protocol for SOCK_DGRAM? (real cases, not hypothetical "it might be", please") i.e., what are the situations where the following two lines would not produce identical…
Mark Harrison
  • 297,451
  • 125
  • 333
  • 465
31
votes
3 answers

NodeJS UDP Multicast How to

I'm trying to send a UDP Multicast Packet to: 230.185.192.108 so everyone subscribed will receive. A bit stuck. I believe it's broadcasting correctly, but can't seem to pick anything up with any client. Server: var news = [ "Borussia Dortmund…
Taurian
  • 1,660
  • 7
  • 20
  • 28
30
votes
3 answers

UDP checksum calculation

The UDP header struct defined at /usr/include/netinet/udp.h is as follows struct udphdr { u_int16_t source; u_int16_t dest; u_int16_t len; u_int16_t check; }; What value is stored in the check field of the header? How to verify if the…
Deepak
  • 2,003
  • 6
  • 30
  • 32
29
votes
3 answers

What is a message boundary?

What are "message boundaries" in the following context? One difference between TCP and UDP is that UDP preserves message boundaries. I understand the difference between TCP and UDP, but I'm unsure about the definition of "message…
KMC
  • 19,548
  • 58
  • 164
  • 253
29
votes
3 answers

UDP-Broadcast on all interfaces

On a Linux system with a wired and a wireless interface (e.g. 192.168.1.x and 192.168.2.x subnets) I want to send a UDP broadcast that goes out via ALL available interfaces (i.e. both through the wired and the wireless interface). Currently I…
Steven