The Network Layer
Table of Contents
- The Network Layer
- IP Addresses
- IP Datagrams and Encapsulation
- IP Address Classes
- Address Resolution Protocol
The Network Layer
On a local area network or LAN, nodes can communicate with each other through their physical MAC addresses. This works well on small scale because switches can quickly learn the MAC addresses connected to each other ports to forward transmissions appropriately. But MAC addressing isn't a scheme that scales well, every single network interface on the planet has a unique MAC address and they aren't ordered in any systematic way. There is no way of knowing where on the planet a certain MAC address might be at any one point in time, so it's not ideal for communicating across distances. Later on in this lesson, when we introduce ARP or Address Resolution Protocol, you'll see that the way that nodes learn about each other's physical addressing isn't translatable to anything besides a single network signet anyway. Clearly we need another solution, and that is the network layer, and the internet protocol or IP in the IP addresses that come along with it. By the end of this lesson you'll be able to take identify an IP address, describe how IP datagrams are encapsulated inside the payload of an ethernet frame and correctly identify and describe the many fields of an IP datagram header.
IP Addresses
IP addresses are a 32 bit long numbers made up of four octets, and each octet is normally described in decimal numbers. 8 bits of data or a single octet can represent all decimal numbers from 0 to 255.
For example, 12.30.56.78 is a valid IP address, but 123.456.789.100 would not be.because it has numbers larger than could be represented by 8 bits. This format is known as dotted decimal notation.
IP addresses belong to the networks, not the devices attached to those networks.
So your laptop will always have the same MAC address no matter where you use it, but it will have a different IP address assigned to it at an Internet cafe than it would when you're at home.
For now, remember that on many modern networks you can connect a new device and an IP address will be assigned to it automatically through a technology known as dynamic host configuration protocol. An IP address assigned this way is known as a dynamic IP address. The opposite of this is known as a static IP address, which must be configured on a node manually.
In most cases static IP addresses are reserved for servers and network devices, while dynamic IP addresses are reserved for clients. But there are certainly situations where this might not be true.
IP Datagrams and Encapsulation
IP Datagram
A highly structured series of fields that are strictly defined.
The two primary sections of an IP datagram are the header and the payload.
IP Datagram Header
Version field
The very first field is four bits, and indicates what version of Internet protocol is being used. The most common version of IP is version four or IPv4.
Version six or IPv6, is rapidly seeing more widespread adoption, but we'll cover that in a later module.
Header Length field
Almost always 20 bytes in length when dealing with IPv4.
Service Type field.
These eight bits can be used to specify details about quality of service or QoS technologies.
The important takeaway about QoS is that there are services that allow routers to make decisions about which IP datagram may be more important than others.
Total Length field.
It's used for exactly what it sounds like; to indicate the total length of the IP datagram it's attached to.
Identification field
A 16-bit number that's used to group messages together.
IP datagrams have a maximum size and you might already be able to figure out what that is. Since the Total Length field is 16 bits, and this field indicates the size of an individual datagram, the maximum size of a single datagram is the largest number you can represent with 16 bits: 65,535. If the total amount of data that needs to be sent is larger than what can fit in a single datagram, the IP layer needs to split this data up into many individual packets. When this happens, the identification field is used so that the receiving end understands that every packet with the same value in that field is part of the same transmission.
Flag field
Used to indicate if a datagram is allowed to be fragmented, or to indicate that the datagram has already been fragmented.
Fragmentation is the process of taking a single IP datagram and splitting it up into several smaller datagrams.
Fragmentation Offset field
Contains values used by the receiving end to take all the parts of a fragmented packet and put them back together in the correct order.
Time to Live (TTL) field.
Every time a datagram reaches a new router, that router decrements the TTL field by one. Once this value reaches zero, a router knows it doesn't have to forward the datagram any further. The main purpose of this field is to make sure that when there's a misconfiguration in routing that causes an endless loop, datagrams don't spend all eternity trying to reach their destination. An endless loop could be when router A thinks router B is the next hop, and router B thinks router A is the next hop, spoiler alert.An 8-bit field that indicates how many router hops a datagram can traverse before it's thrown away.
Protocol field.
Another 8-bit field that contains data about what transport layer protocol is being used.
The most common transport layer protocols are TCP and UDP
Header checksum field
A checksum of the contents of the entire IP datagram header.
Source and destination IP address fields
An IP Address and these fields are each 32 bits long.
IP options field
An optional field and is used to set special characteristics for datagrams primarily used for testing purposes.
Since the IP options field is both optional and variable in length
Padding field
A series of zeros used to ensure the header is the correct total size.
Encapsulation
This is exactly what the IP datagram is, and this process is known as encapsulation.IP Address Classes
IP addresses can be split into two sections, the network ID and the host ID.
The address class system is a way of defining how the global IP address space is split up. There are three primary types of address classes. Class A, Class B and Class C. Class A addresses are those where the first octet is used for the network ID and the last three are used for the host ID. Class B addresses are where the first two octets are used for the network ID, and the second two are used for the host ID. Class C addresses, as you might have guessed, are those where the first three octets are used for the network ID, and only the final octet is used for the host ID.
There are two other IP address classes, but they're not quite as important to understand. Class D addresses always begin with the bits 1110, and are used for multicasting, which is how a single IP datagram can be sent to an entire network at once. These addresses begin with decimal values between 224 and 239. Lastly, Class E addresses make up all of the remaining IP addresses. But they are unassigned and only used for testing purposes. In practical terms, this class system has mostly been replaced by a system known as CIDR or classless inter-domain routing. But the address class system is still in place in many ways and is important to understand for anyone looking for a well routed networking education. And you know we're all about that. So, don't worry, we'll be covering CIDR in a future lesson.
The number of addresses usable for addressing specific hosts in each network is always 2N - 2, where N is the number of rest field bits, and the subtraction of 2 adjusts for the use of the all-bits-zero host value to represent the network address and the all-bits-one host value for use as a broadcast address.Thus, for a Class C address with 8 bits available in the host field, the maximum number of hosts is 254.
Address Resolution Protocol
You now understand how both Mac addresses are used at the data link layer, and how IP addresses are used at the network layer. Now we need to discuss how these two separate address types relate to each other. This is where address resolution protocol or ARP comes into play.
ARP is a protocol used to discover the hardware address of a node with a certain IP address.
Once it IP datagram has been fully formed, it needs to be encapsulated inside an Ethernet frame. This means that the transmitting device needs a destination MAC address to complete the Ethernet frame header. Almost all network connected devices will retain a local ARP table.
An ARP table is just a list of IP addresses an the Mac addresses associated with them.
ARP table entries generally expire after a short amount of time to ensure changes in the network are accounted for.
References:
https://www.coursera.org/learn/computer-networking/lecture/AexeX/the-network-layer
https://www.coursera.org/learn/computer-networking/lecture/jn80L/ip-addresses
https://www.coursera.org/learn/computer-networking/lecture/C8EJ0/ip-datagrams-and-encapsulation
https://www.coursera.org/learn/computer-networking/lecture/FdoW7/ip-address-classes
https://www.coursera.org/learn/computer-networking/lecture/1NBYG/address-resolution-protocol
https://en.wikipedia.org/wiki/Classful_network
网友评论