Wednesday, 19 October 2011

What is Packet Loss on the Internet?



When faced with the typical Global Internet ping time of 300 milliseconds and 1 out of 25 packets being lost (4% average) an Internet VPN user with a typical IPV 1MB connection who might expect 10 megabytes/minute throughput on a clean local connection will find he is getting less than 10 per cent or under 1 megabytes/minute.

There are a number of factors that can constitute towards packet loss when routing over the public internet.

Congestion: The Internet Standards treat packet loss and congestion as synonyms. Routers discard incoming packets that can’t be stored or transmitted.  Imagine an Ethernet (10 megabit/sec) pipe feeding a 1 megabit router.  Any-time the average feed from the Ethernet exceeds 1 megabits/sec, packets will be lost. This is normal congestion, (ie. packets lost) because the average sum of the inputs to a router exceeds the capacity of its output; simple math.

Bit errors: As information packets move from place to place, there is always a chance that some bits will be modified. Each packet has a mathematical sum of the bits it contains appended to it. When a receiving router receives a packet whose contents and the appended sum don’t agree, that packet is discarded.  This can occur any-place in the journey from source to destination.

A Cisco router might show this in a number of ways by looking at the interface counters;

No errors on the CCT :
13377077 packets input, 1550035765 bytes Received 2 broadcasts, 0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
0 watchdog
0 input packets with dribble condition detected
3029752328 packets output, 700325236 bytes, 0 underruns
0 output errors, 0 collisions, 3 interface resets
0 babbles, 0 late collision, 0 deferred
0 lost carrier, 0 no carrier
0 output buffer failures, 0 output buffers swapped out

The last neighbor change was on the 15 th April:

The above shows a router running BGP on an almost perfect line.

Deliberate Discard: Networks can guarantee that certain connections and traffic won’t lose bits.Certain service providers may use Quality of Service features on routers to rate limit traffic to preserve and guarantee bandwidth to higher ranking protocols. This is also refereed to as traffic shaping or policing.

Quality of Service (QoS) refers to the capability of a network to provide better service to selected network traffic over various technologies, including Frame Relay, Asynchronous Transfer Mode (ATM), Ethernet and 802.1 networks, SONET, and IP-routed networks that may use any or all of these underlying technologies. The primary goal of QoS is to provide priority including dedicated bandwidth, controlled jitter and latency (required by some real-time and interactive traffic such as Video and Voice), and improved loss characteristics.

This in principle is quite simple. As internet packet traffic moves over the same network as all other traffic, and if it looks like there are too many packets to get all the voice, video ect through without missing a bit, packets are discarded until there is room for the QoS preferred traffic.  Similarly Cisco backbone routers offer packet discard policies, so the operator of the router can decide which types of traffic will suffer lost packets as the router approaches congestion.

Cisco define QoS handling in four steps. Classification, Pre-Queuing, Queuing and Scheduling and Post Queuing. QoS can be configured to use either Resource Reservation Protocol (RSVP) or DiffServ Code Point (DSCP)

Many times low-speed links present an issue for smaller packets.

For example, the serialisation delay of a 1500-byte packet on a 56-kbps link is 214 milliseconds. If a voice packet were to get behind this big packet, the delay budget for voice would be exceeded even before the packet left the router! Link fragmentation and interleave allow this large packet to be segmented into smaller packets interleaving the voice packet. Interleaving is as important as the fragmentation. There is no reason to fragment the packet and have the voice packet go behind all the fragmented packets.

Serialisation delay is the time that it takes to put a packet on the link.

For example;

Packet size: 1500-byte packet * 8 bits/byte = 12,000 bits
Line rate: 56,000 bps

Result: 12,000 bits/56,000bps = .214 sec or 214 msec
      

What is causing the delay? 50 - 70 milliseconds is a typical UK ping time when going between national backbones. Most of this delay cannot be avoided.

Speed of Light:  The speed of light in a fiber optic cable works out to 10 milliseconds per thousand miles, for a ping time (due to the speed of light) of 50 milliseconds on a UK to USA Atlantic trunk fiber link.  Remember that long distance routes are not normally "line of sight", so the distance may be much further than you think, especially with overseas connections.

Router in and out time: Routers receive packets before forwarding them.  If a router is sending a typical MTU 1500 byte packet at 1.5 megabits/sec the time from the first bit to the last bit is 7.7 milliseconds.  If the router is storing packets waiting to send them, then the delay time increases.  This is the reason the measured Global Internet ping time varies.

Congestion Avoidance:  TCP assumes that all packet loss is caused by congestion and responds by reducing the transmission rate.

Slow Start: When a TCP connection starts (or re-starts if more than one packet has been lost) it sends one packet, waits for the acknowledgment, then sends 2, then 4…and ramps up its transmission pace. Each step in the ramp consumes a round trip delay. Remember, TCP works on the principle of acknowledging every packet: SYN, SYN-ACK, ACK. Once the window, session and transmission speed has been agreed and successful transmission has occurred, the connection is renegotiated as speed may improve.

Data Acknowledgements:  The TCP receiver sends an acknowledgment to the sender whenever a segment of information is received. The sender does not assume any data is lost until a multiple of round trip time has elapsed without receiving an acknowledgment, or until it has received multiple duplicate acknowledgments.

Window Size:  TCP can only send a certain amount of data before it must stop transmitting and wait for an acknowledgment. That amount of data is called the window size. The standard window size in TCP is limited to 64 kilobytes.  RFC1323 allows larger windows, but it as in all networks, you are as fast as your weakest link.

When you factor all of the above, it gives a new perspective on why  the internet is subject to such variability in performance.  If you can experience zero packet loss, your performance rises.

No comments:

Post a Comment