In today’s connected world, speed is everything. Developers know that real-time video communications, internet calls, and instant messaging rely on data getting from one point to the other in the fastest way possible. After all, users will quickly stop interacting with your application if the experience is maligned with performance issues.
Plenty of issues can disrupt network performance and deliver a subpar user experience. One of these issues is packet loss.
As a developer, your goal should be to prevent packet loss in your application. With that in mind, we’ve created this guide that explains what packet loss is and how to stop it from happening. But before we get there, we first need to answer this question from the user’s perspective, “why do I have packet loss?”
What is Packet Loss?
Before defining network packet loss, we first need to know what a data packet is.
Any stuff you send over the internet is first divided into pieces of data and then reassembled once it reaches its destination. These are called packets.
Think of a packet as mail over the postal service. The actual letter is your raw data, but you also have supplementary information like the sender and the address on the envelope. This is called the header, and it’s needed so that data packets reach their intended destination. Other metadata are also used to refine data transmission further.
However, data packets don’t always reach their intended destination. Network congestion, software errors, or hacks can cause packets to drop. This is called a packet loss.
Packet loss is expressed as a percentage of packets lost over the total number sent. So, for example, if you sent 30 data packets and only 24 made it, that’s a 20% packet loss.
Fortunately, lost packets don’t remain lost. Instead, certain network protocols like Transmission Control Protocol (TCP) can retransmit that lost packet to ensure the data remains whole at the endpoint.
Unfortunately, this also eats up more bandwidth and time, increasing latency and jitter. In addition, excessive packet loss can also reduce the network’s throughput. Overall, these factors will cause a degraded user experience and reduced productivity.
Different applications manifest packet losses in various ways. Asynchronous communications like email or instant messaging will only introduce delays in receiving messages. When downloading a file, packet losses will increase download time. It’s not ideal but tolerable in most cases.
Packet loss becomes a big problem with real-time applications like VoIP calls and video conferencing. Even a slight 2% packet loss will cause choppy calls, distorted audio, garbled video, and, at worst, dropped calls.
If you’re using the User Datagram Protocol (UDP), then the effects of packet loss will be more apparent. That’s because, unlike the standard TCP, UDP doesn’t retransmit lost packets. Instead, it will terminate the connection and disrupt your session completely.
At worst, packet loss can lead to incomplete data or a corrupted file. This can cause empty spots in an image or severely distorted audio. Packet loss is also a security vulnerability that hackers can use to attack.
Why Do I Get Packet Loss?
Now that we know what a packet loss is, the next question is, “why am I getting packet loss?”
A myriad of factors causes packet loss. Understanding them is key in figuring out how to get rid of packet loss.
The number one culprit is network congestion. So if you’ve ever asked yourself, “why is my packet loss so high?” Network congestion is the first thing to investigate.
Congestion is caused by too much data being sent through limited bandwidth. For instance, being on a VoIP call while someone else is playing an online game and downloading a big file can slow down your network.
It’s not so different from too many cars passing through a narrow road during peak hours. When this happens, packets have no choice but to wait their turn to get transmitted over the network.
Unfortunately, if the packet gets delayed for too long, the network will ignore or discard them. This, of course, leads to packet loss and high latency.
Network hardware can also lead to packet losses. This happens when outdated firewalls and routers perform slower, which can delay the overall speed of the network. Even faulty cables can contribute to packet loss by disrupting the signal flow.
Hardware with older firmware might not handle the network as efficiently as one with new updates. Misconfigurations, especially with firewall access rules, can also impact packet loss.
There’s also the issue of wireless connections. Despite its convenience, Wi-FI is much more susceptible to environmental interference, leading to dropped packets.
Critical errors in software can also cause unnecessary packet losses. For example, bugs can execute unexpected network operations that might cause more congestion and lead to more dropped packets. At worst, it can lead to security vulnerabilities, which are big factors of packet loss.
In fact, a specific attack, called a packet drop attack, causes a compromised router to lose packets indiscriminately. This is a type of denial of service attack intended to disrupt the target network. One tell-tale sign of this happening is when you notice a sudden spike in packet loss percentages.
How to Prevent Packet Loss
Now that we’ve answered “what is packet loss?”, it’s time to figure out how to go around it.
What Users Can Do to Fix Packet Loss
Check Your Hardware
The simplest and most obvious step is to check your hardware connections. Make sure all your wiring isn’t worn out. Also, the type of cable you use matters. If you’re a small business handling dozens of concurrent connections, a Cat 5 or 6 cable is recommended.
Upgrade Your Internet Plan
Try to upgrade your Internet plan to a higher bandwidth. If you’re an organization, consider switching to a better WAN provider.
Use a Robust Router
You should also look into upgrading to a high-end router if you’re experiencing constant packet losses.
Switch to a Wired Connection
If you’re on a Wi-Fi connection, try switching to a wired connection. If that’s not possible, try placing yourself nearer the router to minimize signal disruptions. Also, try to balance devices between your router’s 5 GHz and 2.4 GHz frequencies to reduce congestion.
Prevent Overlapping Network Activities
Consider scheduling network activities to prevent overlap. For instance, try to download large files only outside working hours. If you’re at home, minimize VoIP calls to only one person at a time.
Prioritize packets in your router. For instance, if you want to have better quality VoIP calls, set your router firmware to prioritize DSCP class 46 packets.
What Developers Can Do to Prevent Packet Loss
Monitor Packet Loss with QoS tools
An important part of figuring out how to lower packet loss is proper monitoring. Thus, it’s wise to invest in a few network monitoring and quality of service (QoS) tools. Their big advantage is that they constantly check packet losses in real-time and instantly alert you if it gets excessive. They also offer logs to help you analyze packet losses and look for patterns.
Adaptive Bitrate Control
Another solution is adaptive bitrate control, which adjusts the bitrate of video streams based on network conditions. It does this by periodically sending packets to your router to measure bandwidth utilization. A good video call is one that keeps a constant bitrate and has no interruptions due to packet loss or latency.
Video applications have improved the overall quality of their services by increasing the bitrate for high-bandwidth connections and decreasing it for low-bandwidth ones. Unfortunately, this does not work with all audio applications due to their different latency requirements. The best you can do is set a higher audio bitrate, which will lessen jitter but also take more processing power to achieve.
Agora’s voice, video, and messaging SDKs make it easy for developers to build real-time experiences that automatically minimize the impacts of packet loss to provide a seamless communication experience for your users—in any application. With easy-to-embed APIs and a vast partner ecosystem, the ability to deliver voice, video, and real-time messaging to your users can be done quickly and cost-effectively.
The Bottom Line
Packet loss can be a disruptive distraction. If a file doesn’t download correctly or a video will not play, users will get frustrated with your application. As a developer, you can remove this frustration by investing in a real-time engagement solution that reduces packet loss and minimizes its impact on the user. Agora’s reliable worldwide coverage with ultra-low latency, scalability, and flexible, interactive features allow a user experience that’s free of disruption from packet loss and jitter.
Agora provides everything you need to build a complete real-time engagement experience. Sign up for free to start building your voice or video experience today.