TCP/IP model and TCP/UDP protocol, tcpudp

Source: Internet
Author: User
Tags file transfer protocol

TCP/IP model and TCP/UDP protocol, tcpudp
Protocol: rules, standards, or conventions established for data exchange (communication) in the network. (= Semantics + syntax + rules)TCP/IP has become an industrial standard for Internet communication.TCP/IP model:



TCP protocolIs a connection-oriented reliability transmission protocol. Before sending data, you must first send a connection request. when the other party listens to a request, the connection is established, and then both parties can send and receive messages, after the message is sent, the two parties are disconnected (namely, the three-way handshake protocol ).


Three-way handshake protocol:

First handshake:

When a connection is established, the client sends a syn Packet (syn = j) to the server and enters the SYN_SENT status, waiting for confirmation from the server; SYN: Synchronize Sequence Numbers ).
The second handshake:

When the server receives the syn packet, it must confirm the customer's SYN (ack = j + 1) and send a SYN Packet (syn = k), that is, the SYN + ACK packet, the server enters the SYN_RECV status;
The third handshake:

The client receives the server's SYN + ACK packet and sends the ACK (ack = k + 1) Confirmation packet to the server. After the packet is sent, the client and server enter the ESTABLISHED status and complete three handshakes.


Socket:

To facilitate the development of network application software, Berkeley University launched an application to access the communication protocol's operating system call-socket (socket) on Unix ). The emergence of socket allows programmers to easily access TCP/IP and develop various network applications. With the popularization of Unix applications, sockets have been widely used in programming network software. Later, sockets were introduced into Windows and other operating systems. The Java language also introduces the socket programming model.


TCP-based socket programming :(Socket and ServerSocket)

Client programming:① Call Socket () to create a stream Socket and connect it to the server; ② call getOutputStream () and getInputStream of the Socket class to obtain the output stream and input stream, and start sending and receiving network data. ③ Close the communication socket. Server programming:① Call ServerSocket (int port) to create a server socket and bind it to the specified port; ② call accept () to listen for connection requests. If the client requests a connection, the connection is accepted, return communication socket. ③ Call the getOutputStream () and getInputStream of the Socket class to obtain the output stream and input stream and start sending and receiving network data. ④ Close the communication socket.


UDP is a non-connection-free and unreliable protocol, that is, before data communication, the sender and the receiver do not need to be connected. The sender needs to send data and only need to construct a datagram, add the acceptor address to the datagram, and then send it out. this protocol is an unreliable protocol. Because there is no connection between the sending and receiving devices, the data sent out may be lost midway through, and the sending end has not received any feedback. therefore, the most important thing in implementing UDP protocol programs is how to Implement UDP datagram
JAVA provides two key classes for implementing the UDP protocol. Datagram (DatagramPacket ):Construct a datagram that can contain the data to be sent and the acceptor address. UDP (DatagramSocket ):Build the sender and receiver that implements the UDP function to send and receive data packets.
UDP network programming method: Write the receiver program:① Call mongoramsocket (int port) to create a datagram socket and bind it to the specified port; ② call mongorampacket (byte [] buf, int length ), create a byte array to receive UDP packets. ③ Call receive () of the DatagramSocket class to receive UDP packets. ④ Close the datagram socket. Write the sender program:① Call mongoramsocket () to create a datagram socket; ② call mongorampacket (byte [] buf, int offset, int length, InetAddress address, int port) to create a UDP packet to be sent. ③ Call the send () method of the DatagramSocket class to send a UDP packet. ④ Close the datagram socket.


What is the UDP protocol? What is the difference between it and the TCP/IP protocol?

TCP/IP Protocol Introduction

TCP/IP communication protocol

This section briefly introduces the internal structure of TCP/IP and lays the foundation for discussing Internet-related security issues. TCP/IP protocol groups are popular in part because they can be used on a variety of channels and underlying protocols (such as T1 and X.25, Ethernet, and RS-232 serial interfaces. Specifically, TCP/IP is a set of protocols, including TCP and IP, UDP (User datainprotocol), and ICMP (Internet Control Message Protocol) protocol and other protocol groups.

Overview of TCP/IP architecture

The TCP/IP protocol does not fully comply with the OSI Layer-7 Reference Model. The traditional Open System Interconnection Reference Model is a layer-7 abstract reference model of communication protocols, where each layer executes a specific task. This model aims to make various hardware communicate with each other at the same level. These seven layers are: physical layer, data link layer, network layer, transmission layer, voice layer, presentation layer and application layer. The TCP/IP communication protocol uses a layer-4 hierarchy. Each layer calls the network provided by its next layer to meet its own needs. The four layers are:

Application Layer: layer for communications between applications, such as simple Email transmission (SMTP), file transfer protocol (FTP), and network remote access protocol (Telnet.

Transport Layer: In this layer, it provides data transmission services between nodes, such as transmission control protocol (TCP) and User Datagram Protocol (UDP, TCP and UDP add transmitted data to the data packet and transmit it to the next layer. This layer is responsible for transmitting data and confirming that the data has been delivered and received.

Interconnect Network Layer: provides basic data packet transmission functions so that each data packet can reach the target host (but does not check whether it is correctly received), such as Internet Protocol (IP ).

Network Interface Layer: manages the actual network media and defines how to transmit data using the actual network (such as Ethernet and Serial Line.

Protocols in TCP/IP

The following is a brief introduction of what functions are available in TCP/IP protocols and how they work:

1. IP

Internet Protocol IP is the heart of TCP/IP and the most important protocol in the network layer.

The IP layer receives a packet from a lower layer (network interface layer, such as an Ethernet device driver) and sends the packet to a higher layer-TCP or UDP layer, the IP layer also sends packets received from the TCP or UDP layer to the lower layer. IP packets are unreliable because the IP does not do anything to confirm that the packets are sent in order or are not damaged. An IP packet contains the address (source address) of the host that sent the packet and the address (Destination Address) of the host that received the packet ).

When receiving data packets, high-level TCP and UDP services generally assume that the source address in the packet is valid. It can also be said that IP addresses form the authentication basis for many services. These services believe that data packets are sent from a valid host. IP validation contains an option called IP source routing, which can be used to specify a direct path between the source address and the destination address. For some TCP and UDP services, the IP packet with this option is transmitted from the last System in the path, rather than from its actual location. This option exists for testing, indicating that it can be used to fool the system for a normally prohibited connection. Therefore, many services that rely on the IP Source Address for confirmation will have problems and will be illegally infiltrated.

2. TCP

If an IP packet contains a TCP packet that has been blocked, the IP will send them to the upper layer. TCP sorts packets and checks errors to connect virtual circuits. TCP packets include serial numbers and validation, so packets not received in order can be sorted, and damaged packets can be re-transmitted.

TCP sends its information to higher-level applications, such as Telnet service programs and customer programs. The application takes turns to take the rest of the full text...>

This section describes specialized network communication terms such as http, tcp, udp, ftp, and ip.

To be honest, it is really hard to describe these protocols, but it can only tell you about their functions.
In fact, you don't need to know too much about it. After the system learns network knowledge, you can read these protocols clearly.
I was confused at first, but I didn't care much about it. Now, it is easy to understand.

I am taking CCNP now. To be honest, it is better to read the English version of the Chinese version of the tutorial. It is easier to understand English than Chinese.
So there are no good Chinese tutorials to recommend to you, because they are very professional statements like those on Baidu encyclopedia.

I suggest you set a goal first and then learn network knowledge. You should first test the National Computer Level 4 network engineer. Its official tutorial is very good. You can check it and it doesn't matter if you don't understand it, you can view and make real questions and understand the definition from "practice. Next, let's take a look at the fifth version of the computer network (as if it was the latest version). After reading these two versions, there will be almost no more network knowledge, but the update speed will be very fast and the full version will be updated in about three years, so you have to keep up with the speed. Now IPv6 is ready for popularization. Therefore, in the past two years, the network will develop faster.
At last, if you still don't understand it, you should attend the training and ask the instructors who don't understand.
If you still don't understand it, you can't help it. It means you are not doing this.

Send your email. I have the fifth edition of the computer network.

Finally, if you have any questions, you can ask me. in a timely manner, I have poor technical skills. I also have a CCIE and H3CSE teacher.
I can ask him, I wish you a successful learning.

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.