Monday 30 December 2013

IP introduction



IP Introduction

This is the study note for TCP/IP illustrated Volume I: the protocols chapter 3.

The Internet Protocol (IP) is the principal communications protocol in the Internet protocol suite for relaying datagrams across network boundaries. Its routing function enables internetworking, and essentially establishes the Internet. IP, as the primary protocol in the Internet layer of the Internet protocol suite, has the task of delivering packets from the source host to the destination host solely based on the IP addresses in the packet headers. 

There are two features of IP:

  • Unreliable: it means by the protocol, the IP delivery is not reliable, you can’t relied on the IP to make sure it is delivered correctly. The upper layer protocol eg (TCP) will provide the reliability for applications.
  • Connectionless: it means the protocol itself doesn’t provide a virtual connection for IP peers. Every package delivery is independent of each other.

1.      IP header:



Explain of IP headers:
IP was designed decades ago and quite a few ideas are not used any more. Here is the explaination of each field. The important fields are marked as bold.

  • Version: IP versions , usually 4
  • Header length: usually be 5.
  • TOS: not very often used. Usually 0x00.
  • Total length: the length of the whole IP package.
  • Identification: the IP package’s Identification.
  • IP flags:  threee bits:
  • first is resvered,
  • the second means don’t do fragment on the package.
  • The third mean there are more fragments (not used very often) usually 0
  • Fragment Offset: the offset of the package start of whole IP datagram.
  • TTL:  Time to live field, usually the most router hops a package can usually travel. When it reaches 0, the router/host should discard the package.
  • Protocol: indicates the package type, eg TCP or UDP.
  • Header Checksum: the checksum of the IP header
  • Source Address: the source IP address of the package, who sent the package
  • Destination Address:  the destination IP address of the package. Who should receive the package.
  • IP options:  not very often used.



IP header sample


This is the IP package I captured


So we will see

  • Version: 4
  • Header length: 5
  • TOS: 000
  • Total length: 90  
  • Identification: 0x3125
  • IP flags:  000
  • Fragment Offset: 0.
  • TTL:  122
  • Protocol: 6 (TCP)
  • Header Checksum: 369F (correct)
  • Source Address: 163.189.94.81
  • Destination Address:  192.168.22.35
  • IP options:  not used.

 IP routing: 

IP packages are travelling and delivered in between hosts via the network, it travels hop by hop. The device which transmits the packages are called Router.
the router contains routing table. The routing table usually have the below information:
  • Destination : either it is a host or a network address
  • Next hop: the next hop router’s IP address
  • Interface : the physical interface the
  • Flag: indicates it is a router or an interface The router table may contains other useful information it needs.
Usually the router will try to match the destination IP with the routing table, if not found, it will match the network/netmask, if not found, it will use the default gw if there is or discard if not.  
  

Useful commands:

#ifconfig                     // the command to specify/show the interface IP information.
eg: ifconfig –a
     ifconfig eth0

              #netstat                               //show linux network relate info.
                eg: netstat –an                 //show all activated connections
                      netstat –l                       //show the listening ports.
                      netstat –r                     //show the routing table

No comments:

Post a Comment