# Internet layer

The internet layer is a group of internetworking methods, protocols, and specifications in the Internet protocol suite that are used to transport network packets from the originating host across network boundaries; if necessary, to the destination host specified by an IP address. The internet layer derives its name from its function facilitating internetworking, which is the concept of connecting multiple networks with each other through gateways.
The internet layer does not include the protocols that fulfill the purpose of maintaining link states between the local nodes and that usually use protocols that are based on the framing of packets specific to the link types. Such protocols belong to the link layer. Internet-layer protocols use IP-based packets.
A common design aspect in the internet layer is the robustness principle: "Be liberal in what you accept, and conservative in what you send" as a misbehaving host can deny Internet service to many other users.

## Purpose

The internet layer has three basic functions:
* For outgoing packets, select the next-hop host (gateway) and transmit the packet to this host by passing it to the appropriate link layer implementation;
* For incoming packets, capture packets and pass the packet payload up to the appropriate transport layer protocol, if appropriate.
* Provide error detection and diagnostic capability.
In Version 4 of the Internet Protocol (IPv4), during both transmit and receive operations, IP is capable of automatic or intentional fragmentation or defragmentation of packets, based, for example, on the maximum transmission unit (MTU) of link elements. However, this feature has been dropped in IPv6, as the communication endpoints, the hosts, now have to perform path MTU discovery and ensure that end-to-end transmissions don't exceed the maximum discovered.
In its operation, the internet layer is not responsible for reliable transmission. It provides only an unreliable service, and best effort delivery. This means that the network makes no guarantees about the proper arrival of packets. This in accordance with the end-to-end principle and a change from the previous protocols used on the early ARPANET. Since packet delivery across diverse networks is an inherently unreliable and failure-prone operation, the burden of providing reliability was placed with the endpoints of a communication path, i.e., the hosts, rather than on the network. This is one of the reasons of the resiliency of the Internet against individual link failures and its proven scalability. The function of providing reliability of service is the duty of higher-level protocols, such as the Transmission Control Protocol (TCP) in the transport layer.
In IPv4, a checksum is used to protect the header of each datagram. The checksum ensures that the information in a received header is accurate, however, IPv4 does not attempt to detect errors that may have occurred to the data in each packet. IPv6 does not include this header checksum, instead relying on the link layer to assure data integrity for the entire packet including the checksum.

## Core protocols

The primary protocols in the internet layer are the Internet Protocol (IP). It is implemented in two versions, IPv4 and IPv6. The Internet Control Message Protocol (ICMP) is primarily used for error and diagnostic functions. Different implementations exist for IPv4 and IPv6. The Internet Group Management Protocol (IGMP) is used by IPv4 hosts and adjacent IP multicast routers to establish multicast group memberships.

## Security

Internet Protocol Security (IPsec) is a suite of protocols for securing IP communications by authenticating and encrypting each IP packet in a data stream. IPsec also includes protocols for key exchange. IPsec was originally designed as a base specification in IPv6 in 1995, and later adapted to IPv4, with which it has found widespread use in securing virtual private networks.

## Relation to OSI model

Because the internet layer of the TCP/IP model is easily compared directly with the network layer (layer 3) in the Open Systems Interconnection (OSI) protocol stack, the internet layer is often improperly called network layer.

## IETF standards

* J. Postel, ed. (September 1981). INTERNET PROTOCOL - DARPA INTERNET PROGRAM PROTOCOL SPECIFICATION. IETF. doi:10.17487/RFC0791. STD 5. RFC 791. IEN 128, 123, 111, 80, 54, 44, 41, 28, 26. Internet Standard 5.
* J. Postel (September 1981). INTERNET CONTROL MESSAGE PROTOCOL - DARPA INTERNET PROGRAM PROTOCOL SPECIFICATION. Network Working Group. doi:10.17487/RFC0792. STD 5. RFC 792. Internet Standard 5.
* David D. Clark (July 1982). IP DATAGRAM REASSEMBLY ALGORITHMS. IETF. doi:10.17487/RFC0815. RFC 815. Unknown.
* David D. Clark (July 1982). FAULT ISOLATION AND RECOVERY. IETF. doi:10.17487/RFC0816. RFC 816. Historic.
* J. Postel (November 1983). The TCP Maximum Segment Size and Related Topics. Network Working Group. doi:10.17487/RFC0879. RFC 879. Obsolete.
* J. Mogul; J. Postel (August 1985). Internet Standard Subnetting Procedure. Network Working Group. doi:10.17487/RFC0950. STD 5. RFC 950. Internet Standard 5.
* S. Kent (November 1991). U.S. Department of Defense - Security Options for the Internet Protocol. Network Working Group. doi:10.17487/RFC1108. RFC 1108. Historic.
* S. Deering (August 1989). Host Extensions for IP Multicasting. Network Working Group. doi:10.17487/RFC1112. STD 5. RFC 1112. Internet Standard 5.
* R. Braden, ed. (October 1989). Requirements for Internet Hosts -- Communication Layers. Network Working Group. doi:10.17487/RFC1122. STD 3. RFC 1122. Internet Standard 3.
* R. Braden, ed. (October 1989). Requirements for Internet Hosts -- Application and Support. Network Working Group. doi:10.17487/RFC1123. STD 3. RFC 1123. Internet Standard 3.
* R. Bush; D. Meyer (December 2002). Some Internet Architectural Guidelines and Philosophy. Network Working Group. doi:10.17487/RFC3439. RFC 3439. Informational.