TCP/IP Study Notes (2) – Data Link Layer

TCP/IP Study Notes (2) - Data Link Layer

The Data Link Layer Has Three Purposes:

  • To send and receive IP datagrams for the IP module.

  • To send ARP requests and receive ARP responses for the ARP module.

  • To send RARP requests and receive RARP responses.

Everyone has heard of IP. As for ARP and RARP, ARP stands for Address Resolution Protocol, which is a protocol for converting an IP address to a MAC address, while RARP stands for Reverse Address Resolution Protocol. They will be introduced in later chapters of the TCP/IP protocol (ARP can easily paralyze the network in a local area network).

There are many protocols at the data link layer, including the most commonly used Ethernet (the network card we usually use), less common Token Ring, and FDDI. Of course, there is also the PPP protocol (used in ADSL broadband), which is quite popular in China, as well as a loopback protocol.

Referring to the command ifconfig -a in Linux, this command usually produces the following output:

eth0 Link encap:Ethernet HWaddr 00:01:4A:03:5B:ED
inet addr:192.168.11.2 Bcast:192.168.11.255 Mask:255.255.255.0
inet6 addr: fe80::201:4aff:fe03:5bed/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2819 errors:0 dropped:0 overruns:0 frame:0
TX packets:76 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:241609 (235.9 KiB) TX bytes:9596 (9.3 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:2713 errors:0 dropped:0 overruns:0 frame:0
TX packets:2713 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3516032 (3.3 MiB) TX bytes:3516032 (3.3 MiB)

Here, eth0 is the Ethernet interface, while lo is the loopback interface. This indicates that this host supports at least the loopback protocol and Ethernet protocol at the network link layer.

Ethernet refers to a standard jointly announced by Digital Equipment Corp., Intel Corp., and Xerox Corp. in 1982, which uses a method called CSMA/CD for access. The IEEE802 standard set 802.3 (with some definitions included in 802.2) also provides a CSMA/CD standard. These two standards are slightly different, and the TCP/IP protocol handles this situation as follows:

  • The Ethernet IP datagram encapsulation is defined in RFC894, while the IEEE802 network IP datagram encapsulation is defined in RFC1042.

  • A host must be able to send and receive datagrams defined in RFC894.

  • A host can receive mixed datagrams of both RFC894 and RFC1042 encapsulation formats.

  • A host may be able to send RFC1042 datagrams. If a host can send both types of packets, the sent packets must be configurable, and by default, they must be RFC894 packets.

It can be seen that RFC1042 plays a supporting role in TCP/IP. For these two different datagram formats, please refer to the textbook.

PPP (Point-to-Point Protocol) is a replacement for SLIP. They both provide a low-speed access solution. Each data link layer protocol has a defined MTU (Maximum Transmission Unit). If the IP datagram is too large, it must be fragmented so that each fragment is smaller than the MTU. Note that the MTU for PPP is not a physical definition, but a logical definition (which I believe is controlled by software). You can use netstat to print the MTU results, for example, by typing netstat -in.

Kernel Interface table
Iface  MTU  Met  RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flgeth0  1500   0   1774    0      0      0     587     0      0     0    BMRU
lo    16436  0   2667    0      0      0     2667    0      0     0    LRU

You can observe that the MTU for eth0 is 1500, while the MTU for lo (loopback interface) is 16436.

Finally, let’s talk about the loopback interface. We usually use 127.0.0.1 to test whether our machine’s server is working or not. This goes through the loopback interface. There are three points to note about the loopback interface:

  • Any data sent to the loopback address (usually 127.0.0.1) is treated as IP input.

  • Datagrams sent to broadcast or multicast addresses are copied to the loopback interface and then sent to Ethernet. This is because the definitions of broadcast and multicast include the host itself.

  • Any data sent to the host’s IP address is sent to the loopback interface.

This chapter is still very simple and generally provides enough knowledge for understanding; there is no need to go into too much detail.

Every Lesson You Learn Should Be Rewarding

“Learning Linux This Way” is a high-quality self-study tutorial on Linux technology written by senior operations and maintenance expert Liu Chuan and several Red Hat architects (RHCA) based on the latest RHEL7 system. It is extremely suitable for use as an introductory tutorial or teaching auxiliary material for Linux technology. It won the IT category book sales championship during the Double Eleven and Double Twelve shopping festivals and was the fastest-growing technical book among domestic readers in 2017 and 2018. You can search for the book title on JD, Dangdang, Amazon, and Tmall to purchase it, or you can add Liu Chuan’s WeChat for learning exchanges (just press and hold the image below for 3 seconds to scan automatically)~

TCP/IP Study Notes (2) - Data Link Layer

Liu Chuan’s QQ: 5604215

Linux Technical Exchange Group: 560843 ( New group, hot group joining… )

Official Site: www.linuxprobe.com

☀ Online Learning of the Book (better reading effect on computer):

http://www.linuxprobe.com/chapter-00.html

“Learning Linux This Way” is a technical book written based on the latest Linux system, aimed at readers with no background. It starts with basic Linux knowledge and gradually increases the content difficulty, detailing the working principles and configuration methods of various services in the Linux system to meet the demands of actual production environments for operation and maintenance personnel, highlighting the practicality of the content. Readers who want to learn the Linux system can click the “Read the Original” button to learn about this book. This book is also suitable for professional operations and maintenance personnel as a highly valuable reference tool!

Leave a Comment