Internet 5-Layer protocol--Re-learning computer network

Source: Internet
Author: User

The lessons of the study were passed, and later all were to be.

or refer to Nanyi's article first to remember, when needed to supplement the "Computer network," The contents of the book

Http://www.ruanyifeng.com/blog/2012/05/internet_protocol_suite_part_i.html

The rules that everyone follows are called protocols, and the core of the Internet is a series of protocols, often called "Internet Protocols" (Internet Protocol Suite).

They make detailed provisions on how computers are connected and networking. Understanding the protocols, we understand the principles of the Internet.

# Five-layer model

The teacher of broadband communication Network Course said, the important is not 3 layer 5 Layer 7 layer, the important is the thought of stratification. It is not only valuable for the Internet Protocol to disassemble the function.

Seven layer is actually more perfect, but design out, five layer already ruled the earth, scientific research AO however market. Ha ha.

So from the user to the underlying hardware is as follows: (Chinese translation has a difference, English is the same)Ps:layer and level difference?

  • Application tier (Application layer)
    • Specify the data format of the application; Receive data from the "Transport layer" for interpretation.
    • For example, the TCP protocol can pass data to a variety of programs, such as email, WWW, FTP, and so on. Then there must be different protocols for the format of e-mail, Web pages, FTP data, and these application protocols constitute the "Application layer".
    • Directly facing the user. Data is placed in the "Data" section of the TCP packet
  • The Transport layer (Transport layer)
    • Locate the host after port, the packet and the specific program match: 0-65535, 16 binary
    • 0-1023 is occupied by the system. The application randomly selected a
    • Host + port: socket (socket)
    • UDP Specifies the packet format, head+data into the IP data. Head defines the issuing port and the receive port with a total length of not more than 65535 bytes
    • TCP approximation has the acknowledgement mechanism of UDP, the implementation is complex. Also embedded in the IP packet data, the packet has no length limit, but in order to ensure the efficiency of the network, usually do not exceed the IP packet, to ensure that a single TCP packet no longer split.
  • Network layer
    • Sending data with MAC address is defective: the broadcast is inefficient, only in the subnet
    • So: In-subnet broadcast, inter-network routing (how to distribute packets to different sub-networks)
    • Network Address--determine the computer's debut network
    • The protocol that specifies the network address is called the IP protocol. The address that it defines is called an IP address. At present, the widely used is the fourth edition of IP protocol, referred to as IPV4. This version stipulates that the network address consists of 32 bits.

    • IP Address (Network + host) and subnet mask bit with the get subnet address
    • Head + data is placed in the (encapsulated) Link layer data, head 20-50 bytes, the total length of the maximum 65535 bytes, so that an IP packet may be split into multiple link layer Ethernet packets
  • Link layers (link layer)
      • In various hegemony, the Ethernet (Ethernet) protocol wins, including data grouping, device address, sending method
      • Data grouping: such as: How many 0, 1 counts a group? What do you mean, each signal bit? --a set of electrical signals consisting of a frame, including Head and Data:head 18 bytes, containing packet description items (transceiver, data type, etc.); data46-1600 bytes
      • Address: All the devices connected to the network have a NIC, the network Card Factory has a MAC address, that is, 48-bit two-mechanism address (12 hexadecimal digits, manufacturer + Network card number)
      • How do you know about MAC?
        • Different subnets of the computer do not know the other side of the MAC address, can only be sent to gateways (gateway);
        • Within the same subnet, ARP: broadcast a packet with the destination IP, Mac location fill FF:FF:FF:FF:FF:FF represents the broadcast, IP match on the computer will reply to their own MAC, otherwise discarded.
      • Data sending: Broadcast (broadcasting), sent to all computers within the network
    • Physical layers (physical layer)
      • The use of physical means (optical cable, cable, twisted pair, radio) to connect the computer to provide electrical characteristics, responsible for transmitting 0, 1 electrical signals (high and low level)

# question: Why use MAC address, direct IP not all can find host? When is UDP when is TCP

Below from the user's point of view:

    • Static IP Address
      • Native IP Address
      • Subnet mask
      • IP address of the gateway
      • IP address of DNS
    • Dynamic IP Address
      • DHCP protocol automatically assigns IP addresses: in each sub-network, one computer is responsible for managing all IP addresses of the network, the "DHCP server". When a new computer joins the network, a "DHCP request" packet must be sent to the "DHCP server" requesting the IP address and the associated network parameters.
      • If two computers are on the same subnet, you must know the other's MAC address and IP address to send the packet. However, the newly added computer does not know these two addresses, how to send a packet?
        • DHCP is the application-layer protocol, above the UDP protocol, so the "DHCP request" packet is

        • Ethernet header, sets the MAC address of the issuing party (native) and the MAC address of the receiver (DHCP server). The former is the MAC address of the local network card, the latter filled in ff-ff-ff-ff-ff-ff.
        • "IP Header" later, set the IP address of the sender and the IP address of the receiver. At this time, for both, this machine is not known. The IP address of the issuing party is then set to 0.0.0.0, and the IP address of the receiver is set to 255.255.255.255.
        • The last "UDP header" that sets the port of the issuing party and the port of the receiver. This section is provided by the DHCP protocol, which is port 68 and the receiver is port 67.
        • The DHCP server reads the data contents of the packet, assigns the IP address, and sends back a "DHCP response" packet. The structure of this response packet is similar, the Ethernet header MAC address is the network card address of both sides, IP header IP address is the DHCP server IP address (sender) and 255.255.255.255 (receiver), The UDP header port is 67 (sender) and 68 (receiver), the IP address assigned to the requester side and the specific parameters of the network are included in the data section.

One instance: accessing Web pages

    • The user has set up their own network parameters:

* The IP address of the machine: 192.168.1.100
* Subnet Mask: 255.255.255.0
* IP Address of the gateway: 192.168.1.1
* DNS IP address: 8.8.8.8

    • Open the browser and enter the URL: www.google.com The browser is sending a Web request packet to Google.
    • The DNS protocol can help us to convert this URL into an IP address. The DNS server is known to be 8.8.8.8, so we send a DNS packet (53 port) to this address. Then, the DNS server responds and replies to Google's IP address is 172.194.72.105 why is UDP

    • Next, determine if the IP address is in the same subnet
      • The known subnet mask is 255.255.255.0 (DNS also replies to Google's subnet mask?). ), to the IP address of their own Google's IP address and operation, two results are not equal, so Google and this machine is not the same subnet.
      • Therefore, we want to send a packet to Google, must be forwarded through the gateway 192.168.1.1, that is, the receiver's MAC address will be the gateway's MAC address.
    • The application-layer protocol, which uses the HTTP protocol to browse the Web, constructs the entire packet: why TCP

The contents of the HTTP section are similar to the following:

get/http/1.1
Host:www.google.com
Connection:keep-alive
user-agent:mozilla/5.0 (Windows NT 6.1) ...
accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-encoding:gzip,deflate,sdch
accept-language:zh-cn,zh;q=0.8
accept-charset:gbk,utf-8;q=0.7,*;q=0.3
Cookies: ...

We assume that the length of this part is 4960 bytes and it will be embedded in the TCP packet.

    • TCP protocol
      • TCP packets need to set the port, the receiver (Google) HTTP port is 80 by default, the sender (native) port is a randomly generated integer between 1024-65535, assumed to be 51775
      • The header length of the TCP packet is 20 bytes, plus the packet embedded in HTTP, the total length becomes 4980 bytes.
    • IP protocol
      • Then, the TCP packet is then embedded in the IP packet. IP packets need to be set up on both sides of the IP address, which is known, the sender is 192.168.1.100 (native) and the receiver is 172.194.72.105 (Google). The header length of the IP packet is 20 bytes, plus the embedded TCP packet, the total length becomes 5000 bytes.
    • Ethernet Protocol
      • Finally, the IP packet is embedded in the Ethernet packet. Ethernet packet needs to set the MAC address of both sides, the sender is the local network card MAC address, the receiver is the gateway 192.168.1.1 MAC address (through the ARP protocol).
      • The data portion of the Ethernet packet, the maximum length is 1500 bytes, and now the IP packet length is 5000 bytes. Therefore, IP packets must be split into four packets. Because each package has its own IP header (20 bytes), the length of the IP packets for the four packets is 1500, 1500, 1500, 560, respectively.

    • Server-side response
      • After the forwarding of multiple gateways, Google's server 172.194.72.105, received the four Ethernet packets.
      • According to the IP header number, Google put four packages together, take out the full TCP packet, and then read the inside of the "HTTP request", and then make "HTTP response", and then sent back with the TCP protocol.
      • After the native HTTP response is received, the Web page can be displayed to complete a network communication.

Internet 5 layer Protocol-re-learning computer network

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.