cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Visitor
Visitor
608 Views
Registered: ‎09-05-2020

first udp packets always lost

Hello,

we build freertos lwIP UDP Perf client example to test, but it always lost the first hundreds of packets

the device is zynq7020, it is giga ethernet.

why?

thank you,

mu

0 Kudos
Reply
10 Replies
Participant
Participant
585 Views
Registered: ‎11-21-2020

I don't know if it your issue but I can tell you a similar behavior we faced when streaming 1Gb/s in UDP.

UDP has no back pressure. The receiver side has no way to know whether there won't be any UPd traffic in the coming hours or if it will suddently face a 1GB/s datastream. At the time we had such a system, Linux or Windows didn't took any conservative measure (because it would have reserved precious memory resources maybe for nothing) and relied on the incoming traffic to react and adapt the resources allocated to the TCP/IP stack. In particular the amount of memory buffers in the scatter-gather of the DMA. Therefore it missed the first packets, noticed there was an incoming 1Gb/s datastream, allocated dynamically more buffers, then received the remaining packets without any lost.

To prevent this initial loss we had to tweak the TCP/IP parameters which is network card dependent and in particular the amount of memory buffer allocated by default.

Hope it helps.

Teacher
Teacher
570 Views
Registered: ‎07-09-2009

Yep,
UDP is send and forget.
the drivers are notorious for missing lumps of data,
If you need reliable, then that's what TCP/IP is all about
at the expense of latency,
<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>
Participant
Participant
556 Views
Registered: ‎11-21-2020

@drjohnsmith 

I partially disagree with you.

It is true if you have in mind end to end connection through a bunch of switches. But there is a lot of professional systems relying on UDP for transferring a lot of data without any loss. Indeed, given that a professional switch can have 24 or 48 x 1GbE/10GbE to connect ethernet endpoints in a point-to-point fashion, you can have a system with as many as 24/48 agents - which is already quite a lot for many professional apps - talking to each other full speed in UDP. I can tell you that you can dispatch several 4x1GbE streams to many compute servers w/o any data loss other such a switch.

So you can't only think in terms of protocol, you also have to take the network (and its elements) in considerations.

Visitor
Visitor
529 Views
Registered: ‎09-05-2020

thank you for your reply!
after the board is powered on, if it is first time to transmit data to UDP server, it always lost first hundreds of packets. but after some time, you transmit data again, udp packets are ok.
0 Kudos
Reply
Visitor
Visitor
527 Views
Registered: ‎09-05-2020

when udp data rate is high, the packets sometimes is lost and out of order.
0 Kudos
Reply
Visitor
Visitor
527 Views
Registered: ‎09-05-2020

thank you for your reply!
0 Kudos
Reply
Participant
Participant
503 Views
Registered: ‎11-21-2020

@mu

It depends also how you connect the different pieces of your system to each other. Is the board directly connected to the computer? is it connected through a cheap NetGear-like switch or is it connected through a professional grade switch? is it the only traffic through the switch? to the desktop? But I can ensure you that if you can control the overall network architecture, you can stream UDP full-speed without any loss and sometimes even without any reordering.

0 Kudos
Reply
Teacher
Teacher
487 Views
Registered: ‎07-09-2009

@EajksEajks

just be careful,
UDP is send and forget.

e.g.
https://en.wikipedia.org/wiki/User_Datagram_Protocol

" It has no handshaking dialogues, and thus exposes the user's program to any unreliability of the underlying network; there is no guarantee of delivery, ordering, or duplicate protection."

Depending upon the route taken over the network, and the load factor,
UDP is very un reliable.

Its used for some live streaming video and audio ,
it works great, very low latency,
but protocols on top have to be added so that the receiver knows what to do when it misses packets or a packet is out of order.

No professional system relies on UDP to transmit data without loss.


<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>
Participant
Participant
479 Views
Registered: ‎11-21-2020

@drjohnsmith 

10 years doing what I described. Massive parallel appliance. N times 1Gb/s. 24/24, 7/7. No packet loss.

Packet losses occur in switches and nics because of resource contention.

If you control your system, you can do it. If you can't control it, then it is indeed unreliable.

Teacher
Teacher
475 Views
Registered: ‎07-09-2009

I think we agree

UDP "has no handshaking dialogues, and thus exposes the user's program to any unreliability of the underlying network; there is no guarantee of delivery, ordering, or duplicate protection"


Not saying this persons problems are due to this,
but its probable.
<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>