Learning Center
Plans & pricing Sign in
Sign Out
Your Federal Quarterly Tax Payments are due April 15th Get Help Now >>



									           Packet Switch Network

           IP                        IP

                             IP             IP

Ether IP   TCP        Data

         TCP/IP Layering

         Socket Library

      TCP                 UDP          Layer 4 / Transport

ARP    RARP        IP           ICMP   Layer 3 / Network

   Ethernet               PPP          Layer 2 / Data Link

Network card              Com          Layer 1 / Physical

             application        application   application   application

ICMP     IGMP              TCP                 UDP

       ARP                 IP                 RARP

                                incoming frame
                type     data    CRC

6         6      2     64-1500   4
    dst   src
                      IP Address
                7 bits                       24 bits
Class A   0     netid                        hostid

                         14 bits                  16 bits
Class B
          1 0             netid                    hostid
                                   21 bits                  8 bits
Class C   1 1 0                    netid                    hostid
                                         28 bits
Class D   1 1 1 0                  multicast group ID

  IP Address/Physical Address

• Static Mapping
  – IP broadcast address maps to Ethernet
    broadcast address)
  – IP Multicast Address maps to Ethernet
    Multicast Address
     • lower 23bits of class D IP map into the lower
       23bits of Ethernet address 01:00:5e:00:00:00
• Dynamic Mapping
  – ARP
  – RARP

• Address Resolution Protocol
• RFC-826
• Mapping between IP address and the
  physical address(such as MAC)
     ARP/RARP Packet Format
            0                         16                      31
               hard type              proto type
             HLEN PLEN                  op
                   sender ethernet address
            sender ether addr       sender IP addr
             sender IP addr       target ether addr
                    target ethernet address
                       target IP address
Hardware type = 1 : Ethernet
Protocol type = 080016: IP address
HLEN: hardware address length = 6 : Ethernet MAC address length
PLEN: protocol address length = 4 : IP address length
OP(operation): 1: ARP request, 2: ARP response, 3: RARP request, 4: RARP
           How it works ?

                                             To :
                          ARP           IP
                                Ethernet
Ethernet          Ethernet

ARP           ARP           IP


• Internet Protocol

      TCP   UDP    ICMP    IGMP

ARP               IP

            PPP        Ethernet

•   Internet Protocol
•   RFC-791
•   Unreliable
•   Connectionless
•   Dispatch packet to upper protocol
•   Fragmentation & Assembly
•   Routing
                         Packet Format
        0                            15 16                            31
         VERS HLEN      TOS        total length
            identification    flag fragment offset
             TTL      protocol header checksum                                 20 bytes
                           source IP address
                         destination IP address
                            options(if any)
VERS = 4 : IPv4 Protocol
HLEN: times of 32-bit, if no options, the HLEN = 5
total length : the total length of the IP datagram, so the data-length of this packet is
               total length - HLEN *4
TOS: type of service 0 1 2 3 4                   5     6 7
                          precedence D      T   R     unsed
precedence: ranging from 0 through 7, indicate the importance of each datagram.
allow the router to implement congestion control algorithm
D: low delay requests        T: high throughput       R: high reliability
              Packet format

• Version : 4
• Header length : number of 32-bit words
• TOS : 3-bit precedence, 4 TOS bits, 1 unused
• Identification : uniquely identifies each datagram
  sent by host
• flags : more fragments
• fragment offset : offset from original datagram
• TTL : time to live
          0 1 2      3 4 5     6 7
         Precedence D T R      0   0

Bit 0-2: Precedence.
Bit 3: 0 = Normal Delay, 1 = Low Delay.
Bit 4: 0 = Normal Throughput, 1 = High Throughput.
Bit 5: 0 = Normal Relibility, 1 = High Relibility.
Bit 6-7: Reserved for Future Use.

111 - Network Control              011 - Flash
110 - Internetwork Control         010 - Immediate
101 - CRITIC/ECP                   001 - Priority
100 - Flash Override               000 - Routine
                       Flags & Fragment

         • Flags : 3 bits
                    0 1 2
                    0 DF MF

              Bit 0: reserved, must be zero
              Bit 1: (DF) 0 = May Fragment, 1 = Don't Fragment.
              Bit 2: (MF) 0 = Last Fragment, 1 = More Fragments.

         • Fragment Offset: 13 bits
              – Unit : 8 octets (64 bits)
offset of the data in multiples of eight octets, the fragment size must be chosen to be a
multiple of eight.
       Protocol number

• IPPROTO_ICMP        1
  IPPROTO_IGMP        2
  IPPROTO_TCP         6
  IPPROTO_RSVP        46
         Header Checksum

• How to calculate ?
  – checksum field = 0
  – sum of 16-bit words
  – checksum = 1’s complement of sum
• How to verify ?
  – receiver calculate the checksum should be
    0xffff (?, 0x0000)

• MTU:Maximum Transmission Unit
  – Ethernet : 1500
  – FDDI : 4352
  – IEEE 802.3/802.2 : 1492
• Path MTU
  – smallest MTU of any data link that packets
    traverse between the two hosts
  Fragmentation Algorithm
    FO - Fragment Offset
    IHL - Internet Header Length
    DF - Don't Fragment flag
    MF - More Fragments flag
    TL - Total Length
    OFO - Old Fragment Offset
    OIHL - Old Internet Header Length
    OMF - Old More Fragments flag
    OTL - Old Total Length
    NFB - Number of Fragment Blocks
    MTU - Maximum Transmission Unit
            Fragmentation Algorithm

       IF TL =< MTU THEN Submit this datagram to the next step
              in datagram processing ELSE IF DF = 1 THEN discard the
           datagram ELSE
           To produce the first fragment:
           (1) Copy the original internet header;
           (2) OIHL <- IHL; OTL <- TL; OFO <- FO; OMF <- MF;
           (3) NFB <- (MTU-IHL*4)/8;
           (4) Attach the first NFB*8 data octets;
           (5) Correct the header:
              MF <- 1; TL <- (IHL*4)+(NFB*8);
              Recompute Checksum;
           (6) Submit this fragment to the next step in
              datagram processing;

the length of data field in the IP packet must be the times of eight
                 Fragmentation Algorithm
To produce the second fragment:
    (7) Selectively copy the internet header (some options
       are not copied, see option definitions);
    (8) Append the remaining data;

    (9) Correct the header:
       IHL <- (((OIHL*4)-(length of options not copied))/4;
       TL <- OTL - NFB*8 - (OIHL-IHL)*4); //previous sent and options not copied
       FO <- OFO + NFB; MF <- OMF; Recompute Checksum;
    (10) Submit this fragment to the fragmentation test; DONE.
          Internet datagram options
•   The IP OPTIONS field is variable length.
•   The PADDING field depends on the options selected.
•   The IP OPTIONS field is used for testing or debugging.
•   Each option consists of a single octet option code, which
    may be followed by a single octet length and a set of data
    octets for the option.

COPY bit 1: the option should be copied into all fragments.
        0 : the option should only be copied into the first fragment and not
            into all fragments.
         Record Route Option
• The RECORD ROUTE OPTION allows the
  source to create an empty list of IP addresses and
  arrange for each router that handles the datagram
  to add its IP address to the list.
• CODE field = 7 means option class = 0, option
  number = 7 for record route
• LENGTH field specifies the total length of the option
  as it appears in the IP datagram, including the first
  three octets.
• The POINTER field specifies the offset within the
  option of the next available slot.
• If the pointer is greater than the length, the list is full,
  so the machine forwards the datagram without
  inserting its entry. It the list is not full, the machine
  inserts its 4-octet IP address at the position specified
  by the POINTER, and increments the POINTER by
         source Route Options
• It provides a way for the sender to dictate a path
  through the internet.
• IP supports two forms of source routing. One form,
  called strict source routing, specifies a routing
  path by including a sequence of IP addresses in the
• strict source routing means that the addresses
  specify the exact path the datagram must follow to
  reach its destination. The path between two
  succcessive addresses in the list must consist of a
  single physical network; an error results if a router
  cannot follow a strict source route.
• The other form, called loose source routing, also
  includes a sequence of IP addresses. It specifies
  that the datagram must follow the sequence of IP
  addresses, but allows multiple network hops
  between successive addresses on the list.
              Timestamp Option
• The timestamp option works like the record route option
• Timestamps give the time and date at which a router
  handles the datagram expressed as milliseconds since
  midnight, Universal Time.
                   IP routing

routing     route  netstat
daemon    command command
                                   UDP          TCP

    routing                                input
                       IP output
     table                                 queue
              Routing Principles
          RouteDatagram(Datagram, RoutingTable)
extract destination IP address, D, from the datagram
             and compute the network prefix, N;
If N matches any directly connected network address
        deliver datagram to destination D over that network
else if the table contains a host-specific route for D
               send data gram to next-hop specified in table
else if the table contains a route for network N
               send datagrram to next-hop specified in table
else if the table contains a default route
       send datagram to the default router specified in table
else declare a routing error;
              Simple Routing Table

• netstat -rn

Destination     Gateway         Flags Refcnt Use    Interface   UGH   0      0      emd0       UH    1      0      lo0
default   UG    0      0      emd0   U     4     25043   emd0
           Routing Protocol

•   RIP v1/v2
•   OSPF
•   BGP

 • Internet Control
   Message Protocol

      ping program

TCP    ICMP          UDP


• Internet Control Message Protocol
• RFC-792
• Query Message
  – Echo request and Echo reply message
• Error Message
  – Destination Unreachable message
  – Redirect message
                  ICMP Type
Type   Message Type    Type   Message Type

0      Echo reply      13     Timestamp
3      Destination     14     Timestamp reply
4      Source quench   15     Information
5      Redirect        16     Information reply

8      Echo request    17     Address mask
11     Time exceeded   18     Address mask
12     Parameter
          ping Echo request msg                      Echo reply msg

               0                       15 16                    31
                   8 or 0          0           checksum
                      identifier           sequence number

                                   option data

• OPTIONAL Data: is a variable length field that contains data to be returned to
  the sender. An echo reply always returns exactly the same data as was received
  in the request.
• IDENTIFIER and SEQUENCE NUMBER are used by the sender to match
  replies to requests.
             Destination Unreachable
When a router cannot forward or deliver an IP datagram, it sends a destination unreachable
message back to the original source.

                     pkt                            Unreachable msg
                                      internet                          R

              0                      15 16                          31
                    3            0-12      checksum
                                    unused (0)

                        IP header +
                        64 bits of original IP datagram
         Destination Unreachable
0 Net Unreachable
1 Host Unreachable
2 Protocol Unreachable
3 Port Unreachable
4 Fragmentation Needed and Don't Fragment was Set
5 Source Route Failed
6 Destination Network Unknown
7 Destination Host Unknown
8 Source Host Isolated
9 Communication with Destination Network is Administratively Prohibited
10 Communication with Destination Host is Administratively Prohibited
11 Destination Network Unreachable for Type of Service
12 Destination Host Unreachable for Type of Service

        R2             ‚             R1
           „           Redirect msg    

0                    15 16                31
    5          0-3           checksum
              router ip address

        IP header +
        64 bits of original IP datagram
ROUTER INTERNET ADDRESS field contains the address of a router that
the host is to use to reach the destination mentioned in the datagram header.

     Code Value                    Meaning
         0          Redirect datagrams for the Net (now obsolete)
         1          Redirect datagrams for the Host
         2          Redirect datagrams for the Type of Service and Net
         3          Redirect datagrams for the Type of Service and Host
                      Time Exceeded
                                      Time exceeded msg
                                             TTL = 1

         0                    15 16                     31
             11         0 or 1      checksum                   Destination

                           unused (0)

                  IP header +
                  64 bits of original IP datagram

         Code Value            Meaning
             0             Time-to-Live count exceeded
              1            Fragment reassembly time exceeded
                           Source Quench

Source, send fast
                                              Source quench msg
                                                                  Buffer full

             0                       15 16                  31
                    4          0              checksum
                                 unused (0)

                        IP header +
                        64 bits of original IP datagram

To top