# Routing protocols and architectures/Inter-domain routing: peering and transit in the Internet

Traffic within the AS is almost 'free', excluding infrastructure costs (maintenance, administration, electricity, etc.) → ISPs try to convince users to spend most of their time inside the AS.
However, an AS should connect to other ASes for two reasons:
* an AS must be able to reach all the destinations present in the Internet for Metcalfe's law (= the network must be as more extended as possible to be useful);
* an AS would like to achieve resilience in its connections toward the outside world.
ASes on the Internet are interconnected by a hierarchical organization:
* Tier 1 (e.g. Seabone, Sprint): international operator interconnecting major towns by long-distance, broadband links and transporting big traffic flows along backbones;
* Tier 2 (e.g. Telecom Italia): national operator collecting traffic from single users through a lot of access points thanks to its house-to-house presence throughout the territory;
* Tier 3: local operator serving a very restricted geographical area.

## Commercial agreements among ASes

Interconnections between an operator and another one may not come for free: usually, the interconnection between two ASes is established only upon an economic agreement. Two types of agreements are possible:
* transit: it represents the most natural choice from the economic viewpoint;
* peering: when two ASes discover that they can do better.
Inter-domain routing over the Internet is mainly driven by commercial agreements among operators at various hierarchical levels:
* Tier 1: it can advertise, independently of the geographical coverage of its network, the reachability of the full route (0.0.0.0/0), that is the reachability of (almost) every destination AS on the Internet, without having to buy transit from other providers or to pay some access fee;
* Tier 2: it needs to buy transit from a Tier-1 operator in order to be able to reach the whole Internet, and it can establish a lot of peering agreements with other Tier-2 providers;
* Tier 3: it has not any peering agreement, and simply buys transit from a Tier-2 (or Tier-1) provider.

### Transit

An agreement is transit when an ISP has to pay another ISP to connect to its AS. The ISP receiving the money guarantees the 'transit', that is the right to use its network, to the traffic coming from the other AS.
The economic agreement may establish:
* the payment method:
** fee by volume: a maximum amount of bytes of data per day or per month, plus additional cost for traffic exceeding that amount;
** flat fee: a monthly fee for a maximum bandwidth (the bandwidth can be limited via software on the access interface).
* which destinations are reachable through the transit:
** full route: all destinations around the world must be reachable;
** only destinations in a certain geographical area (e.g. USA): packets directed toward other destinations are dropped.
The price may be influenced by the importance of the ISP selling the transit:
* an US ISP has control of the most important part of the network because inside its AS there are the most visited web servers in the world;
* a very large ISP can offer a good reachability with the rest of the world thanks to its high number of interconnections.

### Peering

An agreement is peering when two peer ISPs agree to exchange traffic between themselves without having to pay each other.
Two ISPs can decide to stipulate a peering agreement if they determine that the costs for direct interconnection are lower than the costs for buying transit from each other: costs for setup and maintenance of the direct link between the ASes are equally split by the two ISPs, which can send data at the full speed allowed by the link.
Tier-1 operators work in a very competitive market:
* Tier-2 operators can establish new peering agreements among themselves as soon as they become more convenient than transit;
* a Tier-2 operator can shortly move to a more convenient Tier-1 operator;
* a dominant operator may be forced by the market guarantor to offer peering connections with minor ISPs.

## Routing policies

In inter-domain routing, other requirements are more important than simple network connectivity:
* economic (who pays for the bandwidth?): sometimes longer paths may be preferred to best paths;
* administrative (is it allowed to go?): sometimes some paths are omitted to the other party;
* security (is that administrative domain trusted?): sometimes safer (and longer) paths may be preferred to best paths.
The path chosen by the routing protocol is not necessarily the least-cost path from the technical point of view, but it is the best path among the ones which satisfy the constraints established by routing policies configured by the network administrator, which reflect commercial agreements among ASes.
The decision process on border routers is affected by routing policies:
* routing table: the choice of some cheaper routes can be favoured and the choice of other ones across untrusted ASes can be discouraged;
* route advertisements: the routes announced toward other ASes may not correspond to the actual network topology.

### Economic requirements

Sending traffic on a transit link costs → an AS can take advantage of a peering link, even if it is not a direct link, to make the other peer AS pay the transit cost (freeriding).
In the example in the side figure, two Italian ASes A and B are interconnected in peering, and each of them is connected in transit with US AS C. The best path according to the traditional routing rules is path x because it is made up of a direct link, but A needs to pay to make traffic go through that link. A can set a policy which prefers a cheaper path y: it deviates all the traffic directed to C to the link toward B, which is a low-cost link for A → B will send A's traffic to its transit link toward C, paying instead of A.

### Administrative requirements

An AS can set a routing policy in order not to announce connectivity with other ASes to an AS (route hiding).
In the example in the side figure, B has a transit link toward C and uses it for its traffic, but advertises partial connectivity by omitting the information about this link in the advertisements which it sends to A, in order to avoid that A takes advantage of the peering link to save on the transit cost (and vice versa). A could not trust this advertisement and in turn set a policy forcing statically all traffic toward C to be sent to B anyhow → B can defend itself by setting an Access Control List (ACL) on its border router to discard all packets coming from A and directed toward C.

### Security requirements

A network operator can represent a security threat because for example is used to make sniffing actions on traffic crossing its AS → an AS would like to avoid that its traffic directed to other ASes go through that untrusted operator.
In the example in the side figure, A to reach C prefers a longer but safer path x because it does not cross untrusted operator B, even if the latter is advertising low-cost path y toward C.

## Internet Exchange Point

Interconnecting two ASes by direct connection, that is by a single wide-area link between them, is not convenient:
* link cost: its installation may require digging operations;
* cost of interfaces on routers: they have to send the signal over long distances;
* flexibility: intervention is necessary on the physical infrastructure to create a new interconnection.
An Internet Exchange Point (IXP) allows multiple border routers of different ASes (ISPs) to exchange external routing information in a more dynamic and flexible way.
Routers are connected through an intermediate data-link-layer Local Area Network: technically all routers are directly reachable, but in practice routing policies define interconnections according to commercial agreements among ASes → to create a new interconnection, it is sufficient to configure routing policies on single routers without having to change the physical infrastructure. An interconnection can also be active but used just as a backup (selection done in BGP).
Usually each AS pays a monthly fee, depending on the speed of the connection to the IXP. The IXP is in charge of the technical functioning of switches within the intermediate network:
* single location: often all routers are concentrated inside a room in a datacenter, where they are provided with:
** high-speed data-link-layer network;
** electrical power, conditioning system;
** monitoring service;
** proximity to optical-fiber backbones;
* distributed infrastructure: multiple access points are available in the main towns over the territory (for example, TOPIX runs across the entire Piedmont region).
The IXP is also known as Neutral Access Point (NAP): the IXP has to be neutral and uninvolved in its customers' business. An IXP can decide to disallow transit agreements: for example, MIX in Milan is a nonprofit organization which only admits peering agreements to favour internet diffusion in Italy, but this may limit the amount of traffic exchanged across the IXP because ISPs available only for transit agreements will choose other IXPs.

## Network neutrality

Network neutrality is the principle according to which all traffic should be treated equally, without privileging or damaging a part of traffic for economic interests.
Network operators can be tempted to give 'preferential treatment' to portions of traffic:
* privilege some traffic: offer a better service for a certain kind of traffic (e.g. higher speed);
* damage some traffic: offer a worse service, or no service at all, for a certain kind of traffic.
A neutral network guarantees that all entities (e.g. content providers) have the same service, without making some service be killed at the discretion of the network operator, but enforcing 'pure' network neutrality implies that traffic control, which may be useful in many cases, is not possible at all; on the other end, if it is admitted that the network may not be neutral, the network operator is given the power to privilege some traffic or content. In an open market the ball is leaved to the user: if users do not agree that their VoIP traffic is discriminated, they can switch to another network operator (although in practice this may not always be possible due to cartels among network operators).

### Examples of non-neutrality

* content providers: ISPs would like to have a part of revenues of content providers → an ISP may privilege traffic directed to a content provider with which it stipulated a revenue sharing agreement;
* peer-to-peer (P2P):
** end users do not care about destination of their traffic, but P2P traffic can reach every user in every AS around the world making the ISP pay high costs → an ISP may privilege traffic which is generated within the AS (e.g. AdunanzA by Fastweb);
** P2P traffic is more symmetric because it uses a lot the upload bandwidth, while networks have been sized to support asymmetric traffic → an ISP may privilege asymmetric traffic (e.g. normal web traffic);
* quality of service (QoS): an ISP may privilege traffic with a higher priority level (e.g. VoIP traffic);
* security: an ISP may block traffic from malicious users (e.g. DDoS attack).