There are two scenarios for two host communications: 1. In the same network segment 2. Not in the same network segment
(1.) The communication process on the same network segment
Actions of the host on the application tier:
The TCP port on the TCP/IP protocol corresponds to a variety of applications, and the client will need to open this fixed port of the host to access an application. The client itself opens a random port greater than 1024 to communicate with each other's host. Users use the application to edit information, a single session is actually a software connection between the logic of a host application layer.
The operation of the host on the Transport layer:
For data Fragmentation (Segment), add a TCP header (containing source port, destination port, sequence number, etc.)
Reasons for Fragmentation:
(A): Data can be sent from multiple applications simultaneously.
(B): When the packet is too large to produce an error, it also needs to be re-transmitted, that is, the take-up and time, small packets on the data flow is much less impact.
(C): A variety of network transmission media has its largest transmission unit limit, does not allow the presence of large packets on the network.
The operation of the host at the network level:
When the transport layer adds a TCP header for data fragmentation, the data is sent to the network layer for processing. The network layer adds the IP header (containing the source IP address, the destination IP address) to the packets coming from the transport layer into the packet
The operation of the host on several link layers:
The data link layer encapsulates the data frame header in front of the packet, encapsulating the colonel's position after the packet, and encapsulating the packet as a data frame. (Add source MAC address and destination MAC address, if the host does not know the destination MAC address then want the switch to send ARP broadcast to get the destination MAC address)
The operation of the host to the physical layer:
The data frames sent from the logical link layer are converted into electronic signals that can be transmitted on the physical line, and transferred to the forwarding device switch on the network, which is processed by the switch.
The switch handles the data frame:
After the switch receives the data stream, it looks for the destination host based on the MAC address of the data frame sent over, and sends the data to the destination host. The forwarding process does not change the data frame structure.
The destination host receives the operation of the data frame:
When the destination host receives a data frame to compare the purpose of the Mac, if sent to its own, then remove the data frame head, sent to the network layer, the network layer compared to the destination IP, such as the same packet is sent to the transport layer, the transport layer is then compared to the destination port, the same is removed data segment to the application process data assembly
(2) Communication process between two hosts on different network segments
Work on Host A:
Because host A and Host B are not in the same network segment, host A is not able to resolve through ARP to host B's MAC address, and host A is also a network node without routing capability, so host A is not able to rely on their own power to send data to Host B up. Host a must rely on routers in the network to route packets to the appropriate destination network.
Host a network configuration: Configure your own IP and subnet masks to configure the gateway at the same time (who provides the host with access to other network segments, the default gateway is populated with whose IP address.) ' Router, proxy server ')
[Dns:dns provides the destination address of the domain name resolution, such as in the LAN of different network segments, can be filled in the local area network DNS server. If you are accessing the domain name of an Internet extranet, complete the ISP's DNS server. ]
After the default gateway is filled in, host a can know the MAC address of router A through ARP parsing. When host a sends a file to Host B, it can send the packet to the destination via router a.
Example: Host a B Host process that sends data to other network segments.
1. Host a application layer data to the transport layer is segmented, hit the TCP header (with the source port, destination port), and then issued to the network layer, the IP address (including the source IP, destination IP), and then sent to the data link layer, hit the data frame (including the source Mac, the purpose Mac), because do not know the purpose The MAC address on the Mac that is on the gateway (router interface) is sent to router a.
2. After router a receives the message, reseal the data frame (knowing that the sending to the B host needs to go through router B), then modify the source MAC address as Router A's MAC address, the destination address is the MAC address of B, (Router A for NAT address translation)
3. Router B receives information from Router A, verifies the address, checks the IP, modifies the Mac, and the source Mac changes to Router B's Mac, (if Host B is in the subnet of Router B) The target Mac fills in Host B's Mac, which is the next step to send the information to Host B.
4. After Host B receives the data, the data is split to frame, packet, TCP header, check its destination address and checksum, and after the data stream is re-consolidated, the data is passed to the application layer for processing.
The general idea is the above part, after learning to add, 2016.11.30 22:43
Communication process (TCP) of two hosts in the network