The Network Layer
Intro to the Network Layer
wow.. couldn't understand a word..
The Network Layer
On a local area network, or LAN, nodes communicate with each other through their Physical MAC addresses. However, when it comes to broader network, MAC address is hard to work with. Because every node has different MAC addresses, it is hard to found out where that MAC address actually is.
ARP (Address Resolution Protocol)
IP Addresses
32 bit long numbers made of 4 octets.
Every octet is represented in decimals. So, the numbers larger than could be represented by 8 bits will be invalid.
Dotted Decimal Notation
IP addresses belong to networks, not to the devices attached to those networks.
Dynamic Host Configuration Protocol
Dynamic IP Address <-> Static IP Address
In most cases, static IP addresses are reserved for servers and network devices while dynamic IP addresses are reserved for clients.
IP Datagrams and Encapsulation
IP Datagram
A highly structured series of fields that are strictly defined
- Version (4 bits) : The most common version of IP os version 4, or IPv4.
- Header Length Field (4 bits) : Almost always 20 bytes in length when dealing with IPv4
- Service Type Field (8 bits) : These 8 bits can be used to specify details about quality of service, or QoS, technologies.
- Total Length Field (16 bits) : Indicates the total length of the IP datagram it's attached to.
- Identification Field : 16-bit number that's used to group messages together. 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. This Identification Field is used so that the receiving end understands that every other packet with the same value in that field is part of that same transmission
- Flags (4 bits) : Used to indicate if a datagram is allowed to be fragmented, or to indicate that the datagram has already been fragmented. Fragmentatiton : The process of taking a single IP datagram and splitting it up into several smaller datagrams.
- Fragment Offset (12 bits) : contains values used by the receiving end to take all part of the fragmented packet and put them back together in correct order
- Time to Live (TTL) Field : An 8-bit field that indicates how many router hops a datagtam can traverse before it's thrown away.
- Protocol Field : Another 8-bit field that contains data about what transport layer protocol is being used. TCP, UDP.
- Header Checksum Field (16 bits) : A checksum of the contents of the entire IP datagram header.
- Source IP Address : 32 bits long
- Destination IP Address : 32 bits long
- IP Options Field : An optional field and is used to set special characteristics for datagrams primarily used for testing purposes
- Padding Field: A series of zeros used to ensure the header is the correct total size
Data Payload Section = IP datagram
Encapsulation
Application : [Message]
Transport : (TCP or UDP header) + [Message]
Network : (IP header) + [TCP segment or UDP datagram]
Data-link : (Ethernet header) + [IP datagram] + (Ethernet footer)
Entire contents of the IP datagram are encapsulated as the payload of an Ethernet frame.
IP datagram also has a payload section. The contents of this section is entirety of TCP or UDP packet.
Each layer is needed for the layer above it
IP Address Classes
IP addresses can be split into two sections: the network ID amd the host ID.
Network ID - First octet of an IP address
Host ID - Second, Third and Fourth octet of an IP address
If host ID's octets are all 1s, it is used as broadcast address. If host ID's octets are all 0s, it is used as network address.
Address class system
A way of defining how the global IP address space is split up
- Class A : those where the first octet is used for the network ID, last three is used for the host ID. In decimals, 0-127. In binary, it starts with 0 (0xxx xxxx. xxxx xxxx. xxxx xxxx. xxxx xxxx). It has (2β·) network IDs and (2Β²β΄ - 2) host IDs.
- Class B : first two octets are used for the network ID anr the second two are used for the host ID. In decimals, 128-191. In binary, it starts with 10 (10xx xxxx. xxxx xxxx. xxxx xxxx. xxxx xxxx). It has (2ΒΉβ΄) network IDs and (2ΒΉβΆ - 2) host IDs.
- Class C : first three octets are used for the network ID and the last octet is used for the host ID. In decimals, 192-223. In binary, it starts with 110 (110x xxxx. xxxx xxxx. xxxx xxxx. xxxx xxxx). It has (2Β²ΒΉ) network IDs and (2βΈ - 2) host IDs.
Address Resolution Protocol
ARP
A protocol used to discover the hardware address of a node with a certain IP address
Once the IP datagram is fully formed, it has to be encapsulated into an Ethernet frame. In this process, transmitting device needs Destination MAC address to complete the Ethernet frame header. Almost all network connected devices will retain a local ARP table.
ARP Table
A list of IP address and the MAC addresses associated with them
A host wants to send a data to an IP address, but it could be a case that this destination doesn't have an entry in the local ARP table. When this happens, the node that wants to send data sends a broadcast ARP message to a MAC broadcast address which is FF:FF:FF:FF:FF:FF. This message is delivered to all nodes on the local network. When the network interface that's been assigned in the particular IP address receives this ARP broadcast and send back what is known as ARP Response. This reponse message will contain MAC address for the network interface in question.
ARP table entries generally expire after a short amount of time to ensure changes in the network are accounted for.