Module 5 Z0EUGu9
Module 5 Z0EUGu9
• One of them handles each packet as it arrives, looking up the outgoing line to use for it in the routing tables.
  This process is forwarding.
• The other process is responsible for filling in and updating the routing tables. That is where the routing
  algorithm comes into play.
• properties desirable in a routing algorithm: correctness, simplicity, robustness, stability, fairness, and
  efficiency.
• Routing algorithms can be grouped into two major classes: nonadaptive and adaptive.
• Nonadaptive algorithms do not base their routing decisions on any measurements or estimates of the current
  topology and traffic.
• Instead, the choice of the route to use to get from I to J (for all I and J) is computed in advance, offline, and
  downloaded to the routers when the network is booted.
• Because it does not respond to failures, static routing is mostly useful for situations in which the routing
  choice is clear
• Adaptive algorithms change their routing decisions to reflect changes in the topology, and sometimes
  changes in the traffic as well.
• These dynamic routing algorithms differ in where they get their information, when they change the routes ,
  and what metric is used for optimization
THE OPTIMALITY PRINCIPLE
 • if router J is on the optimal path from router I to router K, then the optimal path from J to K
   also falls along the same route.
 • the part of the route from I to J as r1 and the rest of the route as r 2.
 • If a route better than r 2 existed from J to K, it could be concatenated with r 1 to improve
   the route from I to K, contradicting our statement that r 1r 2 is optimal.
 • As a direct consequence of the optimality principle, the set of optimal routes from all
   sources to a given destination form a tree rooted at the destination.
 • Such a tree is called a sink tree where the distance metric is the number of hops.
 • The goal of all routing algorithms is to discover and use the sink trees for all routers.
(a) A network. (b) A sink tree for router B.
• If all of the possible paths are to be chosen, the tree becomes a more general structure called a DAG
  (Directed Acyclic Graph).
• it does not contain any loops, so each packet will be delivered within a finite and bounded number of hops.
FLOODING
 • every incoming packet is sent out on every outgoing line except the one it arrived on.
 • have a hop counter contained in the header of each packet that is decremented at each hop,
   with the packet being discarded when the counter reaches zero.
 • the hop counter should be initialized to the length of the path from source to destination.
 • If the sender does not know how long the path is, it can initialize the counter to the worst
   case, namely, the full diameter of the network.
 • Flooding with a hop count can produce an exponential number of duplicate packets as the
   hop count grows and routers duplicate packets they have seen before.
 • have routers keep track of which packets have been flooded, to avoid sending them out a
   second time.
 • have the source router put a sequence number in each packet it receives from its hosts
• each list should be augmented by a counter, k, meaning that all sequence numbers through k have
  been seen.
• When a packet comes in, it is easy to check if the packet has already been flooded by comparing its
  sequence number to k; if so, it is discarded.
• can be used as a building block for other routing algorithms that are more efficient but need more
  in the way of setup.
• Flooding can also be used as a metric against which other routing algorithms can be compared.
• Flooding always chooses the shortest path because it chooses every possible path in parallel.
• Selective flooding
Shortest-Path Routing
     • Path-selection model
       •Destination-based
       •Load-insensitive (e.g., static link weights)
       •Minimum hop count or sum of link weights
                               2
                  3                        1
                           1
                                       4
                  2    1
                                   5
                      4                3
11
Shortest-Path Problem
• Given: network topology with link costs
     • c(x,y): link cost from node x to node y
     • Infinity if x and y are not direct neighbors
• Compute: least-cost paths to all nodes
     • From a given source u to all other nodes
     • p(v): predecessor node along path2 from source to v
                             3                      1
                                       1
                       u                      4
                              2      1
                                           5
                                p(v)
                                       4        3
                            w
12                                         v
Routing
• A routing protocol sets up a routing table in routers
□   Routing
    ◆   Make sure that the next hop actually leads to the destination
    ◆   Global decisions; distributed computation and communication
    ◆   Can go slower (only important when topology changes)
    Forwarding Options
□    Source routing
     ◆   Complete path listed in packet
□    Virtual circuits
     ◆   Set up path out-of-band and store path identifier in routers
     ◆   Local path identifier in packet
□    Destination-based forwarding
     ◆   Router looks up address in forwarding table
     ◆   Forwarding table contains (address, next-hop) tuples
Distance-vector & Link-state Routing
• Both assume router knows
   • address of each neighbor
   • cost of reaching each neighbor
• Both allow a router to determine global routing information by
  talking to its neighbors
□   Motivation
    ◆   Global information allows optimal route computation
    ◆   Straightforward to implement and verify
A Link State Routing Algorithm
     Dijkstra’s algorithm                 Notation:
     ■   net topology, link costs         ■ c(i,j): link cost from node i
         known to all nodes                   to j. cost infinite if not direct
           – accomplished via “link           neighbors
              state broadcast”
                                          ■   D(v): current value of cost
           – all nodes have same info         of path from source to dest.
     ■   computes least cost paths            V
         from one node (‘source”) to
                                          ■   p(v): predecessor node
         all other nodes
                                            along path from source to v,
           – gives routing table for        that is next v
              that node
                                          ■ N: set of nodes whose least
     ■   iterative: after k iterations,
                                            cost path definitively known
         know least cost path to k
         dest.’s
Dijsktra’s Algorithm
          1 Initialization:
          2 N' = {u}
          3 for all nodes v
          4    if v adjacent to u
          5        then D(v) = c(u,v)
          6    else D(v) = ∞
          7
          8 Loop
          9 find w not in N' such that D(w) is a minimum
          10 add w to N'
          11 update D(v) for all v adjacent to w and not in N' :
          12      D(v) = min( D(v), D(w) + c(w,v) )
          13 /* new cost to v is either old cost to v or known
          14 shortest path cost to w plus cost from w to v */
          15 until all nodes in N'
                                  v   3       w
                              2                           5
                      u           2            1               z
                                          3
                          1                               2
                                  x   1
                                              y
             1      A                     A                                  A                     A
                         1+e     2+e             0                    0            2+e    2+e             0
         D        0 0        B   D                   B               D               B    D                   B
                                         1+e 1                               0 0                  1+e 1
             0           e           0           0                       1         1+e        0           e
     1
                    C                      C                                 C                      C
                             1
                   e
                                 … recompute                         … recompute         … recompute
                 initially
                                    routing
                                                     Network Layer                                                4-22
Step 1   Step 2
         Step 4
Step 3
Step 5
         Final
Distance Vector Algorithm Overview
• Each router starts with a distance table consisting of the value “0” for itself and
  the value “infinity” for every other destination
• Each router will transmit its distance vector to each of its neighbors whenever
  the information changes (as well as when a link to a neighbor first comes up)
• Each router saves the most recently received distance vector from each of its
  neighbors, and calculate its own distance vector, based on minimizing the cost to
  each destination
Distance Vector Algorithm
     iterative:
                                    Distance Table data structure
     ■   continues until no nodes
         exchange info.             ■   each node has its own
     ■   self-terminating: no       ■   row for each possible destination
         “signal” to stop           ■   column for each directly-attached
                                        neighbor to node
     asynchronous:
                                    ■   example: in node X, for dest. Y via
     ■  nodes need not
                                        neighbor Z:
        exchange info/iterate in
        lock step!
     distributed:                                 distance from X to
     ■ each node                        X       = Y, via Z as next hop
                                          D
        communicates only with          (Y,Z)                      Z
                                                = c(X,Z) + min {D (Y,w)}
        directly-attached                                      w
        neighbors
Distance Table: An Example
                       B    1   C                              E
                                                                  cost to destination via
                  7                                            D ()   A       B      D
          A             8           2
                                                                  A    1     14      5
              1
                       E        D
                            2                                     B    7       8     5
                                                 destination
      E                                     D                    C     6       9     4
     D (C,D)          = c(E,D) + min {D (C,w)}
                                    w
                      = 2+2 = 4                                  D     4     11      2
      E                                     D
     D (A,D)          = c(E,D) + minw{D (A,w)}
                      = 2+3 = 5 loop!
      E                                     B
      D (A,B)         = c(E,B) + minw{D (A,w)}
                      = 8+6 = 14
                                    loop!
Distance Table Gives Routing Table
                       cost to destination via
                    E                                              Outgoing link
                    D ()   A       B      D
                                                                   to use, cost
                      A      1    14       5                   A     A,1
                      B      7      8      5                   B     D,5
      destination
                                                 desti natio
                      C      6      9      4                   C     D,4
                                                       n
                      D      4    11       2                   D     D,4
     1 Initialization:
     2 for all adjacent nodes v:
     3    DX(*,v) = infty      /* the * operator means "for all rows" */
     4    DX(v,v) = c(X,v)
     5 for all destinations, y
     6    send min DX(y,w) to each neighbor /* w over all X's neighbors */
                   w
Distance Vector Algorithm: Cont’d
 8 loop
 9 wait (until I see a link cost change to neighbor V
 10      or until I receive update from neighbor V)
 11
 12 if (c(X,V) changes by d)
 13 /* change cost to all dest's via neighbor v by d */
 14 /* note: d could be positive or negative */
 15 for all destinations y: DX(y,V) = DX(y,V) + d
 16
 17 else if (update received from V wrt destination Y)
 18 /* shortest path from V to some Y has changed */
 19 /* V has sent a new value for its minw DV(Y,w) */
 20 /* call this received new value is "newval"     */
 21 for the single destination y: DX(Y,V) = c(X,V) + newval
 22
 23 if we have a new minw DX(Y,w)for any destination Y
 24    send new value of minw DX(Y,w) to all neighbors
 25
 26 forever
Distance Vector Algorithm: Example
            Y
        2       1
    X               Z
            7
Distance Vector Algorithm: Example
            Y
        2       1
    X               Z    X                       Z
            7           D (Y,Z) = c(X,Z) + minw{D (Y,w)}
                               = 7+1 = 8
                         X                       Y
                        D (Z,Y) = c(X,Y) + minw{D (Z,w)}
                               = 2+1 = 3
Distance Vector Algorithm: Link Cost Changes
        Link cost changes:
                                                        1
        ■   node detects local link cost change                 Y
        ■   updates distance table (line 15)                4        1
            if cost change in least cost path, notify   X                Z
        ■                                                       50
            neighbors (lines 23,24)
                                                                         algorithm
      “good                                                              terminates
      news
      travels
      fast”
Count to infinity: Another Example
           A         B        C
               1         1
Distance Vector: Link Cost Changes
       Link cost changes:                 60
       ■   good news travels fast                 Y
                                              4        1
       ■   bad news travels slow -        X                Z
           “count to infinity” problem!           50
                                                               algorithm
                                                               continues
                                                                      on!
Distance Vector: Position Reverse
     If Z routes through Y to get to X :                 60
     ■   Z tells Y its (Z’s) distance to X is infinite           Y
                                                             4        1
         (so Y won’t route to X via Z)
                                                         X                Z
     ■   will this completely solve count to infinity            50
         problem?
                                                                              algorithm
                                                                              terminates
Distance Vector Example: Step 1
          Optimum 1-hop paths
          Table for A           Table for B
                                                             E          3                              C
     Dst     Cst    Hop     Dst    Cst    Hop                                                  1
      A       0         A   A       4         A
                                                                                                           1
                                                        2                            F
      B       4         B   B       0         B
                                                                    6
      C       ∞         –   C       ∞         –
                                                                                           1
      D       ∞         –   D       3         D                                                    3           D
      E       2         E   E       ∞         –          A                   4
      F       6         F   F       1         F                                            B
          Table for C           Table for D           Table for E                Table for F
     Dst     Cst   Hop      Dst    Cst    Hop     Dst       Cst   Hop       Dst     Cst    Hop
      A      ∞          –   A       ∞         –   A          2      A       A        6         A
      B      ∞          –   B       3         B   B          ∞      –       B        1         B
      C       0     C       C       1         C   C          ∞      –       C        1         C
      D       1     D       D       0         D   D          ∞      –       D        ∞         –
      E      ∞          –   E       ∞         –   E          0      E       E        3         E
      F       1         F   F       ∞         –   F          3      F       F        0         F
39
Distance Vector Example: Step 2
          Optimum 2-hop paths
          Table for A           Table for B
                                                             E          3                              C
     Dst     Cst    Hop     Dst    Cst    Hop                                                  1
      A       0         A   A       4         A                                                            1
                                                        2                            F
      B       4         B   B       0         B
                                                                    6
      C       7         F   C       2         F
                                                                                           1
      D       7         B   D       3         D                                                    3           D
      E       2         E   E       4         F
                                                         A                   4
      F       5         E   F       1         F
                                                                                           B
          Table for C           Table for D           Table for E                Table for F
     Dst     Cst    Hop     Dst    Cst    Hop     Dst       Cst   Hop       Dst     Cst    Hop
      A       7         F   A       7         B   A          2      A       A        5         B
      B       2         F   B       3         B   B          4      F       B        1         B
      C       0         C   C       1         C   C          4      F       C        1         C
      D       1         D   D       0         D   D          ∞      –       D        2         C
      E       4         F   E       ∞         –   E          0      E       E        3         E
      F       1         F   F       2         C   F          3      F       F        0         F
40
Distance Vector Example: Step 3
          Optimum 3-hop paths
          Table for A           Table for B
                                                             E          3                              C
     Dst     Cst    Hop     Dst    Cst    Hop                                                  1
      A       0         A   A       4         A                                                            1
                                                        2                            F
      B       4         B   B       0         B
                                                                    6
      C       6         E   C       2         F
                                                                                           1
      D       7         B   D       3         D                                                    3           D
      E       2         E   E       4         F
                                                         A                   4
      F       5         E   F       1         F
                                                                                           B
          Table for C           Table for D           Table for E                Table for F
     Dst     Cst    Hop     Dst    Cst    Hop     Dst       Cst   Hop       Dst     Cst    Hop
      A       6         F   A       7         B   A          2      A       A        5         B
      B       2         F   B       3         B   B          4      F       B        1         B
      C       0         C   C       1         C   C          4      F       C        1         C
      D       1         D   D       0         D   D          5      F       D        2         C
      E       4         F   E       5         C   E          0      E       E        3         E
      F       1         F   F       2         C   F          3      F       F        0         F
41
Comparison of LS and DV Algorithm
    Message complexity                   Robustness: what happens
    ■   LS: with n nodes, E links,         if router malfunctions?
        O(nE) msgs sent each             LS:
    ■   DV: exchange between
                                            – node can advertise
        neighbors only
                                              incorrect link cost
         – convergence time varies
                                            – each node computes only
    Speed of Convergence                      its own table
    ■   LS: O(n**2) algorithm requires   DV:
        O(nE) msgs                          – DV node can advertise
         – may have oscillations              incorrect path cost
    ■   DV: convergence time varies         – each node’s table used by
         – may be routing loops               others
         – count-to-infinity problem           o error propagate thru
                                                 network
CONGESTION CONTROL
CONGESTION CONTROL ALGORITHMS
• When too many packets are present in (a part of) the subnet, performance degrades.
  This situation is called congestion.
• the number of packets <carrying capacity of subnet, the number delivered is
  proportional to the number sent
• At very high traffic, performance collapses completely and almost no packets are
  delivered
Congestion can be brought on by
• If all of a sudden, streams of packets begin arriving on three or four input lines and all
  need the same output line, a queue will build up.
• if routers have an infinite amount of memory, congestion gets worse, not better,
  because by the time packets get to the front of the queue, they have already timed out
  (repeatedly) and duplicates have been sent
• Open Loop- solve the problem by good design to make sure it does not occur in the
  first place.
• Tools for doing open-loop control include
   1.   deciding when to accept new traffic,
   2.   deciding when to discard packets and which ones,
   3.   making scheduling decisions at various points in the network.
• Closed Loop- based on the concept of a feedback loop. This approach has three parts
  when applied to congestion control:
   1. Monitor the system to detect when and where congestion occurs.
   2. Pass this information to places where action can be taken.
   3. Adjust system operation to correct the problem.
Monitor the system to detect when and where congestion occurs.
transfer the information about the congestion from the point where it is detected to the
point where something can be done about it.
1. router detecting the congestion will send a packet to the traffic source or sources,
   announcing the problem.
2. a bit or field can be reserved in every packet for routers to fill in whenever congestion
   gets above some threshold level.
3. have hosts or routers periodically send probe packets out to explicitly ask about
   congestion
4. knowledge of congestion will cause the hosts to take appropriate action to reduce the
   congestion.
Adjust system operation to correct the problem
• The presence of congestion means that the load is (temporarily) greater than the
  resources (in part of the system) can handle.
• where the constant a determines how fast the router forgets recent history.
• Whenever u moves above the threshold, the output line enters a ''warning'' state.
• Each newly-arriving packet is checked to see if its output line is in warning state. If it
  is, some action is taken.
Choke Packets
• To tell the source to slow down, the router sends a choke packet back to the source
  host, giving it the destination found in the packet
• original packet is tagged (a header bit is turned on) so that it will not generate any
  more choke packets farther along the path and is then forwarded in the usual way .
• When the source host gets the choke packet, reduce the traffic sent to the specified
  destination by X percent
• the host should ignore choke packets referring to that destination for a fixed time
  interval.
• After that period has expired, the host listens for more choke packets for another
  interval.
• If one arrives, the line is still congested, so the host reduces the flow still more and
  begins ignoring choke packets again.
• If no choke packets arrive during the listening period, the host may increase the flow
  again.
• Hosts can reduce traffic by adjusting their policy parameters, for example, their
  window size.
• Variation -routers can maintain several thresholds. Depending on which threshold has
  been crossed, the choke packet can contain a mild warning, a stern warning, or an
  ultimatum.
• Another variation -use queue lengths or buffer utilization instead of line utilization as
  the trigger signal. The same exponential weighting can be used with this metric as with
  u
LOAD SHEDDING
• when routers are being inundated by packets that they cannot handle, they just throw
  them away
• applications must mark their packets in priority classes to indicate how important they
  are.
• Another option -allow hosts to exceed the limits specified in the agreement negotiated
  when the virtual circuit was set up, but subject to the condition that all excess traffic
  be marked as low priority.
Random Early Detection(RED)
• idea of discarding packets before all the buffer space is really exhausted
• popular algorithm for doing this is called RED (Random Early Detection)
• idea is that there is time for action to be taken before it is too late.
• To determine when to start discarding, routers maintain a running average of their
  queue lengths.
• When the average queue length on some line exceeds a threshold, the line is said to be
  congested and action is taken.
• Router to tell the source about the problem-
1. One way is to send it a choke packet
2. just discard the selected packet and not report it. The source will eventually notice the
   lack of acknowledgement and take action.
QUALITY OF SERVICE
Quality of Service Requirements
• A stream of packets from a source to a destination is called a flow
• The needs of each flow can be characterized by four primary parameters: reliability,
  delay, jitter, and bandwidth.
• Together these determine the QoS (Quality of Service) the flow requires
• Reliability- No bits may be delivered incorrectly. Achieved by checksumming each
  packet and verifying the checksum at the destination
• Jitter- sensitive to the packets arriving with irregular time intervals between them.
•
• Bandwidth- the applications differ in their bandwidth needs
Techniques for Achieving Good Quality of Service
• Overprovisioning
• Buffering
• Traffic Shaping
• The Leaky Bucket Algorithm
• The Token Bucket Algorithm
• Resource Reservation
• Admission Control
• Proportional Routing
• Packet Scheduling
Buffering
• Flows can be buffered on the receiving side before being delivered.
• does not affect the reliability or bandwidth, and increases the delay, but it smooths out
  the jitter
Traffic Shaping
• smooths out the traffic on the server side, rather than on the client side.
• regulating the average rate (and burstiness) of data transmission
• service level agreement - When a connection is set up, the user and the subnet
  agree on a certain traffic pattern for that circuit.
• Traffic shaping reduces congestion and thus helps the carrier live up to its promise.
• with traffic shaping the customer says to the carrier: My transmission pattern will look
  like this; can you handle it?
• Monitoring a traffic flow is called traffic policing - if the customer is following the
  agreement and what to do if the customer is not.
The Leaky Bucket Algorithm
• each host is connected to the network by an interface containing a leaky bucket, that
  is, a finite internal queue.
• host is allowed to put one packet per clock tick onto the network.
• turns an uneven flow of packets from the user processes inside the host into an even
  flow of packets onto the network, smoothing out bursts and greatly reducing the
  chances of congestion.
Implementation of Leaky Bucket
• The leaky bucket consists of a finite queue.
• When a packet arrives, if there is room on the queue it is appended to the queue;
  otherwise, it is discarded.
• At every clock tick, one packet is transmitted (unless the queue is empty).