Android Network programming Series A link layer of the TCP/IP protocol family

Source: Internet
Author: User

This reference article is mainly used for the diffusion of knowledge points in subsequent articles, in this special backup and diffusion learning Exchange.

There are three purposes of the data link layer:

    • Send and receive IP datagrams for IP modules.
    • Sends an ARP request and receives an ARP reply for the ARP module.
    • Send Rarp request and receive RARP response for Rarp

IP everyone has heard about it. As for ARP and RARP,ARP called Address Resolution Protocol, is the IP address for MAC address of a protocol, and Rarp is called Inverse Address Resolution Protocol, in the later section of the TCP/IP protocol will introduce them (in the LAN with the ARP protocol can be easily paralyzed network OH)

The protocol of the data link layer is still many, there are our most commonly used Ethernet (that is, we usually use the network card) protocol, there are less common token ring, and FDDI, of course, there are now quite popular in the domestic PPP protocol (ADSL broadband), as well as a loopback protocol.

Contact the ifconfig-a command in Linux, this command will usually get the following results

Eth0 Link encap:ethernet HWaddr 00:01:4a:03:5b:edinet addr:192.168.11.2 bcast:192.168.11.255 Mask:255.255.255.0inet6 ADDR:FE80::201:4AFF:FE03:5BED/64 scope:linkup Broadcast RUNNING multicast mtu:1500 metric:1rx packets:2819 errors:0 dropped:0 overruns:0 frame:0tx packets:76 errors:0 dropped:0 overruns:0 carrier:0collisions:0 Txqueuelen:1000RX bytes : 241609 (235.9 KiB) TX bytes:9596 (9.3 KiB) Lo Link encap:local loopbackinet addr:127.0.0.1 mask:255.0.0.0inet6 addr::: 1/1 Scope:hostup LOOPBACK RUNNING mtu:16436 metric:1rx packets:2713 errors:0 dropped:0 overruns:0 frame:0tx packets:2713 er rors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:0rx bytes:3516032 (3.3 MiB) TX bytes:3516032 (3.3 MiB)

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

Ethernet (ether-net) is defined as a standard published by Digital Equipment Corp., Intel Corp., and Xerox in 1982, which uses a standard known as csma/ The access method of the CD. The standard set of 802.3 (which is also defined in 802.2) provided by IEEE802 also provides a CSMA/CD standard. These two standards are slightly different, and the TCP/IP protocol handles this situation as follows:

    • IP Datagram Encapsulation for Ethernet is defined in RFC894, while the IP datagram of the IEEE802 network is encapsulated in RFC1042.
    • A host must be able to send and receive RFC894-defined datagrams.
    • A host can receive mixed datagrams in the encapsulated format of RFC894 and RFC1042.
    • A host may be able to send RFC1042 datagrams. If the host can send two types of grouped data at the same time, the packets sent must be set up, and the default condition must be RFC 894 grouping.

Visible, RFC1042 in TCP/IP inside a supporting role in the status. Please refer to the teaching materials for these two different data-reporting formats.

PPP (Point-to-Point protocol) is a replacement from slip. They all offer a low-speed access solution. Each data link layer protocol has an MTU (maximum transmission Unit) definition, under which the IP datagram is too large to be fragmented (fragmentation) so that each slice is less than the MTU, noting that the MTU of PPP is not a physical definition, It refers to a logical definition (which is considered by the individual to be programmed). You can use Netstat to print out the MTU results, such as typing netstat-in

1234 Kernel Interface tableIface       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 BMRUlo        16436   0     2667      0      0      0     2667      0      0      0 LRU

  

It is possible to observe that the MTU of Eth0 is 1500. The MTU of the LO (loopback interface) is 16436.

Finally, say the loopback interface (loopback). Usually we use 127.0.0.1来 try your own machine server so that it doesn't work. This is the loopback interface to go. For loopback interfaces, there are three points worth noting:

    • Any data passed to the loopback address (typically 127.0.0.1) is entered as I p.
    • A copy of the datagram transmitted to the broadcast address or multicast address is sent to the loopback interface and then to the Ethernet. This is because the definition of broadcast delivery and multicast delivery contains the host itself.
    • Any data passed to the host IP address is sent to the loopback interface.

Android Network programming Series A link layer of the TCP/IP protocol family

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.