CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

UDP Packet Loss Issue in Embedded Project with CCS C and PIC

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Makiwa



Joined: 21 Feb 2025
Posts: 1

View user's profile Send private message

UDP Packet Loss Issue in Embedded Project with CCS C and PIC
PostPosted: Fri Feb 21, 2025 8:45 am     Reply with quote

Hello,

I am currently working on an embedded project using the CCS C compiler for a PICmicro microcontroller. I've configured the system to use communication over an Ethernet network, but I'm encountering an issue when managing UDP packets. When attempting to send a UDP packet to a remote server, it seems like there's packet loss or an unusually long response delay.

I've checked the network configuration and the TCP/IP stack, but I can't clearly pinpoint the cause of the problem. If anyone has faced a similar issue or has suggestions on optimizing UDP packet handling in this context, I would greatly appreciate your input!

Thank you in advance for your help!
Ttelmah



Joined: 11 Mar 2010
Posts: 19730

View user's profile Send private message

PostPosted: Fri Feb 21, 2025 10:43 am     Reply with quote

You need to give a lot more information. There are so many generations of
PIC, that knowing which chip is vital.
Then how is the Ethernet being handled?. Internal Ethernet peripheral,
or an external chip?. how is the Ethernet connected?. Is this a local
network, or going via the internet?. How long are the packets?.
asmallri



Joined: 12 Aug 2004
Posts: 1639
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Re: UDP Packet Loss Issue in Embedded Project with CCS C and
PostPosted: Thu Feb 27, 2025 2:12 am     Reply with quote

Makiwa wrote:
Hello,

I am currently working on an embedded project using the CCS C compiler for a PICmicro microcontroller. I've configured the system to use communication over an Ethernet network, but I'm encountering an issue when managing UDP packets. When attempting to send a UDP packet to a remote server, it seems like there's packet loss or an unusually long response delay.

I've checked the network configuration and the TCP/IP stack, but I can't clearly pinpoint the cause of the problem. If anyone has faced a similar issue or has suggestions on optimizing UDP packet handling in this context, I would greatly appreciate your input!

Thank you in advance for your help!


UDP does not have a reliable transport layer (that is what TCP provides). When you use TCP an application's TCP stack is able to detect and recover from errors. When there is a low packet rate loss, the user will often not know that packet loss has occurred.

When using UDP, there is no network stack recovery therefore even a low packet loss rate will result in the user or application having an issue. If your forwarding path includes an Ethernet hub anywhere along the path then packet loss is a fact of life.

What this also means for custom hardware, if you have a hardware fault / design flaw that results in corrupt packets, TCP may appear to work fine but UDP will not. To test your hardware is functioning correctly, try using TCP with a packet sniffer and see if packet retransmissions are occuring indicting a hardware issue.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Ttelmah



Joined: 11 Mar 2010
Posts: 19730

View user's profile Send private message

PostPosted: Thu Feb 27, 2025 7:13 am     Reply with quote

That was why I was wondering whether this was a local network, or across
the internet?. UDP, will usually work fine on a local network, provided there
is not congestion, but across the internet is not reliable at all. If you want to
or must use this, then you have to add your own data recovery protocol to
what you are sending.....

The paint of UDP, is speed over reliability .It is designed for things like
video streaming, where losing a packet just means a hiccup in the video,
but doesn't really 'matter', but being able to guarantee the speed is
important.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group