The Internet Protocol (IP) provides a means to deliver data from a source to a destination. It uses the concept of source and destination IP addresses to identify the communicating entities. The IP protocol is basically a connectionless protocol, that is, the IP protocol layer stores no state or information about the packets (otherwise known as the IP datagrams) that it receives.
IP merely forwards all in-bound data packets to the immediately higher layer, that is, to the TCP or UDP layers (explained later). These could be data packets carrying a response from the server. In the reverse direction, these would be packets supplied by the higher protocol layers to the device driver, for example, the HTTP request sent by the web browser.
When communicating over a network, reliability is of interest to us. Reliability is the ability to transfer data packets so that data is not lost in transit. In practice, a zero-loss transmission of packets is difficult or even impossible to achieve, especially so in the case of TCP/IP networks which can be comprised of many different machine architectures, operating systems, and physical networks.
Reliability is often achieved through acknowledgment and retransmission schemes, more of which we shall see in the next section. The IP protocol does not focus on reliable delivery of the data packets. This doesn't mean that it does not have any interest in reliably delivering data packets. This means that the IP layer leaves it to the higher layers to take care of reliable delivery. Instead it mainly focuses on the following aspects of data delivery:
Packet size and fragmentation
Data is sent and received in units that are most suited to the application. For example, telnet may send only a few bytes of data at a time over the wire, while an application such as FTP would send several kilobytes at a time. The size of a data packet is finite and is influenced by the size of the data packets supported by the underlying network hardware, for example, Ethernet. Matters are further complicated because not all networks that exist between the two communicating machines have the same data delivery unit (or protocol delivery unit).
Routing
A company's network may contain a subnet which in turn may connect to an external network which is another subnet. To reach a destination, an IP packet often needs to traverse several subnets. A router is a TCP/IP host that is connected to at least two subnets and allows traffic to pass from one subnet to the other. When an IP packet leaves the host machine, the only address information it has is the source and destination IP address. The routing logic of the IP protocol present on both the source machine and the intermediate routers along the path to the destination host direct the packet to its destination.
Time-to-Live
Data packets cannot infinitely circulate in a network, they have to be either delivered or discarded after a while. The IP layer ensures this by maintaining a time-to-live (TTL) attribute for each data packet. When the IP layer on a machine sends a packet it sets the TTL value to a certain number and every subsequent IP layer that encounters the packet decrements the TTL value. When the TTL value reaches zero, the packet is discarded. The TTL value is selected such that only packets that are wrongly routed would end up with their TTL being decremented to zero.