Kamis, 15 Mei 2008

ADSL THEORY





Basics

Human hearing covers about 20kHz; voice range is variable but 95% of verbal communication happens in a relatively limited band of 300-4000Hz. The telephone networks of the world use 0-4000Hz, that covers human speech frequencies and signaling with in the phone network. Your telephone line is a pair of solid copper lines which has a frequency range available, basically only limited by technology and attenuation.

ADSL leaves some safety space between itself and other common telephone network protocols and then uses the available frequency bandwidth. This translates to 28kHz to 1.1MHz for ADSL1/2 and 28kHz to 2.2MHz for ADSL2+.

Attenuation

Attenuation, in a communications sense, is the energy loss of signal transmission through a given medium. Simply put, if you talk normally I can hear you when you're 10m away but I can't hear you at 100m unless you shout.

In an ADSL meaning there are two separate and distinct versions. SIGNAL attenuation is what's reported for a current connection (e.g. from your modem) and an average of each individual bucket in the connection, it changes continuously. LINE attenuation is what's reported from a line SQ (Service Qualification) and is measured at a set frequency and signal strength by your providers DSLAM, it can be used to make speed guesstimations and is a good indicator of line health.

To clarify,
LINE attenuation (reported by DSLAM) is about wire health
SIGNAL attenuation (reported by modem) is about connection health and is only useful when considered with SNR margins, power levels and connection speed.

There's a bit of a twist with attenuation, it increases with frequency; the higher the frequency the higher the attenuation. Sounds strange but makes sense; when someone goes past in their lowered Commodore with a bad-ass stereo all you can hear is the doof-doof of the subwoofers. You don't hear the singing, guitars, etc which are a higher frequency. The volume levels are generally the same (the people in the car hear a bit more than just doof-doof) it's just the higher frequencies are being attenuated faster than the lower frequencies.

Attenuation is also caused by line joins (which can also cause noise). If you're talking to someone 5m away they can hear you fine, if they're 5m away but around a corner in a different room then you have to talk louder. It takes energy to turn a signal around a corner.

Signal attenuation varies and even for the same line is different at different points of time. This does not apply to line attenuation. Let's see why.

Line attenuation is measured for a preset group of parameters. This includes the noise frequency distribution. This distribution is static for line attenuation measurement. Therefore power levels for each of 255 channels (buckets) and overall power level are also static. There is no need to vary them.

In real situation noise frequency distribution is highly volatile. If channels say from 130 till 145 get most severely affected by some frequency dependent noise (your neighbour turned mower on) then this amounts from modem point of view to the change in line characteristics, namely line attenuation. To put it precisely, the shape of the curve (which describes how attenuation depends on frequency) changes.

Before the change: just gradual increase of attenuation depending on the frequency. After the change: gradual increase from channel 1 to 129, sudden and abrupt increase from 130 to 145, then partial drop down to usual levels with subsequent continuing gradual increase from 145 till 255. (In practice increase most likely will be not that sudden unless some very special equipment is used).

Modem will try to overcome this hurdle, if it can, by increasing its transmission power for these 15 affected channels. Which again, is the same thing the modem would have done if the line attenuation would suddenly increase by itself (which in real life it cannot) for the frequency range where the channels 130-145 are. So from modem point of view line conditions are volatile and change over time.

Noise

If you're at a party and you're talking to someone then you have to talk louder to make yourself heard over the background noise.

ADSL is exactly the same although the noise is electrical. Noise can be generated by other telephony devices on the line (alarms, phones, faxes, etc) or by electromagnetic pulses (EMP, the only cool thing about a nuclear bomb).

Noise generated by devices can generally be dealt with using good quality line filters or a central splitter in your home. They simply stop any signals outside the 0-4000Hz telephone band from passing through either way. There are some cases where devices external to your home may be causing device noise, they are very rare and can generally be identified by Telstra performing line tests.

EMP is a little more hairy, bit of physics, two ideas which are related. When you pass an electrical charge through a wire there will be an electromagnetic field (basically an EMP) created around the wire. When an electromagnetic field travels over a wire it creates an electrical signal on the wire. Basically, if you had two wires next to each other you could apply an electrical signal to wire A and you could record a weaker version of the signal on wire B. EMP can be created by any electrical source such as fridge motors, car starter motors, PC power supplies, light globes, etc, etc. This is the idea behind crosstalk which we'll cover later.

Frysie's red hot tips for reducing line noise :
o Make sure the unshielded receiving wire (i.e. wall to modem phone cable) is as small as possible
o Use the first point in the house (generally the one closest to the front of the house)
o Make sure there's no devices on the line causing noise (unplug everything else)
o Keep the modem and line away (1m+) from anything else that uses power
o Home alarms generate a lot of line noise; disconnect it or get a central splitter

SNR Margins

When your modem attempts to negotiate ADSL it looks at the line and basically sees attenuation and noise put together. Attenuation gradually increases as frequency increases and noise is a random pattern of low level interference in the background.

It's very similar to a conversation at a party and it's dealt with in the same way; we naturally account for both distance from the other person and the amount of background noise. When we do we don't just talk loud enough to be heard, we speak a bit louder waiting for the idiot with the stupid, loud laugh to start up again. We add a bit extra on to make sure we're louder than the average change in background noise. This is a SNR margin.

There are three SNR margins which can be configured on the DSLAM,
o minimum SNR
o target SNR
o maximum SNR
What effect they have is dependent on the bucket management schema. For all of them; the target SNR margin must be achieved to get ADSL sync and power levels will be increased if SNR margin drops below the minimum and decreased if it's above the maximum. If the SNR margin drops below the minimum and the modem can't increase power levels then ADSL will drop.

When the modem inspects the line and gets a reading on the accumulated attenuation and noise it will take away the target SNR margin, which is set on the ISP side of things. What remains is the available spectrum to ADSL, keep in mind that there are limits to the amount of power ADSL is allowed to transmit hence a limited spectrum.

The problem is every party is different, one might be a Sunday chill out session which is relatively quiet, the other a bucks nights with loud tunes, shouting, debauchery, etc. Lines are the same - the SNR margin that is required is different for each line but the configuration is static.

What's the problem? Just make it as big as possible you say? There's a limit to how loud you can shout and ADSL is the same, the difference is humans don't really put any additional information in extra volume (the opposite generally). ADSL basically uses the strength of the signal to implement nuances or tones which carries the data, i.e. the more received volume the more information can be transmitted. On average, every 3dB of SNR margin takes 0.5Mb to 1Mb of downstream data rate so there is a balancing act.

It's basically an ISP problem but there are a couple ways to deal with it; don't go for higher speeds and introduce large SNR margins, or, if higher speeds are wanted introduce a range of configurations which users can jump between to establish their own speed v's stability balance.

There are some modems which allow the tweaking of SNR margins from the client side, I wouldn't recommend using them, it just makes your ISPs life harder on a few fronts.

Buckets

So the modem has an idea of the quality of the line, it inspects it over discrete
frequency ranges. ADSL is not a single modem, it's actually a whole heap of them (255 on ADSL1/2, 512 on ADSL2+) running in parallel. Each of these individual frequency ranges acts as it's own independent mini-modem; they can be called buckets, bins, carriers, bearers, and sometimes they'll be called modems just to confuse the issue. I'll refer to them as buckets throughout this document.

If we take ADSL1 then these buckets look VERY similar to an old analogue dialup modem. 56K was just a trick of digital ISDN lines at the ISP end, if you dialed up to a friends modem you would get 33.6/33.6 maximum, it's actually a imposed limit, the theoretical is about 36k. This 36k potential (see Shannon's Theorem) is over a 4kHz spectrum.

Some quick maths, ADSL1 is 28kHz to 1.1MHz, that's 1.072MHz of bandwidth, divide by 255 buckets, that's 4.2kHz, let's assume 200Hz of margin between each bucket, that's 4kHz of frequency per bucket. 255 buckets by 36k potential comes to 9.18M, strange that 8Mb downstream plus 1Mb upstream equals 9Mb right?

These buckets and their frequency ranges are defined as part of the ADSL specification. They are independent modems so they can be used for downstream, upstream, white space or management signaling. ADSL1, 2, 2+ specifies how many buckets and the data stream in them is formatted. There are then different annexes in each ADSL type which specifies how management signaling occurs and how the buckets are allocated. This is cool but moving around the standard bucket allocations (e.g Annex M, SADSL) can cause crosstalk issues.

Bucket Allocation

Just to give an example of bucket allocation we'll take a look at ADSLv1 G922.1/Annex A. There are 255 available buckets;
o The first few are used for DSL signalling and bucket negotation, etc plus white space (not sure of specifics).
o 8 to 32 are used for upstream
o 32 to 40 is white space to prevent crosstalk
o 41 to 255 is downstream

If you go for a bit of a play you will find many modems will actually report the bucket allocation. Each bucket is capable of carrying a number of bits (covered in SNR margins), 0 to 15 (may be in hexadecimal 0 to F). If you find the information grab it and put it into Excel, spit a graph out the other side. It will generally illustrate attenuation and noise quite clearly, on the overall graph there will gradual fall in the number of buckets per bin (attenuation increase as the frequency increases) and there may be a couple noise spikes at certain frequencies where the amount of carried data is significantly reduced.

Bucket Negotiation

The modems will negotiate between themselves what their available ADSL annexes are and decide on the best annex based on the line conditions. They will then simultaneously inspect each bucket and decide how much data can be fitted through each one based on the SNR margin and bucket management algorithm.

ADSL uses a process called quadrature amplitude modulation (QAM) to transmit symbols instead of just bits by making shifts in amplitude and phase. The remote end receives the varying signal stream and basically makes a best guess at what the phase and amplitude of the signal was at the receive interval. To see a graphical representation of this have a look at constellation diagrams.

The louder a modem is the clearer it is to the receiving end what the intended symbol was and the more symbols can be fitted through each bucket, i.e. the number of bits carried in the bucket.

Error Correction

ADSL runs error correction at a two different levels.

Firstly it runs a process called Trellis Modulation (TCM). In a basic way TCM is an algorithm which defines sequences that symbols have to be transmitted in. Say we transmit 1,1,2,3,5,8,13 and the recieving end gets 1,1,2,3,?,8,13, it can recalculate what the missing value is because of what was before and after it. (No, TCM is not the Fibonacci sequence, it was just a nice easy algorithm for an example).

The other common form is called Reed Solomon (R-S) coding which is a form of Forward Error Correction (FEC). It's much easier shown then explained, in a basic sense instead of transmitting the data; 1, 7, 6, 3, it will transmit the data along with the sum, so 1, 7, 6, 3, 17. If anything is dropped from the sequence it can be recalculated from the total.

TCM occurs at a symbol level of things (fairly close to the electrical impulse side) whilst R-S occurs at a data layer so they can and will independently find and resolve problems.

If you ever want to see R-S coding in a real life grab a couple blank CDs and make backups of your favourite music CD. Grab a knife (ask Mum and Dad first kids) and scratch both CDs, in one make a scratch at right angles to the edge of the CD, in the other make a circular scratch parallel to the edge. CD's are burnt in a spiral inside to outside, because of the R-S coding on the CD the circle scratch will be dead, you've scratched over an entire (probably many) R-S group. The one that's scratched at right angles has simply taken out individual bits of data from each group which can then recalculated from the rest of the group.

Interleaving

So we're running our Reed Solomon (R-S) encoding and everything is going along swimmingly, lets say we have three groups of R-S data ready to send,
1 : 11, 12, 13, 36
2 : 21, 22, 23, 66
3 : 31, 32, 33, 96
And we transmit it over the wire,
11, 12, 13, 36, 21, 22, 23, 66, 31, 32, 33, 96
But there's a burst of noise in the transmission and the receiver gets,
11, 12, 13, 36, 21, ?, ?, 66, 31, 32, 33, 96
R-S is good, but there's been a code violation (CV also called a cyclic redundancy check (CRC) failure) it can't recover the second group, it needs to be retransmitted.

Interleaving buffers a time sample of data and then mixes it up, so under an interleaved connection the following would be transmitted,
11, 21, 31, 12, 22, 32, 13, 23, 33, 36, 66, 96
With the same burst of noise causing a transmission problem,
11, 21, 31, 12, 22, ?, ?, 23, 33, 36, 66, 96
Once the receiving end unmixes the data it's only lost one value from each group and can recalculate the data.

Interleaving is a catalyst for forward error correction, otherwise, more often than not data needs to be retransmitted. The trade off is that the entire interleaved group needs to be received and unmixed before it can be processed. This introduces latency to the connection equivalent to the time period of interleaved data. If you are attempting to run a fast ADSL connection (i.e. less than 15-20dB of SNR margin) then it's recommended to have interleaving to correct packets affected by impulse noise which is louder than the margin and affects the data stream. Whilst it does introduce latency it also increases the overall throughput of the connection because data doesn't need to be retransmitted.

Crosstalk

This isn't really part of what happens to your connection, it's more to do with design issues faced but it's interesting to the overall picture of things and explains why certain annexes of ADSL are problematic.

You remember in the noise section we were talking about power flowing down a wire creating an EMP and an EMP passing over a wire creates a signal on that wire.

Now when the telephone lines are inside the exchange (and in the ground for that matter) they are tightly bundled together. As an ADSL signal travels down line A then an EMP is created and a signal is generated in the adjacent line B, that's crosstalk or XT. Crosstalk will only occur close to the signal source, whilst the signal is strong, once it's travelled a 100m or so it's lost the power to create a decent EMP.

There are two types of crosstalk dependant on where the XT signal is heard. A DSLAM port talks and the XT signal gets heard by another DSLAM port it's called Near End Crosstalk or NEXT. A DSLAM port talks and the XT signal gets heard by another lines DSL modem it's called Far End Crosstalk or FEXT.

NEXT happens all the time inside the exchanges, it doesn't matter. All the common ADSL annexes listen on 28kHz-138kHz and talk on 138kHz-1.1/2.2MHz, a signal NEXT's at say 432kHz, the port that it crosstalk's to isn't listening to that frequency band.

FEXT is a lot less common and a lot harder to identify. FEXT will only occur on very short lines (less than 250m), the XT signal that is generated is a lot less powerful than the original and it's generally attenuated out before it reaches the DSL modem. In the very rare cases it does get heard by the DSL modem it generally appears as background noise. The only real time it causes issues is if you sync up whilst an adjacent line is down, the adjacent line comes up and the signal is XT'ed and causes an increase in line noise resulting in a drop.

Speeds

OK, the best way to pull together the whole attenuation and noise thing is to have a look at the negotiated speed. Let's assume a normal ADSLv1 connection running Annex A.
o 8198/1024 - high down, high up; low attenuation (short line), low noise.
o 4096/1024 - mid down, high up; attenuated (longer line), low noise (full speed upstream).
o 4096/512 - mid down, mid up; likely low attenuation , high noise levels (from the low upstream speed)
o 2048/512 - low down, mid up; attenuated (lower down speed), high noise levels (low up speed).

Remember, we're talking about line attenuation and not signal attenuation here.

Counters

Ok, so you've got a DSL connection and found this page on your modem with all these weird counters, what do they mean?
o FEC - Forward Error Correction - packets with errors that have been fixed.
o CV or CRC - Code Violation or Cyclic Redundancy Check - packets which have to be retransmitted due to errors
o ECS - Error Corrected Seconds - counter of number of seconds in which a FEC occured
o ES - Errored Seconds - counter of number of seconds in which a CV/CRC occured
o SES - Severely Errored Seconds - counter of number of seconds in which 10 or more CV/CRC occured
o UAS - UnAvailable Seconds - number of seconds that the connection wasn't able to transmit in
o LOS - Loss of Signal Seconds - number of seconds that DSL singalling has been lost

ATM

ADSL is only a physical layer specification, i.e. how the data should be transmitted over the line. ADSL then implements a network layer specification called ATM. ATM is designed as a large switching network run at very high speeds (fibre optic, etc). You find a path through an ATM network via two numbers, a virtual path identifier (VPI) and a virtual circuit identifier (VCI), written as VPI/VCI. Given that ADSL is a point to point network and not large scale switched network it really doesn't matter but both sides have to be listening at the same address. In Australia the traditional ADSL VPI/VCI is 8/35, as a general rule each country or region tends to use its own default values.

PPP

Point to Point Protocol (PPP) is, as it's name suggests, a protocol for establishing a link between two points. In the case of ADSL it's between your modem or PC to our BRAS (Broadband Remote Access Server - the PPP server). PPP isn't technically required for an ADSL connection, the internet could run straight over the ADSL's ATM network. PPP is used on most of ADSL connection because of the legacy of dialup; an authorisation/accounting system is needed and PPP is the defacto standard.

PPP can be run in two different ways and the preferred style is dependant on your ISPs set up. PPPoE is best if they run an ethernet link between the DSLAM and BRAS, PPPoA is better if they are running an ATM network between the DSLAM and BRAS.

Why the difference? Maximum Transmissable Unit (MTU) is the largest individual data packet that can be sent over a network, in the case of Ethernet it's 1500, in the case of ATM it's not limited. What this means is that as the packet passes from ADSL to Ethernet is can exceed Ethernet's MTU and be dropped. By forcing PPPoE your modem forces the packets to stay with in Ethernet's 1500 MTU limit. That said PPPoA is marginally more effiecient with overheads and processing by both ends.

Many people are asking:
- should I use PPPoE or PPPoA
- what MTU is better

Some people are reporting troubles with PPPoA and some with PPPoE. So use whatever works for you, however if you are really in a position to choose, then you will be slightly better off by using PPPoA. As for MTU, set it to 1462 in case you have settled on PPPoA.

So the short answer is: use PPPoA with MTU 1462 bytes.

The long (and much more involved) answer. Part one: PPPoE vs PPPoA.
PPPoE uses one extra eight bytes long header which eats into the payload. PPPoA does not have this header so it has less overhead and each packet can carry more useful data (8 bytes more) which results in slight (around one percent) speed improvement.

The long (and much more involved) answer. Part two: MTU issues.
The default MTU for PPPoA is 1500 bytes. The same default for PPPoE is 1492 bytes (8 bytes less due to increased overhead because of one extra 8 bytes header mentioned above).

Your ADSL modem always talks to DSLAM using ATM with either PPPoE or PPPoA (whatever you have chosen) on top of ATM. DSLAM is in turn connected to a server called BRAS/LNS using either ATM (in case of Telstra Wholesale DSLAMs) of Gigabit Ethernet - GE (in case of iiNET DSLAMs).

If backhaul is ATM based, then DSLAM can process both PPPoE and PPPoA and it can digest both MTU of 1500 bytes for PPPoA and MTU of 1492 bytes for PPPoE. These are the default MTU values so no probs here.

If backhaul is GE based, then DSLAM can still process both PPPoE and PPPoA, however it can digest only MTU of no more than 1492 bytes. If you have chosen PPPoE then 1492 is the PPPoE's default MTU and everything is fine. If you have chosen PPPoA and kept its default MTU equal to 1500 bytes, then you are in trouble unless you lowered MTU to at least 1492 bytes. This is the reason why iiNet recommends PPPoE - less potential issues with MTU exceeding 1492 bytes because iiNet DSLAMs are set to max MTU equal to 1492 bytes for both PPPoE and PPPoA.

The long (and much more involved) answer. Part three: What MTU to choose.

When choosing MTU you should aim at increased speed. So don't think in terms of choosing between 1500 and 1492 bytes MTUs as these values are only relevant when you consider how to avoid the potential trouble when a DSLAM (with GE backhaul) drops your packets with 1500 bytes MTU.

But we are after the increased speed aren’t we? It will be achieved by getting 53 bytes long ATM cells filled better. Which happens when the packet has 1454 bytes MTU for PPPoE and 1462 bytes MTU for PPPoA. PPPoA is itself more efficient for the reason described above. Hence the answer: PPPoA with 1462 bytes MTU.

Glossary

ADSL - Asymmetric Digital Subscriber Line - what this is all about
ATM - Asynchronous Transfer Mode - a network protocol used by ADSL
BRAS - Broadband Remote Access Server - a PPP server
CPE - Customer Premises Equipment - your modem and wiring
DSLAM - Digital Subscriber Line Access Multiplexer - What your modem connects to, generally at a telephone exchange.
PPPOA - Point-to-Point Protocol Over ATM
PPPOE - Point-to-Point Protocol Over Ethernet
PVC - Permanent Virtual Circuit
SDSL - Symmetric DSL - an ADSL link with a 1/1, 2/2, etc speed
SNR - Signal to Noise Ratio - difference between the volume of signal over the volume of noise
ULL - Unbundled Local Loop