SIM7070 - SIM7080 - SIM7090 Series - TCPUDP (S) - Application Note - V1.03
SIM7070 - SIM7080 - SIM7090 Series - TCPUDP (S) - Application Note - V1.03
SIM7070 - SIM7080 - SIM7090 Series - TCPUDP (S) - Application Note - V1.03
Series_TCPUDP(S)
_Application Note
LPWA Module
GENERAL NOTES
COPYRIGHT
www.simcom.com 2 / 21
SIM7070_SIM7080_SIM7090 Series_TCPUDP(S)_Application Note_V1.03
About Document
Version History
Scope
www.simcom.com 3 / 21
SIM7070_SIM7080_SIM7090 Series_TCPUDP(S)_Application Note_V1.03
Contents
About Document .................................................................................................................... 3
Version History ...................................................................................................................................... 3
Scope .................................................................................................................................................... 3
Contents ................................................................................................................................. 4
1 Introduction ...................................................................................................................... 5
1.1 Purpose of the document ............................................................................................................ 5
1.2 Related documents ..................................................................................................................... 5
1.3 Conventions and abbreviations ................................................................................................... 5
www.simcom.com 4 / 21
SIM7070_SIM7080_SIM7090 Series_TCPUDP(S)_Application Note_V1.03
1 Introduction
Based on module AT command manual, this document will introduce TCPUDP(S) application process.
Developers could understand and develop application quickly and efficiently based on this document.
In application, controlling device controls the GSM engine by sending AT Command via its serial interface.
The controlling device at the other end of the serial line is referred to as following term:
TE (Terminal Equipment);
DTE (Data Terminal Equipment) or plainly "the application" which is running on an embedded system;
www.simcom.com 5 / 21
SIM7070_SIM7080_SIM7090 Series_TCPUDP(S)_Application Note_V1.03
2 TCP/UDP Introduction
In the TCP/IP network architecture, TCP (Transport Control Protocol) and UDP (User Data Protocol) are the
two most important protocols at the transport layer, and provide upper-level users with a level of
communication reliability.
The TCP protocol is a reliable, one-to-one, connection-oriented communication protocol. TCP mainly
guarantees the reliability of data transmission in the following ways:
(1) When using the TCP protocol for data transmission, it is often necessary for the client and server to
establish a "channel", and this channel can only be used by the client and server, so the TCP transmission
protocol can only be used for one-to-one connection.
(2) In order to ensure the accuracy of data transmission, the TCP transmission protocol divides the data
packet used for transmission into several parts (the size of each part depends on the network situation at
that time), and then adds a check word in their header Section. After a part of the data is received, the
server will verify the integrity and accuracy of the part. After the verification, if the data is 100% complete
and accurate, the server will ask the client to start Transmission of the next part of the data. If the integrity
and accuracy of the data do not match the original, the server will request the client to transmit this part
again.
The client and server must first establish a "channel" when using the TCP transmission protocol, and then
www.simcom.com 6 / 21
SIM7070_SIM7080_SIM7090 Series_TCPUDP(S)_Application Note_V1.03
close the "channel" after the transmission is completed. The former can be visually referred to as a
"three-way handshake", while the latter can be referred to as " Four waves."
The TCP protocol can provide a reliable communication connection for the application program, so that the
byte stream sent by a computer can be sent to other computers on the network without errors. Data
communication systems that require high reliability often use the TCP protocol to transmit data.
UDP (User Datagram Protocol) is a connectionless protocol and a simple transport layer protocol for
datagrams. It provides non-connection-oriented, unreliable data streaming.
Connectionless means that it is not necessary to establish a connection with the other party before formal
communication, and it is sent directly regardless of the other party's status. It is very similar to the mobile
phone text message: when you send a text message, you only need to enter the other party's mobile phone
www.simcom.com 7 / 21
SIM7070_SIM7080_SIM7090 Series_TCPUDP(S)_Application Note_V1.03
UDP transmission protocol is an unreliable, connectionless oriented communication protocol that can
realize many-to-one, one-to-many and one-to-one connections. UDP does not need to establish a channel
before transmitting data, nor does it need to close the channel after data transmission is completed. As long
as the client sends a request to the server, the server will send all the data at once. UDP does not verify the
integrity of the data when transmitting data, and does not require retransmission when data is lost or data is
wrong, so it also saves a lot of time for verifying data packets, so the delay of the connection established
with UDP Will have a lower latency than connections established with TCP. UDP does not control the data
transmission speed according to the current network conditions, so no matter whether the network
conditions are good or bad, the server will send data at a constant rate. Although this sometimes causes
data loss and damage, this is very important for some real-time applications. Based on the above three
points, UDP is faster in data transmission, lower in latency, and better in real-time, so it is widely used in the
communication field and video websites.
UDP is suitable for application environments that only transmit a small amount of data at a time and have
low requirements on reliability. For example, we often use the "ping" command to test whether the TCP/IP
communication between the two hosts is normal. In fact, the principle of the "ping" command is to send
ICMP data packets to the other host, and then the other host confirms that the data packet is received. If the
message of whether the packet arrives is fed back in time, then the network is connected. For example, in
the default state, a "ping" operation sends 4 packets (as shown). As you can see, the number of data
packets sent is 4 packets, and 4 packets are received (because the host of the other party will send back a
data packet confirming receipt). This fully shows that the UDP protocol is a connection-free protocol and
there is no connection establishment process. Because the UDP protocol has no connection process, its
communication efficiency is high; but also because of this, its reliability is not as high as the TCP protocol.
QQ uses UDP to send messages, so sometimes the message may not be received.
The biggest difference between TCP/IP and UDP is that TCP/IP is connection-oriented and UDP is
connectionless. The TCP and UDP protocols have their own strengths and weaknesses, and they are
suitable for communication environments with different requirements. The differences between the TCP
protocol and UDP protocol are shown in the table below.
www.simcom.com 8 / 21
SIM7070_SIM7080_SIM7090 Series_TCPUDP(S)_Application Note_V1.03
In actual use, TCP is mainly used in scenarios where the accuracy of file transfer is relatively high and is not
very urgent, such as e-mail and remote login. Sometimes in these application scenarios, even the loss of
one or two bytes can cause irreparable errors, so these scenarios generally use the TCP transmission
protocol. Because UDP can improve transmission efficiency, UDP is widely used in data transmission with
large data volume and low accuracy requirements. For example, when we usually watch videos or listen to
music on the website, we basically apply the UDP transmission protocol.
www.simcom.com 9 / 21
SIM7070_SIM7080_SIM7090 Series_TCPUDP(S)_Application Note_V1.03
The module provides AT commands that can be used by device terminals as follows:
Command Description
AT+CSSLCFG Configure SSL parameters of a context identifier
AT+CACID Set TCP/UDP identifier
AT+CASSLCFG Set SSL certificate and timeout parameters
AT+CAOPEN Open a TCP/UDP connection
AT+CASEND Send data via an established connection
AT+CARECV Receive data via an established connection
AT+CAACK Query Send Data Information
AT+CASTATE Query TCP/UDP Connection State
AT+CACLOSE Close a TCP/UDP connection
AT+CACFG Configure transparent transmission parameters
AT+CASWITCH Switch to transparent transport mode
www.simcom.com 10 / 21
SIM7070_SIM7080_SIM7090 Series_TCPUDP(S)_Application Note_V1.03
4 Bearer Configuration
OK
AT+CSQ //Check RF signal
+CSQ: 20,0
OK
AT+CGATT? //Check PS service. 1 indicates PS has attached.
+CGATT: 1
OK
AT+COPS? //Query Network information, operator and
network.
+COPS: 0,0,"CHN-CT",9 //Mode 9 means NB-IOT network.
OK
AT+CGNAPN //Query the APN delivered by the network after the
CAT-M or NB-IOT network is successfully
registered.
+CGNAPN: 1,"ctnb" //"ctnb" is APN delivered by the CAT-M or NB-IOT
network. APN is empty under the GSM network.
OK
AT+CNCFG=0,1,"ctnb" //Before activation please use AT+CNCFG to set
APN\user name\password if needed.
OK
AT+CNACT=0,1 //Activate network, Activate 0th PDP.
OK
www.simcom.com 11 / 21
SIM7070_SIM7080_SIM7090 Series_TCPUDP(S)_Application Note_V1.03
OK
AT+CFUN=0 //Disable RF
+CPIN: NOT READY
OK
AT+CGDCONT=1,"IP","ctnb" //Set the APN manually. Some operators need to
set APN first when registering the network.
OK
AT+CFUN=1 //Enable RF
OK
+CPIN: READY
AT+CGATT? //Check PS service. 1 indicates PS has attached.
+CGATT: 1
OK
AT+CGNAPN //Query the APN delivered by the network after the
CAT-M or NB-IOT network is successfully
registered.
+CGNAPN: 1,"ctnb" //"ctnb" is APN delivered by the CAT-M or NB-IOT
network. APN is empty under the GSM network.
OK
AT+CNCFG=0,1,"ctnb" //Before activation please use AT+CNCFG to set
APN\user name\password if needed.
OK
AT+CNACT=0,1 //Activate network, Activate 0th PDP.
OK
www.simcom.com 12 / 21
SIM7070_SIM7080_SIM7090 Series_TCPUDP(S)_Application Note_V1.03
OK
www.simcom.com 13 / 21
SIM7070_SIM7080_SIM7090 Series_TCPUDP(S)_Application Note_V1.03
5 TCPUDP(S) Examples
OK
AT+CASEND=0,5 //Request to send 5 bytes of data
> //Input data
OK //Data sent successfully
AT+CAACK=0 //Query send data Information of the TCP
connection with an identifier 0.
+CAACK: 5,0 //Total size of sent data is 5 and unack data is 0.
OK
+CADATAIND: 0 //Data comes in on 0th connection.
AT+CARECV=0,100 //Request to get 100 byte data sent by the server.
+CARECV: 10,GET / HTTP //Output received data
www.simcom.com 14 / 21
SIM7070_SIM7080_SIM7090 Series_TCPUDP(S)_Application Note_V1.03
OK
AT+CACLOSE=0 //Close the connection with an identifier of 0.
OK
AT+CNACT=0,0 //Disconnect 0th data connection
OK
OK
+CANEW: 0,1,117.131.85.139,5004 //Have a new client access on 0th connection and
the client has been assigned to 1th connection.
+CADATAIND: 1 //Date comes in on 1th connection.
AT+CARECV=1,100 //Read 100 byte data
+CARECV: 10,GET / HTTP //Actual output 10 byte data
OK
AT+CASEND=1,5 //Request to send 5 bytes of data
> //Input data
OK
AT+CAACK=1 //Query send data Information of the TCP
connection with an identifier 1.
+CAACK: 5,0 //Total size of sent data is 5 and unack data is 0.
OK
AT+CACLOSE=1 //Close the connection with a connection identifier
of 1.
OK
www.simcom.com 15 / 21
SIM7070_SIM7080_SIM7090 Series_TCPUDP(S)_Application Note_V1.03
OK
+CADATAIND: 0 //Date comes in on 0th connection.
+CANEW: 0,0,117.131.85.139,5001 //Have a new client access on 0th connection and
the client has been assigned to 0th connection.
AT+CARECV=0,100 //Read 100 byte data on 0th connection
+CARECV: 10,GET / HTTP //Actual output 10 bytes data
OK
AT+CACFG="REMOTEADDR",1,117.131.85.139 //Set remote address information for send to.
,6014
OK
AT+CASEND=0,5 //Request to send 5 bytes of data
> //Input data
OK //Data sent successfully
AT+CACLOSE=0 //Close the connection with a connection identifier
of 0.
OK
AT+CNACT=0,0 //Disconnect 0th PDP
OK
www.simcom.com 16 / 21
SIM7070_SIM7080_SIM7090 Series_TCPUDP(S)_Application Note_V1.03
About SSL parameters configure and certificate convert please refer to “SIM7070_SIM7080_SIM7090
Series_SSL_Application Note”.
Because of modules can only serve as clients. When you need to establish a one-way authentication
connection, you need to import the root certificate of the server. If no certificate is imported, the module will
default that all the servers can be trusted.
www.simcom.com 17 / 21
SIM7070_SIM7080_SIM7090 Series_TCPUDP(S)_Application Note_V1.03
default.
OK
AT+CAOPEN=0,0,"TCP","117.131.85.139",6005 //Create a SSL connection with 0th PDP on 0th
connection identifier
+CAOPEN: 0,0 //Connection success
//Data come in on 0th connection. When a
OK connection is successfully established or data is
successfully sent, the module actively reads the
data once, and if the server data is received, the
URC is reported.
If no data is received, the URC will not be reported.
+CADATAIND: 0 //After open a connection successfully, if module
receives data, it will report "+CADATAIND: <cid>"
to remind user to read data
AT+CARECV=0,100 //Read 100 byte data
+CARECV: 10,GET / HTTP //Output data
OK
AT+CASEND=0,5 //Request to send 5 bytes of data
> Input data
OK
AT+CACLOSE=0 //Close the connection with an identifier of 0.
OK
AT+CNACT=0,0 //Close the connection with an identifier of 0.
OK
To establish a two-way authentication SSL connection, you need to set up a client certificate. The client
certificate needs to be transformed through "AT+CSSLCFG" first.
The certificate format that the module can support is .PEM, .DER and .P7B.
www.simcom.com 18 / 21
SIM7070_SIM7080_SIM7090 Series_TCPUDP(S)_Application Note_V1.03
OK
AT+CSSLCFG="SSLVERSION",0,3 //Set the protocol type of SSL with an identifier of
0. 3 indicate TLS1.2
OK
AT+CASSLCFG=0,"SSL",1 //Set the 0th connection’s SSL enable option.
//Whether to use SSL, 1 means to turn on the SSL
function.
OK
AT+CASSLCFG=0,"CRINDEX",0 //Identifier for AT+CSSLCFG corresponding SSL
configuration.
OK
AT+CASSLCFG=0,"CACERT","root.pem" //Set root certificate. The root certificate must be a
certificate that has been converted through
AT+CSSLCFG. This item can be omitted. If
omitted, all server certificates are trusted by
default.
OK
AT+CASSLCFG=0,"CERT","client.pem" //Set up client certificates.
//The root certificate must be converted to a
certificate that can be directly used by
AT+CSSLCFG.
OK
AT+CAOPEN=0,0,"TCP","117.131.85.139",6005 //Create a SSL connection with 0th PDP on 0th
//connection identifier.
//Connection success
+CAOPEN: 0,0
OK
AT+CASEND=0,5 //Request to send 5 bytes of data
> //Input data
OK //Data sent successfully
AT+CAACK=0 //Query send data Information of the TCP
connection with an identifier 0.
+CAACK: 5,0 //Total size of sent data is 5 and unack data is 0.
OK
AT+CACLOSE=0 //Close the connection with a connection identifier
of 0.
OK
www.simcom.com 19 / 21
SIM7070_SIM7080_SIM7090 Series_TCPUDP(S)_Application Note_V1.03
To establish PSK DTLS connection, you need to set up a psktable. The psktable needs to be transformed
through "AT+CSSLCFG" first.
OK
+CADATAIND: 0 //Data comes in on 0th connection. When a
connection is successfully established or data is
successfully sent, the module actively reads the
data once, and if the server data is received, the
URC is reported.
www.simcom.com 20 / 21
SIM7070_SIM7080_SIM7090 Series_TCPUDP(S)_Application Note_V1.03
OK
AT+CACLOSE=0 //Close the connection with an identifier of 0.
OK
AT+CNACT=0,0 //Disconnect data connection
OK
www.simcom.com 21 / 21