Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet...

Post on 30-Dec-2015

241 views 0 download

Tags:

Transcript of Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet...

Networking

Network Layer

Networking – Network Layer

• The Network Layer is part of the Internet Protocol stack

• The Network Layer sits between the Transport Layer and the Link/Physical Layer

• The Network Layer provides communication services to the physical hosts and devices in the network

Networking – Network Layer

• The Transport Layer (TCP/UDP) only ”lives” in the end hosts – a router does not know about TCP/UDP protocols

• The Network Layer (IP) ”lives” in end hosts and routers

Networking – Network Layer

• Two main categories of Network-Layer services– Network Layer connection-oriented service

(virtual circuits)– Network Layer connectionless service

(datagrams)• IP (Internet Protocol) offers connectionless

service, which we will focus on

Networking – Network Layer

• Main properties of IP– A best-effort service – no

guarantees on bandwidth, delays, order or integrity…

– Data is transferred through routing – no central entity is responsible for transferring data from Sender to Receiver

Networking – Network Layer

• The general problem of routing:• Given– A source – A destination – A network that contains at least one path from

source to destination• Find– The cheapest path from source to destination

Networking – Network Layer

The source

A destination

Networking – Network Layer

The source

A destinationA path

(cost = 12)

Networking – Network Layer

The source

A destination

A path (cost = 4)

Networking – Network Layer

• How is an optimal path calculated in practice?• Global routing algorithms – all information

about the available network is known in advance, by a central unit

• Decentralised routing algorithms – each ”node” in the network only has knowledge about its own, local costs

Networking – Network Layer

• Global routing in a network is a very well-known mathematical problem

• Algorithm is called Link State algorithm (aka Dijkstra’s algorithm)

• Global state could be learned if all nodes braodcast their state prior to calculation

Networking – Network Layer

• Link State algorithm: calculate the cheapest path from a source node A to all other nodes in the network

• Is an iterative algorithm; it extends the set of known cheapest paths in each step

Networking – Network Layer

• Terminology– c(i,j): Cost of link from node i to node j– D(v): Cost of the cheapest path from A to v that is

currently known– p(v): Previous node to v along the currently known

cheapest path– N: The set of nodes for which the cheapest path is

definitely known

Networking – Network Layer

// InitialisationN = {A}for (all nodes v){ if (v is adjacent to A) D(v) = c(A,v) else D(v) = ∞; // infinity}

Networking – Network Layer

Node A B C D E F

D(v) 0 2 5 1 ∞ ∞

Networking – Network Layer

// IterationPick w: (D(w) is minimal) AND (w not in N)Add w to N for (all nodes v: (adjacent to w) AND (not in N)){ if ((D(w) + c(w,v)) < D(v)) { D(v) = D(w) + c(w,v); }}

Networking – Network Layer

Node A B C D E F

D(v) 0 2 5 1 ∞ ∞

Networking – Network Layer

Node A B C D E F

D(v) 0 2 5 1 ∞ ∞

Networking – Network Layer

Node A B C D E F

D(v) 0 2 4 1 2 ∞

Networking – Network Layer

Node A B C D E F

D(v) 0 2 4 1 2 ∞

Networking – Network Layer

Node A B C D E F

D(v) 0 2 3 1 2 4

Networking – Network Layer

// Link State AlgorithmInitialisation;while (still nodes that are not in A){ Iteration;}

Networking – Network Layer

• When we are done, we have– The cost of the cheapest path from the source to

any destination– The cheapest path itself from the source to any

destination• How did we get the path itself…?

Networking – Network Layer

• Link State algorithm is fast, and is guaranteed to pro-duce the optimal solution…

• …BUT when do we ever have global information available…?

• On the Internet as such, never…

Networking – Network Layer

• In practice, we will often have to rely on locally available information

• The Distance Vector algorithm is such an algorithm

• Main features– Iterative– Asynchronous– Distributed

Networking – Network Layer

• Setup for Distance Vector algorithm• Each node in the network has a number of

direct neighbours DN• Each node also knows about a number of

destinations DE• Each node maintains a distance table– One row for each member of DE– One column for each member of DN

Networking – Network Layer

DN1 DN2 … DNi

DE1

DE2

DE3

DE4

……DEn

Networking – Network Layer

DX(Y,Z)

• This means…– How much will it cost for node X…– …to route something to the destination Y…– …via the direct neighbour Z

Networking – Network Layer

• If the value of DX(Y,Z) is known for all entries in the distance table for X, then X would always know where to route data

• How is the distance table built up?• How is the distance table maintained?

Networking – Network Layer

DX(Y,Z) = c(X,Z) + minw(DZ(Y,w))

Ahhhrrhhhggg, MATH ANGST!

Networking – Network Layer

DX(Y,Z) = c(X,Z) + minw(DZ(Y,w))

• This means…– How much will it cost for node X…– …to route something to the destination Y…– …via the direct neighbour Z

Networking – Network Layer

DX(Y,Z) = c(X,Z) + minw(DZ(Y,w))

• This means…– The direct cost of sending data from X to Z– X knows this, since Z is a direct neighbour of X

Networking – Network Layer

DX(Y,Z) = c(X,Z) + minw(DZ(Y,w))

• This means…– How much will it cost for node Z…– …to route something to the destination Y…– …via the direct neighbour w

Networking – Network Layer

DX(Y,Z) = c(X,Z) + minw(DZ(Y,w))

• This means…– Find the minimal value of the expression in the

brackets, for all the direct neighbours to Z

Networking – Network Layer

• In other words…• …if a node knows – or can get – the distance

tables for all its neighbours, it can build up its own distance table

Networking – Network Layer

DN1 DN2 … DNi

DE1 12 33 24DE2 10 28 45DE3 16 12 18DE4 16 18 12……DEn 48 22 36

Networking – Network Layer

DN1 DN2 … DNi

DE1 12 33 24DE2 10 28 45DE3 16 12 18DE4 16 18 12……DEn 48 22 36

Networking – Network Layer// The algorithm runs on each node// Initialisationfor (all nodes v adjacent to myself (X)){ DX(*,v) = ∞; // * means ”all rows” DX(v,v) = C(X,v);}for (all destinations y){ // w: over all X’s neighbours send minw(D(y,w)) to each neighbour;

}

Networking – Network Layer// The algorithm runs on each node// Loop…foreverwait; // until a message is received

if (message to update cost to all destinations via the neighbour v by the amount d){ for (all destinations y) DX(y,v) = DX(y,v) + d;}if (message that shortest path from v to some y has changed){ DX(y,v) = c(x,v) + newValue;}

for (all neighbours y) send(new value of minw(D(y,w)));

Networking – Network Layer

• A slightly more complex algorithm, but still fairly few lines of code…

• Can we be sure it will ”settle down”?

• Not really, but will provide a reasonable ”snapshot” of the total state at any time

Networking – Network Layer

• The algorithm has some weak spots…• Good news travels fast – if a link cost is

decreased, the information will quickly spread• Bad news travels slow - if a link cost is

increased, the information spreads slowly (the count-to-infinity problem)

• Bad news can cause loops – we can get peculiar routes like A-B-A-D-E

Networking – Network Layer

• There are certain ”tricks” available to avoid the problems

• Poisoned reverse: Injecting false information into the network (white lies…)

• Total algorithm not trivial…

Networking – Network Layer

• Practical routing problems• The internet is too big!

There are billions of possible destinations!

• We can never use a fully global routing algorithm!

• We can never create a complete routing table!

Networking – Network Layer

• In practice, routing is hierarchical• Routers are divided into ”regions” or so-called

autonomous systems (AS)• An AS could e.g. be – A company– A university– A geographic region– …

Networking – Network Layer

• Within an AS, all routers – Know each other– Run the same routing algorithm

• This is called the intra-AS routing protocol• Some routers will also be responsible for

exchanging data with other ASs – these are called gateway routers

Networking – Network Layer

• Since gateway routers talk other gateway routers in other ASs, they need to use an inter-AS routing protocol for this purpose

Networking – Network Layer

• Routing from A (in AS X) to B (in AS Y)– Route from A to gateway router GX in X, using

intra-AS protocol– Route from gateway router GX in X to gateway

router GY in Y using inter-AS protocol– Route from gateway router GY in Y to B, using

intra-AS protocol

Networking – Network Layer

GX

A

B

GY

X Y

Networking – Network Layer

• Note: still only one routing table…

• …but certain entries may be populated in different ways

Networking – Network Layer

• The actual Network Layer protocol used on the Internet is called IP (Internet Protocol)

• IP implements a best-effort service – no guarantees on delivery time, order or delivery at all…

• Two main variants, IPv4 and IPv6

Networking – Network Layer

• More specifically, IP provides a connectionless datagram service

• Data is wrapped into an ”envelope” specifying the destination address, and reaches the destination through local routing

Networking – Network Layer

• Recall that hosts in a network are identified by means of an IP address

• More precisely, all hosts and routers have IP addresses

• Even more generally, all interfaces have IP addresses

Networking – Network Layer

NOTE: Router has three interfaces!

Each interface has its own IP address

Networking – Network Layer

• IP addresses are hierarchical – first 8/16/24 bits define a network, the rest an interface within the network

Network class identification

Networking – Network Layer

• Host/interfaces are uniquely identified by IP addresses, so IP addresses must be globally unique!

• How does a host/interface get an IP address?– Automatic (DHCP)– Manual

Networking – Network Layer

• DHCP – Dynamic Host Configuration Protocol• Your computer queries a DHCP server on the

network, asking for a (temporary) IP address• The DHCP server chooses a vacant IP address,

and returns it to your computer• No guarantees on durability

Networking – Network Layer

• Manual IP address• Somebody (network administrator?) chooses a

vacant IP address from a pool of available IP addresses – you use it!

• Where does the network administrator get IP addresses from…?

Networking – Network Layer

• Allocation of IP addresses is (of course) a regulated process

• Several regional organs manage this– RIPE– ARIN– APNIC

Networking – Network Layer

• Lets send some data, using IP (IPv4)

Networking – Network Layer

Administrative stuff

Networking – Network Layer

Packet maximal lifetime

Networking – Network Layer

TCP, UDP,…

Networking – Network Layer

Error correction

Networking – Network Layer

Where do I come from…

Networking – Network Layer

Where am I going…

Networking – Network Layer

Options…

Networking – Network Layer

Data itself…!

Networking – Network Layer

• IPv6

Networking – Network Layer

Label defining a certain set of packets…

Networking – Network Layer

Upper-layer protocol

Networking – Network Layer

Maximal number of routings

Networking – Network Layer

Note 128 bits…!

Networking – Network Layer

• Now we will never (?) run out of IP addresses…

Networking – Network Layer

• Actual routing on the Internet – how…?• Recall:– Interfaces divided into autonomous systems (AS)– Inside an AS, an intra-AS routing protocol is used– Between ASs, an inter-AS routing protocol is used

• What specific protocols are used in practice?

Networking – Network Layer

• Intra-AS routing protocols– RIP – Routing Information Protocol– OSPF – Open Shortest Path First– IGRP - Internal Gateway Routing Protocol– …

• RIP and OSPF are the most common choices

Networking – Network Layer

• RIP – Routing Information Protocol• RIP is a distance vector algorithm• Cost is defined as one unit per ”hop”, up to a

maximum of 15• Cost (or routing) tables are exchanged with

neighbours every 30 seconds• Cost tables can contain 25 entries

Networking – Network Layer

• Note that RIP costs are not sensitive to ”traffic conditions”

• How can a cost ever change…?– Algorithm needs time to converge– Adding/removing routers can change cost– Neighbour is considered unreachable if no

contact in 180 seconds

Networking – Network Layer

Used for all other destinations

Networking – Network Layer

• Won’t we experience a ”routing table explosion”, since there are billions of possible destinations?

• In practice, routers use routing table aggregation – grouping many destinations into one entry

• http://www.ripe.net/ripe/docs/ripe-399#3

Networking – Network Layer

• OSPF – Open Shortest Path First• OSPF is a link-state algorithm• Link costs defined by network administrator• Each router ”broadcasts” its routing table

(to the neighbours) to all other routers• Each router can then assemble a complete

routing table

Networking – Network Layer

• Other OSPF features– Security by authetication– Multiple same-cost paths– Cost differentiation by type-of-service– Multicast routing support– Support for hierarchical routing within an AS

Networking – Network Layer

Networking – Network Layer

• Inter-AS routing protocols• One protocol called Border Gateway Protocol

(BGP) is the standard for inter-AS routing• Is a path vector algorithm (not distance…)• The algorithm propagates path, not costs,

from AS to AS• Actual choice of path is domain policy…

Networking – Network Layer

Networking – Network Layer

• Why aren’t intra- and inter-AS routing algorithms the same…?– Policy – at inter-AS level, some choices may be

impractical, even though they are cheapest– Scale – size of single AS is controllable, total

number of AS on the Internet is not…– Performance – ”raw” performance more

important on the intra-AS level

Networking – Network Layer