Getting Started with Internet protocols

Source: Internet
Author: User

We use the Internet every day, how is it implemented?

The core of the Internet is a series of protocols that collectively "Internet Protocol" Internet Protocol suite.

1: Overview

1.1 Five-layer model

The realization of the Internet, divided into several layers, each layer has its own function, each layer on the next layer of support

How to layered with different models, some divided into seven layers, but divided into 5 layers is relatively easy to understand

    • Application tier (Application layer)
    • The Transport layer (transport layer)
    • Network layer
    • Link Layer
    • Physical layers (physical layer)

The lower, the closer the hardware, the higher the upper, the closer the user!

Layer 1.2 and Protocol

Every layer of the Internet defines a lot of protocols, which are called "Internet Protocol" Internet Protocol.

    1. Physical layer, physical layer

Is the physical means of connecting the computer, he mainly stipulates some electrical characteristics of the network, the role is responsible for 0,1 electrical signals

2. Link Layer

Pure 0,1 is meaningless, must specify the way of interpretation: how many electrical signals to calculate a group, the meaning of each signal?

This is the function of the link layer, which, on the physical layer, determines how the 0 and 1 are grouped

Ethernet protocol:

Ethernet provides that a set of electrical signals constitute a packet called "frame", each frame is divided into 2 parts, header (head) and data

"Header" contains some description of the packet, such as sender, recipient, data type, etc., "data" contains specific content

"Header" length, fixed to 18 bytes, the length of "data", the shortest is 46 bytes, the longest is 1500 bytes, so, the entire frame is a minimum of 64 bytes, the longest is 1518 bytes, if the data is very long, it must be split into multiple frame to send

MAC address

As mentioned above, each data frame is the message of the sender and recipient in the Head & Data,head, that is, the MAC address, each network card is unique, usually in 12 16 binary number representation. 00-b0-d0-86-bb-f7, length is 48 binary

Broadcast (broadcast)

Define the address is the first step, how does one network card know the MAC address of the other NIC? Mainly through the ARP protocol, the Ethernet packet must know the other's MAC address to send,

Second, there is a MAC address, how can the system send packets to the receiver accurately?

Ethernet uses the broadcast way to send its own data frame, the entire LAN computer will receive, and then read the header information to determine whether it is the receiver, yes, the words will be received, not the words will be discarded

With the definition of the packet, the MAC address of the network card, the sending of the broadcast, the connection layer can transmit the data directly on multiple computers.

4: Network layer

If 2 computers are no longer in the same LAN, through the broadcast way is not transmitted out, so you must find a method, how to distinguish which MAC address belongs to the same network, which is not, if the same LAN on the use of broadcast, if not the way to use the route. ,

In this case, to enable us to distinguish whether different computers belong to the same subnet, this address will be the network address, referred to as the URL

So, each computer must owns 2 different address:mac and IP address. Network addresses help us determine the subnet where the computer resides, and the MAC address sends the packet to the subnet's destination NIC, thus, in log Ically,network address is handled.

5:IP protocol

IPV4. Consists of 32 binaries, divided into 4 segments of the decimal to represent the IP address. How can I tell if 2 computers are on the same subnet? Here is another concept subnet mask "subnet mask", if you know the subnet Mask,it's easy to identify theirs network.

6:IP Data Packets

The data that is sent according to the IP protocol is called an IP packet. It is not difficult to imagine that the inside must include IP address information

But as mentioned earlier, the Ethernet data contains only the MAC address, no IP address of the field, what to do? We can put IP packets directly into the data portion of the Ethernet packet,

Specifically, IP packets are also divided into headers and 2 parts of the data

Head + data

The header mainly includes the version, length, IP address and other information, the data is the specific content of IP packets, he put in the Ethernet packet, Ethernet packet becomes;

Head + head + data

The length of the IP Packet "HEAD" section is 20-69 bytes, the total length of the entire packet is 65,535 bytes, so, theoretically, the data portion of an IP packet is up to 65,515 bytes, as mentioned earlier, The data portion of an Ethernet packet has a maximum of 1500 bytes, so if the IP packet exceeds 1500 bytes, it will be split into several frames to send

7:ARP protocol

Because IP packets are sent over the Ethernet packet, we must know 2 addresses, each other's IP address and MAC address, usually, the other's IP address is known, and the MAC address is unknown

So we need a mechanism to get the MAC address through an IP address.

If the same subnet, we can get the other side of the MAC address through the ARP protocol, the ARP protocol is also sent a packet, contained in the Ethernet packet, which contains the IP address of the queried host, the other side of the MAC address bar is filled with FF:FF:FF:FF:FF:FF to indicate the broadcast address, All hosts on his network will be subject to this packet, with the IP address removed, compared to their IP address, and if the same responds

If you are not on the same subnet, you can only pass the packet to the connection "Vgetway" at 2 subnets.

    1. Transport Layer

With a MAC address and IP address, we can already establish communication on any 2 hosts on the Internet

The next problem is that there are many programs on the same host to connect to the network, for example, once you browse the Web, and chat with friends, when a packet heavy internet sent, how do you know, it is to indicate the content of the Web page, or the content of the chat.

In other words, we also need a parameter that indicates which process the packet is intended to use. This parameter is called a port. Port

He is actually the number of each program that uses the NIC. Each packet is sent to a specific port on the host, so different programs can marry the data they need.

The port is an integer between 0-65535, 16 binary, 0-1023 port is occupied by the system, the user can only choose the port after 1023. No matter you is surfing or chating on line, there'll be is a port selected to match with server port.

The function of the transport layer is to establish, port-to-port communication. In contrast, the function of the network layer is to establish the host to host the communication, as long as the host to determine the port, we can achieve the communication between the programs. Therefore, the UNIX system is the host + port called socket, socket. With it, you can develop a Web application

UDP protocol

Now we have to include the port information in the packet, which requires a new protocol, the simplest implementation is called the UDP protocol, his format is almost in front of the data with a port number

UDP packets, which are also made up of headers and data

Head + Data

The "Head" section mainly defines the port and the receive port, "data" is the specific content, and then put the entire UDP packet into the data portion of the IP packet, and the previous mentioned IP packet is placed in the Ethernet packet, so the entire Ethernet data into a

Head + head + head +data

TCP protocol

The UDP protocol is a bit simpler and easier to implement, but less reliable.

In order to improve the reliability of the network, the TCP protocol was born, did not send a packet is required to confirm, if a packet is lost, it is not confirmed, the sender know it is necessary to re-send the packet

Both TCP packets and UDP packets are embedded in the data portion of the IP packet, and the TCP packet has no length limit. Theoretical no limited, in general, the lenght of TCP is no longer than the Lenght of IP package to ensure Singal TCP package don ' t need to be divided.

Application layer,

The application receives data from the transport layer and is then interpreted. Since the Internet is an open architecture, data sources are varied and must be well-defined in advance, otherwise they cannot be interpreted

The "Application layer" function is to specify the data format of the application

For example, the TCP protocol can pass data to a variety of programs, such as EMAIL,WWW.FTP. There must be different protocols to specify the e-mail, Web, and FTP data formats that make up the application layer

This is the highest level, directly facing the user, his data is placed in the data department of the TCP packet, so that the Ethernet packet becomes

Head + head + head + data

Ethernet Headers    IP Header TCP Header Application Layer data

Summary:

We already know that network communication is the exchange of packets, computer A to Computer B send a packet, the latter received, reply to a packet, so as to achieve communication between 2 computers,

To send this package, we need to know each other's IP address and MAC address. With these 2 addresses, the packet can be accurately sent to the recipient, but said earlier, MAC address has limitations, if 2 computers are no longer the same subnet, it will be forwarded via Gateway. Gateway through the routing protocol, found that the computer is located in Network B, and the packet sent to Gateway B, Gateway B is forwarded to the corresponding computer

The same word network----each other's MAC address, the other IP address

Not the same----) the Gateway MAC address, the other IP address

8: User Internet Settings

Manual IP,DHCP

DHCP is an application-layer protocol that is built on top of the UDP protocol

Head + head + head + data

Ethernet IP UDP DHCP SERVER

The front Ethernet header sets the MAC address of the native and the MAC address of the receiver's DHCP server, which is not known to fill ff-ff-ff-ff-ff-ff

After the IP header, set the IP address of the machine and accept the IP address of the sender, local do not know 0.0.0.0, receiver 255.255.255.255

UDP header, set port 68 and receiver Port 67 for the issuing party

This packet construction can be issued, Ethernet is broadcast sent, no computer on the same subnet received, but also must analyze its IP address to determine whether to send themselves, DHCP sees the sender's 0.0.0., the receiver is 255.255.255.255 know is to me, the other PC will discard this package

Next DHCP reads the contents of the package, assigns a good IP address, sends it back to the DHCP response, and this package night resembles

9: instance, accessing Web page

This machine: 192.168.1.100

255.255.255.0

192.168.1.1

8.8.8.8

Then open the browser and visit google.com This means that the browser is sending a Web request to Google

DNS protocol

Send a packet, you must know the other's IP address, but we only know the URL, the DNS protocol can help us to convert the URL into IP

Known DNS server 8.8.8.8, so we send a DNS packet to this address

Head + head + head + data

Ethernet IP UDP DNS Packets

Then DNS makes the corresponding and tells us that Google's address is 172.194.72.105

Subnet mask determines whether the same subnet

And operation with the known subnet mask 255.255.255.0 and IP address

So we're going to send a packet to Google, which must be forwarded through the gateway, which means that the accepted MAC address is the gateway address

Application Layer Protocol

Browse the Web with the HTTP protocol, and his entire packet is constructed

Head + head + head + data

Ethernet IP TCP HTTP

The contents of the Http section,

get/http/1.1

Host:www.google.com

Connection:keep-alive

user-agent:mozilla5.0 (Windwos NT)

Accept

text/html,applicaiton/xhtml,applicaiton/xml;1=0.9,*/*;1=0.8

Accept-encoding;gzip,deflate,sdch

accept-language:zh-cn,zh;q=0.8

accept-charset:gbk,utf-9;q=0.7,*;q=0.3

a cookie;

We assume that this part is 4960 bytes long and that he will be encapsulated in a TCP packet

TCP protocol

TCP packets need to be set up port, Google http port 80, sender's ports are randomly generated between 1024-65535, assuming 51755

The header length of the TCP packet is 20 bytes, plus the embedded HTTP packet, with a total length of 4980

IP protocol

TCP packets are then embedded in IP packets, IP packets are both IP addresses,

The IP header is 20 bytes, plus the embedded TCP packet is 5000 bytes

Ethernet Protocol

Finally, the IP packet embedded in the Ethernet packet, the Ethernet packet needs to set the MAC address of both sides, the MAC address of the computer and the MAC address of the receiver network management, (get through ARP)

Ethernet Data portion maximum 1500 bytes, and now IP packet length 5000, therefore, IP packets must be split 4 packets, because each package has its own IP header (20 bytes) So 4 packets of IP packet length 1500 1500 1500 560

Head Head Data

Head Head Data

Head Head Data

Head Head Data

Ethernet IP TCP DATA

Server-side response

The 4 Ethernet packets were received by a Google server forwarded through multiple gateways

According to the IP header number, Google will be 4 packets flat up to obtain a complete TCP packet, and then read the inside HTTP request in response, in the same TCP protocol, sent back

This machine is subject to HTTP, you can display the Web page, complete a complete network communication

Getting Started with Internet protocols

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.