870 likes | 1.21k Views
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.
E N D
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 A destination The source
Networking – Network Layer A path (cost = 12) A destination The source
Networking – Network Layer A destination A path (cost = 4) The source
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 // Initialisation N = {A} for (all nodes v) { if (v is adjacent to A) D(v) = c(A,v) else D(v) = ∞; // infinity }
Networking – Network Layer // Iteration Pick 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 // Link State Algorithm Initialisation; 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 itselffrom 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 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 // The algorithm runs on each node // Initialisation for (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…forever wait; // 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 X Y GX GY A B
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