Difference between revisions of "FAQ network"
Thedude0001 (Talk | contribs | merge | delete) (wicification, typos and grammar) |
|||
Line 1: | Line 1: | ||
− | + | =Network speed: what you should know before asking questions= | |
by Froenchenko Leonid, <a href="lfroen@gmail.com">lfroen@gmail.com</a><br> | by Froenchenko Leonid, <a href="lfroen@gmail.com">lfroen@gmail.com</a><br> | ||
− | + | ==Preface== | |
The purpose of this document is to clarify different issues regarding network | The purpose of this document is to clarify different issues regarding network | ||
speed that pops up from time to time in amule forum. Generally speaking, there're several reasons for questions about "amule & network": | speed that pops up from time to time in amule forum. Generally speaking, there're several reasons for questions about "amule & network": | ||
<ul> | <ul> | ||
<li>Speed reported by amule doesn't match provider given rate</li> | <li>Speed reported by amule doesn't match provider given rate</li> | ||
− | <li> | + | <li>Poor performance of amule itself or another network application on the same computer</li> |
<li>What are key factors influencing network performance while amule is running | <li>What are key factors influencing network performance while amule is running | ||
</li> | </li> | ||
Line 16: | Line 16: | ||
FAQ". <br> | FAQ". <br> | ||
− | + | ==Network speed - how much is it ?== | |
While talking about network speed, people are using "bps" units, which mean | While talking about network speed, people are using "bps" units, which mean | ||
"bit per second". The reason for <i>bit</i> rather that <i>byte</i> is pretty | "bit per second". The reason for <i>bit</i> rather that <i>byte</i> is pretty | ||
Line 24: | Line 24: | ||
in "bytes per second". However, this convention is not widely accepted. Particularly, organizations like IETF and IEEE are stick to original "bps".<br> | in "bytes per second". However, this convention is not widely accepted. Particularly, organizations like IETF and IEEE are stick to original "bps".<br> | ||
− | + | ==Prefixes== | |
− | Since invention, networks made quite a progress, and now we have networks | + | Since their invention, networks made quite a progress, and now we have networks |
− | that transfers | + | that transfers thousands and millions bits and more bits per second. For marking |
those speeds, prefixes <i>"kilo"</i>, <i>"mega"</i>, <i>"giga"</i>, <i>"tera"</i> | those speeds, prefixes <i>"kilo"</i>, <i>"mega"</i>, <i>"giga"</i>, <i>"tera"</i> | ||
− | etc. are used. It is <u>common mistake</u> to think that values | + | etc. are used. It is a <u>common mistake</u> to think that values with those prefixes are the same as in computer science, i.e. powers of 2. The truth is that, for historical reasons, prefixes in networking have a decimal base, and not a binary one. |
<table cellpadding="2" cellspacing="2" border="1" width="100%" | <table cellpadding="2" cellspacing="2" border="1" width="100%" | ||
Line 97: | Line 97: | ||
</table> | </table> | ||
<br> | <br> | ||
− | As you can from table above the error in calculation is about 5% when prefix | + | As you can see from the table above the error in calculation is about 5% when the prefix |
− | is incorrectly interpreted. Please | + | is incorrectly interpreted. Please note that the speed your provider tells |
you is "speed in network", i.e. calculated on decimal base. <br> | you is "speed in network", i.e. calculated on decimal base. <br> | ||
− | For example when provider tells you that your link is "ADSL 256/128" you | + | For example when your provider tells you that your link is "ADSL 256/128" you |
should understand that he means 256000/128000 bps. Which means, that you have | should understand that he means 256000/128000 bps. Which means, that you have | ||
64000/16000 bytes per second speed in your link.<br> | 64000/16000 bytes per second speed in your link.<br> | ||
− | + | ==Protocol overhead - what is it about== | |
When amule is running, it constantly "talks" with other "mules" and servers. | When amule is running, it constantly "talks" with other "mules" and servers. | ||
This data exchange is needed to identify itself, request information about | This data exchange is needed to identify itself, request information about | ||
available sources and files, perform searches and so on. Since this information | available sources and files, perform searches and so on. Since this information | ||
− | + | has no use for the user itself, it's called "overhead" i.e. inevitable addition | |
to the data you actually want to upload or download. Amule calls this "<i>connection | to the data you actually want to upload or download. Amule calls this "<i>connection | ||
− | overhead</i>". However, the number amule presents, includes only size of actual | + | overhead</i>". However, the number amule presents, includes only the size of the actual |
− | data that amule itself sending to the network stack. Later, this data is | + | data that amule itself is sending to the network stack. Later, this data is |
− | sent down to the net with more overhead - now of network protocols. How | + | sent down to the net with more overhead - now of network protocols. How much |
− | is it - lets see in the next section.<br> | + | is it - lets see that in the next section.<br> |
− | + | ==Network overhead== | |
First of all - we're talking about IPv4 network. Once upon a time, there | First of all - we're talking about IPv4 network. Once upon a time, there | ||
was only one type of IP network. Now there's 2 - IP version 4, the old | was only one type of IP network. Now there's 2 - IP version 4, the old | ||
Line 124: | Line 124: | ||
is 20 bytes. Header can have optional parts (each 4 bytes) and it's up to | is 20 bytes. Header can have optional parts (each 4 bytes) and it's up to | ||
your provider - for example my add 1 option dword.<br> | your provider - for example my add 1 option dword.<br> | ||
− | When talking to other thing on ed2k network, amule uses | + | When talking to other thing on ed2k network, amule uses the widely known TCP protocol. |
− | UDP also used, but in | + | UDP is also used, but in much smaller scale. As the reader might know, TCP is a reliable protocol, i.e. it's guaranteed that data which sent from one side will arrive on the other or an error will be reported. In order to achieve this, TCP send its own data in addition to the actual transfer. This data includes TCP client initial negotiation, checksums, sequence numbers and acknowledgments. All this is in the <i>TCP header</i> which is added to each packet sent. The size of this header |
is 20 bytes minimum. While being small overhead for large bulk transfer, it | is 20 bytes minimum. While being small overhead for large bulk transfer, it | ||
can take significant part of bandwidth when small amounts of data are being | can take significant part of bandwidth when small amounts of data are being | ||
exchanged. <u>This is exactly what happens on source discovery part of amule</u>. | exchanged. <u>This is exactly what happens on source discovery part of amule</u>. | ||
− | Our client is trying to establish connection and negotiate with large number | + | Our client is trying to establish a connection and negotiate with a large number |
of other clients. Doing this, amule opens new TCP connections <u><i>all the | of other clients. Doing this, amule opens new TCP connections <u><i>all the | ||
− | time</i></u>. The amount of those connections is controlled by <i>"Maximum | + | time</i></u>. The amount of those connections is controlled by the <i>"Maximum |
− | number of connections in 5 seconds"</i> setting in preferences. | + | number of connections in 5 seconds"</i> setting in the preferences. A typical number |
is about 100. Each TCP connection results in at least 3 packets traveling | is about 100. Each TCP connection results in at least 3 packets traveling | ||
− | the net - one is SYN packet, i.e. connection request, and one ACK or RST | + | the net - one is a SYN packet, i.e. connection request, and one an ACK or a RST |
− | when connection is accepted or refused, and SYN+ACK to establish session. | + | when the connection is accepted or refused, and SYN+ACK to establish the session. |
− | There's more overhead of DNS queries when address is resolved, retries when | + | There's more overhead of DNS queries when an address is resolved, retries when a |
host doesn't reply and so on.<br> | host doesn't reply and so on.<br> | ||
− | + | ===On low level:=== | |
− | After passing TCP and IP layers | + | After passing TCP and IP layers packets go down to the network interface |
− | driver. The kind of this driver | + | driver. The kind of this driver depends on the way your computer is connected to the internet. For simplicity sake we will assume that this computer is connected to the ISP directly, i.e. you have no LAN (or switch or router) between. |
Common setups that I'm aware of:<br> | Common setups that I'm aware of:<br> | ||
<ol> | <ol> | ||
<li>Analog modem, connected to telephone line (ISDN modem falls in this category too)</li> | <li>Analog modem, connected to telephone line (ISDN modem falls in this category too)</li> | ||
− | <li>Cable modem, connected through ethernet, ISP gives you IP address through DHCP</li> | + | <li>Cable modem, connected through ethernet, ISP gives you an IP address through DHCP</li> |
<li>Cable modem, connected through ethernet, ISP requires you to configure PPPoE or PPTP tunnel</li> | <li>Cable modem, connected through ethernet, ISP requires you to configure PPPoE or PPTP tunnel</li> | ||
− | <li>ADSL modem, connected through ethernet. You must have PPPoE or PPTP tunnel</li> | + | <li>ADSL modem, connected through ethernet. You must have a PPPoE or PPTP tunnel</li> |
<li>Variation of above - modem connected to PC by USB. </li> | <li>Variation of above - modem connected to PC by USB. </li> | ||
</ol> | </ol> | ||
− | In each of above setups | + | In each of above setups there are different protocols in use, and different headers added to transmitted packets. But there's one important thing to note: <u><i>ethernet frames traveling between cable/ADSL modem and PC don't reach the ISP</i></u>. And consequently they are not counted in rate calculations. PPPoE and |
− | PPTP headers, on the contrary <u><i> | + | PPTP headers, on the contrary <u><i>do reach the ISP</i></u>. Whether or not |
your particular provider includes them in rate calculations I obviously have | your particular provider includes them in rate calculations I obviously have | ||
− | no idea. For this reason I will exclude those headers from my calculations. | + | no idea about. For this reason I will exclude those headers from my calculations. |
If you think that your ISP includes it, add 4 bytes to the size of each packet.<br> | If you think that your ISP includes it, add 4 bytes to the size of each packet.<br> | ||
− | + | ===Example:=== | |
− | Let's see how | + | Let's see how much network overhead we have on a typical network. Our connection |
− | is cable modem connected | + | is a cable modem connected via an ethernet link to a PC directly (no router between them). |
In this setup we have IPv4 packets sent over ethernet. <br> | In this setup we have IPv4 packets sent over ethernet. <br> | ||
− | Lets say we have 10 new | + | Lets say we have 10 new connections opened each second, and all are being accepted |
− | (successfully established TCP session). This alone | + | (successfully established TCP session). This alone sums up to (I'm counting data |
going up - from my computer to the net):<br> | going up - from my computer to the net):<br> | ||
<br> | <br> | ||
− | <i>10 connection * 2 packets * (20 bytes of TCP + 20 bytes of IPv4) = 800 bytes. </i><br> | + | <i>10 connection * 2 packets * (20 bytes of TCP + 20 bytes of IPv4) = 800 bytes of overhead. </i><br> |
<br> | <br> | ||
− | This | + | This means that we are starting with 1.16*8 Kbps of "<i>invisible"</i> |
overhead caused by the very way the network works. Now, let's assume that | overhead caused by the very way the network works. Now, let's assume that | ||
− | after each connection is established our amule sends something to other side | + | after each connection is established our amule sends something to the other side |
and waits to receive an answer.<br> | and waits to receive an answer.<br> | ||
<br> | <br> | ||
− | <i>10 connections * (1 packet of data + 1 ACK)*(20 bytes of TCP + 20 bytes of IPv4) = 800</i><i> bytes. <br> | + | <i>10 connections * (1 packet of data + 1 ACK)*(20 bytes of TCP + 20 bytes of IPv4) = 800</i><i> bytes of overhead. <br> |
<br> | <br> | ||
Total of 800 bytes + 800 bytes = 1600 bytes per second = 6400 bps = 6.4 Kbps<br> | Total of 800 bytes + 800 bytes = 1600 bytes per second = 6400 bps = 6.4 Kbps<br> | ||
</i><br> | </i><br> | ||
What we have here is 6.4 Kbps of network overhead alone. Taking into account | What we have here is 6.4 Kbps of network overhead alone. Taking into account | ||
− | that amule | + | that amule has other data to send (uploads) and it is not the only network |
− | application running we will have following picture | + | application running we will have the following picture: Most chances that your |
link to provider is not that fast. Amule will <u><i>try</i></u> to open | link to provider is not that fast. Amule will <u><i>try</i></u> to open | ||
− | 10 connections per second and will <u><i>try</i></u> to upload on specified | + | 10 connections per second and will <u><i>try</i></u> to upload on the specified |
− | speed. | + | speed. Your operating system will share all available bandwidth between those and between amule and other network applications (browser for example). Actual results will vary depending on specific OS settings.<br> |
− | + | ==ACK bottleneck== | |
− | In all calculations above there was one assumption - zero download. But | + | In all calculations above there was one assumption - zero download. But downloading is what amule was built for. So let's examine how the overhead |
− | above | + | above affects your downloading speed. The answer is in TCP protocol. When TCP is sending |
− | data, it requires from other side to acknowledge the reception. So | + | data, it requires from the other side to acknowledge the reception. So if client |
− | A sending data to client B by TCP, B | + | A is sending data to client B by TCP, B has to send a special ACK packets to A which tells B "ok, I got it". If, however, A doesn't receive the ACK packets |
− | which tells B "ok, I | + | |
in time, he will assume that either packet is lost. So, without going deeply | in time, he will assume that either packet is lost. So, without going deeply | ||
into TCP specification: <u><i>if B fails to send ACK to A, as a result A will | into TCP specification: <u><i>if B fails to send ACK to A, as a result A will | ||
transmit slower</i></u>. <br> | transmit slower</i></u>. <br> | ||
− | Now let's see situation in amule. We saw in previous chapter, that uplink | + | Now let's see the situation in amule. We saw in the previous chapter, that the uplink |
− | stream is congested by | + | stream is congested by connection requests and uploads. As a result, there's a |
− | good chance that ACK | + | good chance that ACK packets for a file we are downloading <u><i>will not be sent |
− | on time</i></u>. | + | on time</i></u>. The remote party will notice this and slow down. This is one |
− | more reason why upstream better not be too congested.<br> | + | more reason why the upstream should better not be too congested.<br> |
− | + | ==Is there something I can do ?== | |
− | OK, now | + | OK, now that you understood why your network is so slow while amule is |
− | running you | + | running you will maybe look for a way to fix this. The answer in 2 words: "rate limit". |
The first thing you should do is to assign realistic rate limits in amule | The first thing you should do is to assign realistic rate limits in amule | ||
− | itself. If you have | + | itself. If you have a uplink rate of 128 Kbps don't set amules upload limit to |
16 (kilobytes per second) just because 128/8=16.<br> | 16 (kilobytes per second) just because 128/8=16.<br> | ||
− | + | A better, but far more complicated solution is to use the QoS and packet scheduling | |
− | services of your OS. For example, you can give higher priority to ACK packets | + | services of your OS. For example, you can give a higher priority to ACK packets |
− | to solve above "ACK bottleneck" problem. The QoS topic, however, is beyond | + | to solve the above mentioned "ACK bottleneck" problem. The QoS topic, however, is beyond |
scope of this article.<br> | scope of this article.<br> | ||
<br> | <br> | ||
− | + | ==Router (switch, home network): is there any difference ?== | |
− | When cable coming from your ISP is connected to some switching or routing | + | When the cable coming from your ISP is connected to some switching or routing |
device, which in turn is connected to several PC's, bandwidth is shared between | device, which in turn is connected to several PC's, bandwidth is shared between | ||
− | them. So, having N computers connected, ideal device would simply provide | + | them. So, having N computers connected, an ideal device would simply provide |
− | each one of them with 1/N of total bandwidth. | + | each one of them with 1/N of the total bandwidth. The situation may vary in real |
life, and your particular device may have different idea about fairness. Since | life, and your particular device may have different idea about fairness. Since | ||
− | you're not going to have hardware specs | + | you're not going to have the hardware specs of your router chipset the only |
advice here is "try and see yourself". <br> | advice here is "try and see yourself". <br> |
Revision as of 17:45, 27 February 2005
Network speed: what you should know before asking questions
by Froenchenko Leonid, <a href="lfroen@gmail.com">lfroen@gmail.com</a>
Preface
The purpose of this document is to clarify different issues regarding network speed that pops up from time to time in amule forum. Generally speaking, there're several reasons for questions about "amule & network":
- Speed reported by amule doesn't match provider given rate
- Poor performance of amule itself or another network application on the same computer
- What are key factors influencing network performance while amule is running
Intended audience for this document are users who want to get better understanding of network functionality in general and in practical implication to amule functionality.
This page, however, is not to be seen as comprehensive general purpose "Network
FAQ".
Network speed - how much is it ?
While talking about network speed, people are using "bps" units, which mean
"bit per second". The reason for bit rather that byte is pretty
match historical, but also have engineering motivation behind. This motivation
comes from the fact, that not all networks in the world are transferring bytes.
There's also convention to use capital "B" in "Bps" when speed is marked
in "bytes per second". However, this convention is not widely accepted. Particularly, organizations like IETF and IEEE are stick to original "bps".
Prefixes
Since their invention, networks made quite a progress, and now we have networks that transfers thousands and millions bits and more bits per second. For marking those speeds, prefixes "kilo", "mega", "giga", "tera" etc. are used. It is a common mistake to think that values with those prefixes are the same as in computer science, i.e. powers of 2. The truth is that, for historical reasons, prefixes in networking have a decimal base, and not a binary one.
Prefix |
meaning in computers |
meaning in networks |
difference, %% |
---|---|---|---|
K (kilo) |
2^10 = 1024 |
10^3 = 1000 |
2% |
M (mega) |
2^20 = 1,048,576 |
10^6 = 1,000,000 |
5% |
G (giga) |
2^30 = 1,073,741,624 |
10^9 = 1,000,000,000 |
7% |
T (tera) |
2^40 = 1,099,511,627,776 |
10^12 = 1,000,000,000,000 |
9% |
As you can see from the table above the error in calculation is about 5% when the prefix
is incorrectly interpreted. Please note that the speed your provider tells
you is "speed in network", i.e. calculated on decimal base.
For example when your provider tells you that your link is "ADSL 256/128" you
should understand that he means 256000/128000 bps. Which means, that you have
64000/16000 bytes per second speed in your link.
Protocol overhead - what is it about
When amule is running, it constantly "talks" with other "mules" and servers.
This data exchange is needed to identify itself, request information about
available sources and files, perform searches and so on. Since this information
has no use for the user itself, it's called "overhead" i.e. inevitable addition
to the data you actually want to upload or download. Amule calls this "connection
overhead". However, the number amule presents, includes only the size of the actual
data that amule itself is sending to the network stack. Later, this data is
sent down to the net with more overhead - now of network protocols. How much
is it - lets see that in the next section.
Network overhead
First of all - we're talking about IPv4 network. Once upon a time, there
was only one type of IP network. Now there's 2 - IP version 4, the old
we all know; and IP version 6 - the new one. ED2K protocol by design, is
unable to talk over IPv6 network, so users who have it (in Japan and China
for example) will not be able to connect "as is". Using IPv4 means, that each
packet (TCP, UDP, ICMP) will have IPv4 header. The minimum size of this header
is 20 bytes. Header can have optional parts (each 4 bytes) and it's up to
your provider - for example my add 1 option dword.
When talking to other thing on ed2k network, amule uses the widely known TCP protocol.
UDP is also used, but in much smaller scale. As the reader might know, TCP is a reliable protocol, i.e. it's guaranteed that data which sent from one side will arrive on the other or an error will be reported. In order to achieve this, TCP send its own data in addition to the actual transfer. This data includes TCP client initial negotiation, checksums, sequence numbers and acknowledgments. All this is in the TCP header which is added to each packet sent. The size of this header
is 20 bytes minimum. While being small overhead for large bulk transfer, it
can take significant part of bandwidth when small amounts of data are being
exchanged. This is exactly what happens on source discovery part of amule.
Our client is trying to establish a connection and negotiate with a large number
of other clients. Doing this, amule opens new TCP connections all the
time. The amount of those connections is controlled by the "Maximum
number of connections in 5 seconds" setting in the preferences. A typical number
is about 100. Each TCP connection results in at least 3 packets traveling
the net - one is a SYN packet, i.e. connection request, and one an ACK or a RST
when the connection is accepted or refused, and SYN+ACK to establish the session.
There's more overhead of DNS queries when an address is resolved, retries when a
host doesn't reply and so on.
On low level:
After passing TCP and IP layers packets go down to the network interface
driver. The kind of this driver depends on the way your computer is connected to the internet. For simplicity sake we will assume that this computer is connected to the ISP directly, i.e. you have no LAN (or switch or router) between.
Common setups that I'm aware of:
- Analog modem, connected to telephone line (ISDN modem falls in this category too)
- Cable modem, connected through ethernet, ISP gives you an IP address through DHCP
- Cable modem, connected through ethernet, ISP requires you to configure PPPoE or PPTP tunnel
- ADSL modem, connected through ethernet. You must have a PPPoE or PPTP tunnel
- Variation of above - modem connected to PC by USB.
In each of above setups there are different protocols in use, and different headers added to transmitted packets. But there's one important thing to note: ethernet frames traveling between cable/ADSL modem and PC don't reach the ISP. And consequently they are not counted in rate calculations. PPPoE and
PPTP headers, on the contrary do reach the ISP. Whether or not
your particular provider includes them in rate calculations I obviously have
no idea about. For this reason I will exclude those headers from my calculations.
If you think that your ISP includes it, add 4 bytes to the size of each packet.
Example:
Let's see how much network overhead we have on a typical network. Our connection
is a cable modem connected via an ethernet link to a PC directly (no router between them).
In this setup we have IPv4 packets sent over ethernet.
Lets say we have 10 new connections opened each second, and all are being accepted
(successfully established TCP session). This alone sums up to (I'm counting data
going up - from my computer to the net):
10 connection * 2 packets * (20 bytes of TCP + 20 bytes of IPv4) = 800 bytes of overhead.
This means that we are starting with 1.16*8 Kbps of "invisible"
overhead caused by the very way the network works. Now, let's assume that
after each connection is established our amule sends something to the other side
and waits to receive an answer.
10 connections * (1 packet of data + 1 ACK)*(20 bytes of TCP + 20 bytes of IPv4) = 800 bytes of overhead.
Total of 800 bytes + 800 bytes = 1600 bytes per second = 6400 bps = 6.4 Kbps
What we have here is 6.4 Kbps of network overhead alone. Taking into account
that amule has other data to send (uploads) and it is not the only network
application running we will have the following picture: Most chances that your
link to provider is not that fast. Amule will try to open
10 connections per second and will try to upload on the specified
speed. Your operating system will share all available bandwidth between those and between amule and other network applications (browser for example). Actual results will vary depending on specific OS settings.
ACK bottleneck
In all calculations above there was one assumption - zero download. But downloading is what amule was built for. So let's examine how the overhead
above affects your downloading speed. The answer is in TCP protocol. When TCP is sending
data, it requires from the other side to acknowledge the reception. So if client
A is sending data to client B by TCP, B has to send a special ACK packets to A which tells B "ok, I got it". If, however, A doesn't receive the ACK packets
in time, he will assume that either packet is lost. So, without going deeply
into TCP specification: if B fails to send ACK to A, as a result A will
transmit slower.
Now let's see the situation in amule. We saw in the previous chapter, that the uplink
stream is congested by connection requests and uploads. As a result, there's a
good chance that ACK packets for a file we are downloading will not be sent
on time. The remote party will notice this and slow down. This is one
more reason why the upstream should better not be too congested.
Is there something I can do ?
OK, now that you understood why your network is so slow while amule is
running you will maybe look for a way to fix this. The answer in 2 words: "rate limit".
The first thing you should do is to assign realistic rate limits in amule
itself. If you have a uplink rate of 128 Kbps don't set amules upload limit to
16 (kilobytes per second) just because 128/8=16.
A better, but far more complicated solution is to use the QoS and packet scheduling
services of your OS. For example, you can give a higher priority to ACK packets
to solve the above mentioned "ACK bottleneck" problem. The QoS topic, however, is beyond
scope of this article.
Router (switch, home network): is there any difference ?
When the cable coming from your ISP is connected to some switching or routing
device, which in turn is connected to several PC's, bandwidth is shared between
them. So, having N computers connected, an ideal device would simply provide
each one of them with 1/N of the total bandwidth. The situation may vary in real
life, and your particular device may have different idea about fairness. Since
you're not going to have the hardware specs of your router chipset the only
advice here is "try and see yourself".