OSI protocols and TCP / IP protocol

·Telecommunication

    
        The network is connected to the respective physical links isolated host workstation or together to form a data link, so as to achieve the purpose of resource sharing and communication. Information exchange and communication is carried out between people passing through some medium. Communications network is isolated the respective devices connected via a network, for communication between people, people with a computer, the computer and the computer via the exchange of information. Network communication is the most important network communication protocols. Today there are many network protocols, LAN There are three most commonly used network protocols: MICROSOFT's NETBEUI, NOVELL the IPX / SPX and TCP / IP protocol. Should be to select the appropriate network protocol as necessary.

1.OSI seven agreements

        OSI (Open System Interconnection, Open Systems Interconnect) seven layer network model is a reference model of ISO (International Organization for Standardization, ISO) made of, the network communication is a logically defined, and may be understood as defined in the general network communication specification. Our process and the data transmission in the network, in fact, following FIG encapsulation and decapsulation process, the sender through various encapsulation processing, converting data into a bitstream, the bitstream transmission hardware signal transmission medium , the receiver then de-encapsulation bitstream.Here Insert Picture Description

(1) The physical layer

Predetermined mechanical, electrical, functional and procedural characteristics of how the bottom of the physical connection, and the physical device is a network communications. Such as: how to use cables and connectors of
the type for transmitting the signal voltage and the like. Note that, during a communication network required physical medium (cable, cable, etc.), is not part of the physical layer, as was
the physical layer is actually a predetermined, these predetermined physical media devices connected to the network when a variety of specifications, parameters and work. But at the same time, twisted pair cables and other physical
media is to achieve the physical layer.

(2) Data Link Layer

Physical address specifies how address, how data (frame frame) reliable delivery and flow control on the physical line. The data link layer protocols are SLIP Association
Protocol, CSLIP protocol, PPP protocol. Switches, and based on the information contained in the frame transmits a frame decoded data to the correct recipient, so that the switch is working in the data
link layer.

(3) The network layer

What are the network nodes, what network path by the data (packet) transmitted from the sender to the recipient. In the network layer, the node A sends the determined data from
the network path to the node B, through which nodes. Network layer may be established LAN communication systems, and more important is that communication can be established in a WAN networking system, because
it has its own routing address structure, work for routing communication network via a routing protocol (also called routable protocol).

(4) transport layer

Responsible for the overall data transfer and data control, it provides a mechanism for the exchange of data from end to end. Transport layer data (segment) segmentation and reassembly, and flow control and
determines received data capacity of the reception side suitable transmission rate. Such as Ethernet can not handle packets larger than 1500 bytes, the data is divided into transport layer data segments,
and the small data fragments SEQ ID NO. Recipient transport layer data in accordance with recombinant SEQ ID NO. There are transport layer protocol TCP protocol, UDP protocol.

(5) session layer

Between two nodes in the network to establish, maintain and terminate communication.

(6) presentation layer

It formats the data between the application and the network so that it can be understood by the other. I.e., the sender indicates an abstract syntax layer converts the application data into a network of
network grammar adapted to transmit OSI network transmission, the receiver and vice versa. In addition, the presentation layer may also encrypt and decrypt data.

(7) Application layer

Topmost OSI layer that provides network services for applications. Such as providing protocol support for e-mail, file transfer function. HTTP application layer protocols have protocol, FTP Association
Protocol, SMTP protocol.

2.TCP / IP protocol

TCP / IP (Transmission Control Protocol / Internet Protocol, Transmission Control Protocol / Internet Protocol) refers to the protocol suite enables transmission of information between multiple different networks. TCP / IP protocol refers not only two TCP and IP protocols, but rather refers to a protocol stack consisting of FTP, SMTP, TCP, UDP, IP and other protocols, just as the TCP / IP protocol in the TCP and IP protocol the most representative, it is called TCP / IP protocol.

Here Insert Picture Description
This is the TCP / IP model and one of the four related agreements.
Here Insert Picture Description

· TCP / IP network interface layer

A major role: data encapsulation / decapsulation framing (frame). In order to ensure reliable transmission over the data transmission network layer herein may be processed into a physical layer packet transmission structure - frame. In addition to including the data frame to be transmitted, but also includes the physical address and control information and error checking the sender and receiver. Wherein determining the physical address where to send a frame, and error detection control information is used to ensure error-free data arrives.

The main role of two: a control frame transmission. Transmission control frame is mainly reflected in the feedback retransmission timer, the frame number of aspects. Receiver frame by error coding (parity or CRC code) check to determine whether a frame error occurred during transmission, and sends a send feedback, if transmission error occurs, it is necessary to correct retransmission. As a transmission, after transmission frame if, at the same time it starts a timer after transmitting the frame if the feedback is not received within a certain time, in order to avoid stagnation transmission, that is after the timer Timeou frame transmission error, automatic retransmission. In order to avoid the case of multiple receive and to transmit it to the same frame as the network layer occurs, the required number each frame transmitted, the receiver in order to determine whether the received frame is repeated.

The main role of three: flow control. Due to differences in operating speed devices each using both the transceiver and the buffer memory space, the sender may appear larger than the transmission capacity of the phenomenon recipient receives capability, this time limit without making the appropriate transmission rate of the sender, the received time to the front frame frame will be continuously sent back to the "flooding", resulting in lost frames and errors. Thus, the flow control is actually a sender control data traffic, the transmission rate so that it does not exceed the rate of the reception side. We need to know some rules so that the sender can then send the next frame under what circumstances, and under what circumstances must stop sending, waiting to receive some feedback before sending more.

· TCP / IP network layer

When it comes to network layer must mention it is the IP protocol, which is TCP / IP protocol suite, the core of the agreement. All TCP, UDP, ICMP, IGMP protocol data are transmitted in IP datagrams format. IP protocol is unreliable provided, connectionless datagram delivery service. Unreliable is the IP datagram protocol does not guarantee the success of arrival, the only transport service, transmission error, the erroneous data packets are discarded. No connection is the IP protocol processing of data packets are independent, which means that the receiver will not necessarily receive data packets according to the transmission order. IP datagram format is as follows:
Here Insert Picture Description
This is the data packets through the network layer, the added IP header of 20 bytes, including IPV4 communication type information, data identification, a fragment offset, the TTL (TTL is period) , source IP , destination IP and expansion of IP options, etc.;

· TCP / IP transport layer

Add TCP header
Here Insert Picture Description

TCP is a byte-oriented stream transmitted via TCP byte stream in each byte are sequentially numbered, and Sequence header
Number field value refers to the first byte of the data segment newspaper number. Acknowledgment
Number The next is desirable to receive the other of the first data byte of the segment number. Offset: four bits refer to TCP
header length segments comprising a fixed 20-byte TCP and the Options field. Reserved: accounting for 6, reserved for future use, currently 0. The TCP
the flags of C, E, U, A, P, R, S, F field is used to illustrate the nature of the packet. Meaning is as follows:
     C (CWR) and E (ECE) to support ECN (display blocking notice).
     U (URGENT): When URG = 1, which tells the system in this emergency data packets, priority should be transmitted (such as emergency off), which is to mate with the urgent pointer field is used.
     A (ACK): valid only when ACK = 1 is the acknowledgment number field. After establishing a TCP connection, all segments must be the ACK field set to 1.
     P (PUSH): if desired an end of the other end of a TCP connection response immediately, PSH field can "urged" each other, without waiting for the buffer to fill before sending.
      R (RESET): serious errors if a TCP connection, the RST is set to 1, disconnecting the TCP connection, and then re-establish the connection.
     S (SYN): for establishing and releasing connections, when the SYN = 1, represents a connection.
     F (FIN): for releasing the connection, when the FIN = 1, indicates that the sender has finished transmitting, required to release the TCP connection. Window: 2 bytes. Window value refers to the sender's own receive window size, because of the limited space of the receiving buffer.
  CheckSum: 2 bytes. And UDP packets, as a test and to check whether the packets go wrong during transmission. Urgent
Pointer: occupies 2 bytes. When URG = 1 if active, it indicates the number of bytes of urgent data segment newspaper.

· TCP three-way handshake to create a connection and disconnection connection handshake

Here Insert Picture Description

  1. Server Client first sends a connection request packet segment sync your seq (x), Client enters the SYN_SENT state.
  2. Client Server receives the connection request packet segments, back to their Client seq (y) and ack (x + 1), Server enters SYN_REVD state.
  3. Client Server returns an acknowledgment of receipt, once again sends an acknowledgment segment ack (y + 1) to the server, this segment may already carry the data. Client enters ESTABLISHED state.
  4. After receiving confirmation from the Client Server again, enter ESTABLISHED state.
      TCP connection so far established. Why do three-way handshake it? Handshake process is actually notify each other in their initialization index (Initial Sequence
    Number The), referred to ISN, which is the figure above x and y. x and y based on a transmission data after it will be treated to ensure that TCP packets are not confused during transmission.
      We returned TCP Header structural point of view, Sequence Number and Acknowledgment Number 32 are accounted for, so the range seq and ack is 0-2 32-1 seq and ack to 2 per 32-1 then again from zero. It is worth mentioning that the initial value of seq (ISN) does not always start at zero. We imagine, if it is from zero, then when the TCP three-way handshake to establish a connection is completed, Client sent 30 messages, then Client disconnected. Client then reconnect again with 0 as the initial seq, so there will be two messages have the same seq, appeared confused. TCP is in fact the practice of every 4 microseconds to do a ISN plus 1 operation, when the ISN reach 2 ^ 32-1 time again from zero, and have passed a few hours before the report seq = 0 the text does not exist in this connection, and thus avoiding the above problems.
      Here Insert Picture Description
      
     (. 1) transmits a disconnection request the Client to Server segment, seq = m (m is the Client Server to send the last segment of the last byte sequence number by 1, Client enters FIN-WAIT-1 state.
      After (2) Server receives the disconnect segment, transmits an acknowledgment segment to Client, seq = n (n is a Client Server sends the last byte of the last packet sequence number of the segment plus 1, ack = m + 1 , Server into the CLOSE-WAIT state. at this time, the TCP connection is in a semi-closed state, Server sends data words, Client can still be received.
      (. 3) Server sends an acknowledgment message to the disconnected segments Client, seq = u (u Server sending the last segment is half-closed state to the Client last byte sequence number by 1, ack = m + 1, Server into the lAST-ACK state.
      (. 4) Client Server receives the disconnect acknowledgment message after the segment, the Server sends a disconnection acknowledgment packet, seq = m + 1, ack = u + 1, Client enters TIME-WAIT state.
      (. 5) Client Server receives acknowledgment packets off into the CLOSED state, TCP connection is disconnected.
      (. 6) waiting for a period of time in the Client tIME-wAIT state (time 2 * MSL ((Maximum Segment Life )), the transmission confirmation to the Client Server last disconnect confirm arrival (if not reach, Server retransmits the step (3) of the disconnect confirmation message segment to the Client, Client tell you the last time did not confirm disconnection Have received
    to) if no packet is received segments Client Server again during the TIME-WAIT, the state proceeds to CLOSES .TCP connected to this disconnection..
      
      TCP connection reliability reflect:
      (1) the length of TCP segment variable, is adjusted according to both send and receive buffer status, network status.
      (2) when the received TCP data sent from the other end of the TCP connection, it sends an acknowledgment.
      (3) When TCP sends a segment, it starts a timer and wait for the destination to acknowledge receipt of this segment, if not promptly receive a confirmation, it will retransmit this segment.
      (4) TCP test and it will keep the header and data. If there is an error by examining and segments found that the segment will be discarded, waiting for retransmission timeout.
      (5) TCP bytes of data are sorted, segment have a serial number, to ensure correct sequence.
      (6) TCP also provides flow control. Each TCP connection has a transceiving side cache. Receiving TCP only allows the other end of the transmitting and receiving end can receive the data buffer. This will prevent the buffer faster host resulting in slower host overflow.
      It should be noted, TCP packet transmission using return after receiving confirmation of the way to ensure the reliability of packet transmission, does not mean that the sender sends a message segment after entering the state waiting for an acknowledgment, let segment behind waiting. Nor is the recipient after receiving a packet, each packet will reply to confirm.
      The truth is, for the sender, after sending a segment, copy a copy of the segment, and then proceed to the next segment to send messages, reply to the sender to confirm if they are not, it is the segment retransmission timeout. For the recipient, it is by way of "accumulation confirmation" reply. After the recipient received multiple consecutive segments, just back to confirm the last segment, which represents the data before that have been received. In order to achieve the purpose of enhancing transmission efficiency.

· TCP / IP application layer

Port with the application layer connection, reference may be Tcp common port list ;

In the understanding of these, you're ready to expand learning the computer network of a specific communication model, in-depth understanding of the TCP / IP protocol will be more handy.

Released eight original articles · won praise 11 · views 305

Guess you like

Origin blog.csdn.net/weixin_45121946/article/details/104402085