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

86
Networking Network Layer

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

Page 1: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking

Network Layer

Page 2: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 3: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 4: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 5: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 6: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 7: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

The source

A destination

Page 8: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

The source

A destinationA path

(cost = 12)

Page 9: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

The source

A destination

A path (cost = 4)

Page 10: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 11: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 12: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 13: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 14: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

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

Page 15: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Node A B C D E F

D(v) 0 2 5 1 ∞ ∞

Page 16: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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); }}

Page 17: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Node A B C D E F

D(v) 0 2 5 1 ∞ ∞

Page 18: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Node A B C D E F

D(v) 0 2 5 1 ∞ ∞

Page 19: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Node A B C D E F

D(v) 0 2 4 1 2 ∞

Page 20: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Node A B C D E F

D(v) 0 2 4 1 2 ∞

Page 21: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Node A B C D E F

D(v) 0 2 3 1 2 4

Page 22: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

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

Page 23: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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…?

Page 24: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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…

Page 25: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 26: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 27: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

DN1 DN2 … DNi

DE1

DE2

DE3

DE4

……DEn

Page 28: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 29: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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?

Page 30: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

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

Ahhhrrhhhggg, MATH ANGST!

Page 31: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 32: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 33: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 34: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 35: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 36: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

DN1 DN2 … DNi

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

Page 37: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

DN1 DN2 … DNi

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

Page 38: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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;

}

Page 39: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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)));

Page 40: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 41: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 42: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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…

Page 43: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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!

Page 44: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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– …

Page 45: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 46: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 47: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 48: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

GX

A

B

GY

X Y

Page 49: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

• Note: still only one routing table…

• …but certain entries may be populated in different ways

Page 50: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 51: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 52: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 53: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

NOTE: Router has three interfaces!

Each interface has its own IP address

Page 54: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 55: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 56: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 57: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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…?

Page 58: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

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

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

Page 59: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

• Lets send some data, using IP (IPv4)

Page 60: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Administrative stuff

Page 61: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Packet maximal lifetime

Page 62: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

TCP, UDP,…

Page 63: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Error correction

Page 64: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Where do I come from…

Page 65: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Where am I going…

Page 66: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Options…

Page 67: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Data itself…!

Page 68: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

• IPv6

Page 69: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Label defining a certain set of packets…

Page 70: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Upper-layer protocol

Page 71: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Maximal number of routings

Page 72: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Note 128 bits…!

Page 73: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

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

Page 74: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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?

Page 75: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 76: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 77: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 78: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Used for all other destinations

Page 79: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 80: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 81: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 82: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Page 83: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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…

Page 84: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer

Page 85: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

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

Page 86: Networking Network Layer. Networking – Network Layer The Network Layer is part of the Internet Protocol stack The Network Layer sits between the Transport.

Networking – Network Layer