Reproduced (http://jingyan.baidu.com/article/219f4bf7d1f284de442d3823.html)
Essence of DTU Communication
The most basic usage of gprs dtu is to add a SIM card for activating the GPRS function in DTU. After DTU is powered on, it first registers to the GPRS network, and then establishes a connection with the data processing center through the GPRS network. This connection involves wireless network operators, network bandwidth suppliers, network conditions of users' companies, and user computer configurations. Therefore, you need to configure all parts of this connection.
In essence, the DTU and the data processing center establish a socket connection. DTU is the Socket Client, and the data processing center is the socket server. The socket connection can be divided into TCP and UDP protocols. The same protocol must be used between the DTU and the center. Generally, the configuration software is used for configuration.
After the IP address and port number of the center are configured for DTU, The DTU is connected to the user's device through the serial port. DTU is connected to user devices such as hydrology, power supply, meteorology, and environmental protection and placed on site through a serial port.
After DTU is powered on, it first registers to the mobile network, and then sends a socket request packet to mobile. Mobile sends the request to the Internet. The server software in the center establishes a connection after receiving the request and sends the Response Message.
The request message sent by DTU is an Internet data packet. Some reasons may prevent the center from receiving the connection request packet, so that a connection cannot be established. The most common computer with a center has anti-virus software and firewalls that shield these packets. The other is that the central computer accesses the Internet through a vro, and data forwarding needs to be set on the vro. After the socket connection is established, two-way communication is available.
Work Process
After the gprs dtu is powered on, read the working parameters stored in the Internal flash (including GPRS dialing parameters, serial port baud rate, data center IP address, etc., which have been configured in advance ).
Gprs dtu logs on to the GSM network and then performs gprs ppp dialing. After successful dialing, gprs dtu will obtain an internal IP address (generally 10. x) randomly assigned by mobile ). That is to say, gprs dtu is in the mobile Intranet, and its Intranet IP address is usually not fixed, and changes with each dial-up. It can be understood that gprs dtu is a device in a mobile internal LAN, which can communicate with the Internet through a mobile gateway. This is similar to the way computers in the LAN access the external network through the gateway.
Gprs dtu actively initiates a communication connection with the data center and keeps the Communication Connection persistent. Because gprs dtu is in the mobile Intranet, and the IP address is not fixed. Therefore, the gprs dtu can only be used to actively connect to the data center, rather than the gprs dtu. This requires the data center to have a fixed public IP address or a fixed domain name. The public IP address or fixed domain name of the data center is stored in the gprs dtu as the parameter, so that the gprs dtu can actively connect to the data center once the dial-up is successful.
Specifically, gprs dtu uses parameters such as the IP address of the data center (if the central domain name is used, the central IP address is resolved through the central domain name first) and the port number, initiate a TCP or UDP Communication Request to the data center. After receiving a response from the center, the gprs dtu deems that the handshake is successful with the center, and then the communication connection remains there. If the communication connection is interrupted, the gprs dtu will immediately shake hands with the center.
Because the TCP/UDP communication connection has been established, two-way data communication can be performed.
For DTU, as long as two-way communication is established with the data center, the conversion between user serial port data and GPRS network data packets is relatively simple. Once the user's serial port data is received, DTU immediately encapsulates the serial port data in a TCP/UDP packet and sends it to the data center. When DTU receives a TCP/UDP packet from the data center, it extracts the data and sends it to the User device through the serial port.
Two-way communication with multiple gprs dtu is also implemented through a wired data collection center. This is the most common method in the gprs dtu application system.
Core functions
(1) internal integration of TCP/IP protocol stack
Gprs dtu encapsulates the PPP dialing protocol and TCP/IP protocol stack and has an embedded operating system. It can be viewed as a combination of embedded PC and wireless GPRS modem on the hardware; it provides GPRS dial-up Internet access and TCP/IP data communication functions.
(2) provides bidirectional conversion of Serial Data
Gprs dtu provides serial communication interfaces, including RS232, RS485, and rs422, in addition, gprs dtu has designed the serial port data to be a "transparent conversion" method. That is to say, gprs dtu can convert the original data on the serial port into TCP/IP data packets for transmission, instead of changing the original data communication content. Therefore, gprs dtu can be connected to a variety of user devices that use serial communication, and do not need to be modified.
(3) Automatic heartbeat and permanent online
One of the advantages of the GPRS communication network is to support permanent online of GPRS terminal devices. Therefore, the typical gprs dtu supports permanent online functions in design, this requires that DTU includes automatic dial-up upon power-on and uses heartbeat packets to stay online permanently (when there is no data communication for a long time, the mobile gateway will disconnect DTU from the center, a heartbeat packet is a small packet sent before the connection between DTU and the data center is disconnected to prevent the connection from being disconnected. It also supports automatic reconnection and automatic dialing.
(4) Support parameter configuration and permanent storage
As a communication device, gprs dtu is widely used. In different applications, the IP address and port number of the data center and the baud rate of the serial port are different. Therefore, gprs dtu should support parameter configuration and save the configured parameters in the internal permanent memory (generally flash or EEPROM ). Once powered on, the system automatically works according to the set parameters.
Gprs dtu can be used in the following aspects:
(1) only wireless communication environments can be used on site
When the equipment at the data collection site needs to work on the move, or the data collection site is in the wild, the wired communication environment cannot be provided. At this time, using GPRS wireless network may be a good choice, because the GPRS network coverage rate is already high in China, and GPRS signal coverage is available in most parts of the country.
(2) scattered transmission distance of field Terminals
Because the GPRS network is a public network covering the whole country, the advantage of using GPRS to transmit data is that the site collection points can be carried out nationwide step by step, the distance between the data center and the site collection point is unrestricted. Wireless Public Network Communication (including GPRS/CDMA networks and 3G networks) is a significant advantage of private wireless communication networks (such as digital radio stations, WiMAX, and WLAN.
(3) Appropriate real-time data requirements
In the domestic GPRS network, the delay of data transmission is within seconds. In most cases, the average overall latency of GPRS data communication is about 2 seconds. That is to say, data packets sent from the gprs dtu end will arrive at the data center in about two seconds. On the contrary, data packets in the data also arrive at gprs dtu in about two seconds.
In general, the real-time performance of GPRS can meet the requirements of most industrial applications. However, for some specific application systems, if the average latency of about 2 seconds is not supported, the GPRS communication method may not be suitable. (In addition, the transmission delay of the CDMA network is also about 1-2 seconds ).
From another perspective, if we want to design a system to transmit data through the GPRS network, we need to consider this delay when designing a communication protocol.
(4) appropriate data communication rate
The data communication rate between gprs dtu and the data center is generally between 10 kbps-60kbps. In other words, gprs dtu can continuously send data to the center at a speed of 10 bps-60 kbps, and vice versa. (Note: The average data communication rate of CDMA networks in China can reach 40 kbps-90kbps) from the perspective of system application reliability, we believe that when the average data traffic of the application system is within 30 kbps, it is suitable to use GPRS network for data transmission.
For example, if data is remotely transmitted through the GPRS network, the average data traffic needs to be controlled within 30 kbps. (Note: The average continuous communication rate and instantaneous communication rate are different here, and they are not the same as the serial port baud rate of the device)
The above points can be used to determine whether the application system is suitable for using GPRS network for data transmission. If these aspects are consistent, it is very appropriate to use gprs dtu for data transmission.
Essence and debugging experience of gprs dtu Communication