Lec10 Draft

  • Upload
    jinuel

  • View
    229

  • Download
    0

Embed Size (px)

Citation preview

  • 8/8/2019 Lec10 Draft

    1/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

    Application

    Transport

    Network

    LinkPhysical

    you arehere

  • 8/8/2019 Lec10 Draft

    2/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

    Network(host-to-host)

    Transport(process-to-process)

    Link(node-to-node)

  • 8/8/2019 Lec10 Draft

    3/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

  • 8/8/2019 Lec10 Draft

    4/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

    Network(host-to-host)

    Transport(process-to-process)

    Link(node-to-node)

    IP

    IP ICMP

    ICMP RoutingProtocols

    RoutingProtocols

  • 8/8/2019 Lec10 Draft

    5/48

    Network Layer

    The network layer provides communication between two

    end hosts. Its two main functions are routing (which path to

    take) and forwarding (who to forward a packet to). Network

    layer is implemented in all end hosts and intermediate

    routers.

    A packet can pass through different link layers technology

    (WiFi, Ethernet etc.) on its way to the destination.

    The Internets network layer consists of IP (handles

    addressing, packet format), ICMP (for information and error

    reporting), and routing protocols.

  • 8/8/2019 Lec10 Draft

    6/48

    NUS.SoC.CS2105

    Ooi Wei Tsang

    IPInternet Protocol

  • 8/8/2019 Lec10 Draft

    7/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

  • 8/8/2019 Lec10 Draft

    8/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

    V

  • 8/8/2019 Lec10 Draft

    9/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

    Datagram Length (bytes)

  • 8/8/2019 Lec10 Draft

    10/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

    TTL

  • 8/8/2019 Lec10 Draft

    11/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

    Protocol

  • 8/8/2019 Lec10 Draft

    12/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

    Header Checksum

  • 8/8/2019 Lec10 Draft

    13/48

    Internet Protocol (IP)

    Each IP datagram has a 20-byte header, consisting of header

    fields such as version number, datagram length, header

    checksum (similar to UDP/TCP checksum for only for IP

    header), time-to-live (decrease by one for every hop

    travelled, datagram is dropped when becomes 0 to prevent

    infinite loop), and upper-layer protocol ID (which protocol

    should deal with this packet).

  • 8/8/2019 Lec10 Draft

    14/48

    IP Addresses

  • 8/8/2019 Lec10 Draft

    15/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

    ID Offset F

  • 8/8/2019 Lec10 Draft

    16/48

    NUS.SoC.CS2105

    Ooi Wei Tsang

    Fragmentation

  • 8/8/2019 Lec10 Draft

    17/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

  • 8/8/2019 Lec10 Draft

    18/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

    Network(host-to-host)

    Transport(process-to-process)

    Link(node-to-node)

  • 8/8/2019 Lec10 Draft

    19/48

    NUS.SoC.CS2105

    Ooi Wei Tsang

  • 8/8/2019 Lec10 Draft

    20/48

    NUS.SoC.CS2105

    Ooi Wei Tsang

  • 8/8/2019 Lec10 Draft

    21/48

    Fragmentation

    Due to different maximum packet size at the link layer,

    routers may have to fragment IP datagrams before

    forwarding them. IP headers contains necessary information

    so that the destination host can put the fragments back

    together.

    IP header contains an ID field (increase by one for every

    packet sent by the sending host), a fragment bit (1 if more

    fragments to come, 0 if this is the last), and an offset

    (position in the original datagram, in units of 8-byte

    chunks).

  • 8/8/2019 Lec10 Draft

    22/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

    Source IP Address

    Dest IP Address

  • 8/8/2019 Lec10 Draft

    23/48

    NUS.SoC.CS2105

    Ooi Wei Tsang

    IP Addressassociated with an interface

  • 8/8/2019 Lec10 Draft

    24/48

    NUS.SoC.CS2105

    Ooi Wei Tsang

    4,294,967,296

  • 8/8/2019 Lec10 Draft

    25/48

    IP Addresses

    An IP address is associated with an interface (the boundary

    between a node and a physical link), not host. It is common

    for a host/router to have multiple IP addresses.

    IP address is a 32-bit ID, which must be globally unique

    across the Internet.

    IP addresses are organized into hierarchy, with IANA

    (Internet Assigned Numbers Authority) controlling the 1st

    level assignment.

  • 8/8/2019 Lec10 Draft

    26/48

    NUS.SoC.CS2105

    Ooi Wei Tsang

    Subnet

  • 8/8/2019 Lec10 Draft

    27/48

    NUS.SoC.CS2105

    Ooi Wei Tsang

    Subnet Mask

  • 8/8/2019 Lec10 Draft

    28/48

  • 8/8/2019 Lec10 Draft

    29/48

    NUS.SoC.CS2105

    Ooi Wei Tsang

    DHCP

    Dynamic Host ConfigurationProtocol

  • 8/8/2019 Lec10 Draft

    30/48

    NUS.SoC.CS2105

    Ooi Wei Tsang

    ForwardingTable

  • 8/8/2019 Lec10 Draft

    31/48

    Forwarding Table

    Forwarding table in a router stores pairs of (destination

    subnet, outgoing interface).

    Destination subnet is identified by subnet mask or prefix of

    IP addresses, and the longest prefix matching rule is used in

    case there are multiple entries that match the same

    destination address.

    To view routing table, on UNIX based system, run netstat -

    rn, on Windows XP, run route print.

  • 8/8/2019 Lec10 Draft

    32/48

    NUS.SoC.CS2105

    Ooi Wei Tsang

    NAT

    Network Address Translation

  • 8/8/2019 Lec10 Draft

    33/48

    NUS.SoC.CS2105

    Ooi Wei Tsang

    10.0.0.0/8

    172.16.0.0/12192.168.0.0/16

  • 8/8/2019 Lec10 Draft

    34/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

  • 8/8/2019 Lec10 Draft

    35/48

    Network Address Translation

    NAT mitigates the problem of IP address starvation by

    allowing hosts in a LAN to use private IP addresses (10/24,

    172.16/12, 192.168/16). A NAT-enabled router maps a (IP

    address, port) pair of a connection to a port on the router.

    The outside world (WAN) only sees the IP address of the NATrouter and talks to router (as if they are talking to the host

    inside LAN).

    The router modifies the network and transport-layer header

    packets between the LAN and WAN as the packets passthrough the router.

  • 8/8/2019 Lec10 Draft

    36/48

    ICMP

    ICMP is used by hosts and routers to communicate network-

    layer information to each other. ICMP messages are carried

    inside IP datagrams (so it lies above of IP in the stack). Each

    ICMP message has a type and a code field, which indicates

    what the message is for.

  • 8/8/2019 Lec10 Draft

    37/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

    Source IP Address

    Dest IP Address

  • 8/8/2019 Lec10 Draft

    38/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

    Network(host-to-host)

    Transport(process-to-process)

    Link(node-to-node)

    IPIP ICMPICMPRouting

    ProtocolsRouting

    Protocols

  • 8/8/2019 Lec10 Draft

    39/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

    Network(host-to-host)

    Transport(process-to-process)

    Link(node-to-node)

    IPIP

    ICMPICMPRouting

    ProtocolsRouting

    Protocols

  • 8/8/2019 Lec10 Draft

    40/48

    NUS.SoC.CS2105

    Ooi Wei Tsang

    ICMPInternet Control Message

    Protocol

  • 8/8/2019 Lec10 Draft

    41/48

    NUS.SoC.CS2105

    Ooi Wei Tsang

    ICMP(type, code)

  • 8/8/2019 Lec10 Draft

    42/48

    NUS.SoC.CS2105

    Ooi Wei Tsang

    Type Code What?

    8 0echo

    request

    0 0 echoreply

  • 8/8/2019 Lec10 Draft

    43/48

    NUS.SoC.CS2105

    Ooi Wei Tsang

    ping

  • 8/8/2019 Lec10 Draft

    44/48

    NUS.SoC.CS2105

    Ooi Wei Tsang

    Type Code What?

    3 1

    cannot

    reachhost

    3 3cannot

    reachport

  • 8/8/2019 Lec10 Draft

    45/48

    NUS.SoC.CS2105

    Ooi Wei Tsang

    Type Code What?

    11 0TTL

    expired

    12 0bad

    IPheader

  • 8/8/2019 Lec10 Draft

    46/48

    NUS.SoC.CS2105

    Ooi Wei Tsang

    traceroute

  • 8/8/2019 Lec10 Draft

    47/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

  • 8/8/2019 Lec10 Draft

    48/48

    NUS.SOC.CS2105

    Ooi Wei Tsang

    Network(host-to-host)

    Transport(process-to-process)

    Link(node-to-node)

    IPIP ICMPICMPRouting

    ProtocolsRouting

    Protocols