IP Datagram Forwarding

Embed Size (px)

Citation preview

  • 8/11/2019 IP Datagram Forwarding

    1/26

    IP Datagrams. Datagram

    forwarding

  • 8/11/2019 IP Datagram Forwarding

    2/26

    The IP datagram

    The packets that are forwarded across theInternet are known as IP datagrams.

    An IP datagram consists of a header and a

    payload. The header contains information that allows

    Internet routers to forward the datagram from

    the source host to the destination host. IP datagrams have variable size up to a

    maximum.

  • 8/11/2019 IP Datagram Forwarding

    3/26

    The IP Datagram Header

  • 8/11/2019 IP Datagram Forwarding

    4/26

    IP Datagram Forwarding

  • 8/11/2019 IP Datagram Forwarding

    5/26

    Routing procedure

    Say datagram for destinationD arrives at router R. Assume routing table at R has N entries.

    match = false;

    for (i = 0; i < N; ++i) {

    if (D & Mask[i] == Destination[i]) {

    match = true

    Next = NextHop[i];

    break;

    }

    }

    if (match == true)

    forward datagram to Next.

    else

    drop datagram.

  • 8/11/2019 IP Datagram Forwarding

    6/26

    Resolving routing ambiguities

    Example: Routing table contains the followingtwo destinations among others: 128.10.0.0/16and 128.10.2.0/24.

    Datagram with destination D = 128.10.2.3 arrivesat router. It matches both entries.

    The ambiguity is resolved by choosing the entrywith the longest prefix( /24).

    One solution would be to sort the routing table indecreasing order of prefix length and do a linearsearch on the table until a match is found.

  • 8/11/2019 IP Datagram Forwarding

    7/26

    Best-Effort Delivery

    IP is said to offer a best-effortservice. By this wemean that IP will try its best to have an IP packetdelivered to the destination, but it cant make any

    promises. The following problems can occur: Datagram duplication.

    Out-of-order delivery.

    Corrupt packets.

    Lost datagrams.

    Recovery from these problems is left to the upperlayers.

  • 8/11/2019 IP Datagram Forwarding

    8/26

    Encapsulation

    The physical networks that comprise the Internet do notunderstand the IP datagram format. Each one has its own packetformat. For example, Ethernet uses frames with headers containing6-byte ethernet addresses.

    For IP datagrams to be forwarded between two computers, they

    must be encapsulated (placed inside) frames appropriate for thephysical network in which the two computers reside.

    For example, if an IP datagram needs to be forwarded fromcomputer A to computer B, where A and B reside on the sameEthernet, it needs to be encapsulated inside an Ethernet frame.

    The source address of the Ethernet frame is As ethernet interfaceaddress, and the destination address of the frame is Bs ethernetinterface address.

  • 8/11/2019 IP Datagram Forwarding

    9/26

  • 8/11/2019 IP Datagram Forwarding

    10/26

    Transmission across the Internet

  • 8/11/2019 IP Datagram Forwarding

    11/26

    MTU and Datagram Fragmentation

    MTU = maximum transmission unit = max payload a physical frame cancarry.

    Ethernet MTU = 1500

    On the other hand, IP datagrams can be as large as 65535 bytes = 216 1.

    How can such large datagrams be encapsulated inside the much smaller

    frames? Answer: Fragmentation. Large IP datagrams are split into smaller IP

    datagrams that can fit inside smaller physical frames.

    Fragments contain afragment offset field that indicated the relativeposition of the datagram payload with respect to the original(unfragmented) datagram.

    Fragments are collected at the destination and reassembled to generatethe original (unfragmented) datagram.

    Fragments themselved can be further fragmented it they need to travelthrough networks with smaller and smaller MTUs.

  • 8/11/2019 IP Datagram Forwarding

    12/26

  • 8/11/2019 IP Datagram Forwarding

    13/26

  • 8/11/2019 IP Datagram Forwarding

    14/26

    Fragment Loss. Reassembly timer

    Because IP is unreliable, a fragment may get lost.

    Once the destination receives some fragment, it

    starts a timer (reassembly timer). If the timer

    expires before all the remaining fragments havearrived, it is assumed that some fragment was

    lost.

    All the fragments that have been accumulated upto the point when the reassembly timer expired

    are discarded.

  • 8/11/2019 IP Datagram Forwarding

    15/26

    Support Protocols

  • 8/11/2019 IP Datagram Forwarding

    16/26

    Address Resolution Protocol (ARP)

    Problem: Router A needs to forward an IPdatagram to router B (which is on the sameEthernet LAN).

    Router A knows the IP address of B. But the IP datagram must be encapsulated

    within an Ethernet frame, whose Ethernet

    destination address is the address of Bs NIC. How can A discover the Ethernet Address of

    Bs NIC?

  • 8/11/2019 IP Datagram Forwarding

    17/26

    ARP contd

    A uses theAddress Resolution Protocol (ARP) todiscover Bs NIC Ethernet address. It goes like this: A broadcasts an Ethernet frame on the LAN. The payload

    of the frame is an ARP request: who has address148.4.20.10 (Bs IP address).

    All computers in the LAN hear the broadcast.

    The computer whose IP address is 148.4.20.10 (B) repliesto A: my ethernet address is aa:bb:cc:dd:ee:ff.

    Now A has the ethernet address of Bs NIC, and can send

    the IP datagram to B encapsulated within an Ethernetframe with destination address aa:bb:cc:dd:ee:ff.

    ARP messages are encapsulated inside Ethernet frameshaving type 0x0806

  • 8/11/2019 IP Datagram Forwarding

    18/26

  • 8/11/2019 IP Datagram Forwarding

    19/26

    ARP message format

  • 8/11/2019 IP Datagram Forwarding

    20/26

    ARP caching

    ARP responses are cached.

    In the previous example, when A receives the reply from B,it makes an entry in ARP cache: 148.4.20.10 is ataa:bb:cc:dd:ee:ff. This is called an address binding.

    Next time an IP datagram needs to be forwarded to B, itfirst looks up the ARP cache. If the address binding isalready there, A doesnt need to send another ARP request.

    The ARP cache is flushed periodically, to make sure entries

    are always up-to-date (think about what would happen ifBs NIC needs to be replaced: the IP address of B does notchange, but the ethernet addr. of its NIC does)

  • 8/11/2019 IP Datagram Forwarding

    21/26

    Internet Control Message Protocol

    Used mostly for error-reporting at the IP level.

    For example, if the TTL of the IP datagram reaches 0when it reaches a router, the datagram is dropped bythe router, and the router sends an ICMP message backto the source of the datagram to inform it that thedatagram was dropped because its TTL reached 0 (TimeExceeded)

    If a router does not know how to route an IP datagram,

    it drops the datagram an send an ICMP message backto the source (Destination unreachable).

  • 8/11/2019 IP Datagram Forwarding

    22/26

  • 8/11/2019 IP Datagram Forwarding

    23/26

    Encapsulation of ICMP messages

  • 8/11/2019 IP Datagram Forwarding

    24/26

    ICMP Header

  • 8/11/2019 IP Datagram Forwarding

    25/26

    Dynamic Host Configuration Protocol

    (DHCP)

    Allows a computer to obtain an IP address andother parameters from a DHCP server.

    A DHCP server is a program running in some

    fixed computer in the LAN that has beenconfigured to assign IP addresses from a givenrange to other computers in the LAN thatrequest them.

    The DHCP server also provides things likedefault routes, and DNS server addresses.

  • 8/11/2019 IP Datagram Forwarding

    26/26

    DHCP relays

    DHCP requests are broadcasted within the local LAN(frame dest ff:ff:ff:ff:ff:ff)

    If the DHCP server is in a different LAN, the requestwont reach that server.

    One way around this is to configure some othercomputer in the LAN as a dhcp relay agent : the relaywill intercept the DHCP request and forward it to theDHCP server on the other LAN.

    Simplifies management, as only one DHCP sever needsto be configured for the entire network, rather thanhaving to configure separate DHCP servers for eachLAN.