Presentation is loading. Please wait.

Presentation is loading. Please wait.

Confidential SIMCom All right Reserved Plato Chen, Aug 2011 SIMCom SIM900 Technical training TCP/IP.

Similar presentations


Presentation on theme: "Confidential SIMCom All right Reserved Plato Chen, Aug 2011 SIMCom SIM900 Technical training TCP/IP."— Presentation transcript:

1 Confidential SIMCom All right Reserved Plato Chen, Aug 2011 SIMCom SIM900 Technical training TCP/IP

2 SIMCom All right Reserved Confidential 2 1. What is TCP/IP?

3 SIMCom All right Reserved Confidential 3 Layering of TCP/IP Link Internet Transport Application FTP,HTTP,SMTP,POP3 TCP,UDP IP,ICMP,IGMP Device Driver, Interface card ◆ Application Layer Application program access the internet via this layer: FTP, HTTP, SMTP,DNS, Telnet,etc. ◆ Transport Layer Provide host-to-host communication, including TCP and UDP. ◆ Internet Layer Handle the packet activity in network, such as routing. ◆ Network Layer Transmit/Receive data frame to/from internet 4 Layers of TCP/IP

4 SIMCom All right Reserved Confidential 4 Network Topology Host A Router Host B Router Application Transport Internet Link Application Transport Internet Link process-to-process host-to-host Data Flow

5 SIMCom All right Reserved Confidential 5 Encapsulation by descending layers IP header Frame footer Frame header TCP data TCP header Data IP data Frame data Application Transport Internet Link Stream Segment Packet Frame

6 SIMCom All right Reserved Confidential 6 TCP (transmission control protocol) ●Source port (16 bits) – identifies the sending port ● Destination port (16 bits) – identifies the receiving port ● Sequence number (32 bits) – has a dual role: If SYN=1, then this is the initial sequence number. The sequence number of the actual first data byte and the acknowledged number in the corresponding ACK are then this sequence number plus 1. If SYN=0, then this is the accumulated sequence number of the first data byte of this packet for the current session. ● Acknowledgment number (32 bits) – if the ACK flag is set then the value of this field is the next sequence number that the receiver is expecting. This acknowledges receipt of all prior bytes (if any). The first ACK sent by each end acknowledges the other end's initial sequence number itself, but no data. ● Data offset (4 bits) – specifies the size of the TCP header in 32-bit words. The minimum size header is 5 words and the maximum is 15 words thus giving the minimum size of 20 bytes and maximum of 60 bytes, allowing for up to 40 bytes of options in the header. This field gets its name from the fact that it is also the offset from the start of the TCP segment to the actual data. ● Reserved (3 bits) – for future use and should be set to zero.

7 SIMCom All right Reserved Confidential 7 TCP Header ● Flags (9 bits) – contains 9 1-bit flags ●NS (1 bit) – ECN-nonce concealment protection ● CWR (1 bit) – Congestion Window Reduced (CWR) flag is set by the sending host to indicate that it received a TCP segment with the ECE flag set and had responded in congestion control mechanism. ● ECE (1 bit) – ECN-Echo indicates If the SYN flag is set (1), that the TCP peer is ECN capable.ECN If the SYN flag is clear (0), that a packet with Congestion Experienced flag in IP header set is received during normal transmission. ● URG (1 bit) – indicates that the Urgent pointer field is significant ● ACK (1 bit) – indicates that the Acknowledgment field is significant. All packets after the initial SYN packet sent by the client should have this flag set. ● PSH (1 bit) – Push function. Asks to push the buffered data to the receiving application. ● RST (1 bit) – Reset the connection ● SYN (1 bit) – Synchronize sequence numbers. Only the first packet sent from each end should have this flag set. Some other flags change meaning based on this flag, and some are only valid for when it is set, and others when it is clear. ● FIN (1 bit) – No more data from sender ●Window size (16 bits) – the size of the receive window, which specifies the number of bytes (beyond the sequence number in the acknowledgment field) that the receiver is currently willing to receive. ●Checksum (16 bits) – The 16-bit checksum field is used for error-checking of the header and data.checksum ● Urgent pointer (16 bits) – if the URG flag is set, then this 16-bit field is an offset from the sequence number indicating the last urgent data byte. ● Padding – used to ensure that the TCP header ends and data begins on a 32 bit boundary. The padding is composed of zeros.

8 SIMCom All right Reserved Confidential 8 Example

9 SIMCom All right Reserved Confidential 9 TCP protocol operation

10 SIMCom All right Reserved Confidential 10 Connection establishment Three-way handshake ●SYN: The active open is performed by the client sending a SYN to the server. It sets the segment's sequence number to a random value A. ●SYN-ACK: In response, the server replies with a SYN-ACK. The acknowledgment number is set to one more than the received sequence number (A + 1), and the sequence number that the server chooses for the packet is another random number, B. ●ACK: Finally, the client sends an ACK back to the server. The sequence number is set to the received acknowledgement value i.e. A + 1, and the acknowledgement number is set to one more than the received sequence number i.e. B + 1.

11 SIMCom All right Reserved Confidential 11 TCP Data Transfer ●Reliable transmission ● Ordered data transfer - the destination host rearranges according to sequence number. ● Retransmission of lost packets - any cumulative stream not acknowledged is retransmitted. ● Error detection TCP checksum catches most of simple errors. ● Congestion control Timer for retransmission

12 SIMCom All right Reserved Confidential 12 TCP Data Transfer ● Flow control Limits the rate a sender transfers data to guarantee reliable delivery. The receiver continually hints the sender on how much data can be received (controlled by the sliding window). When the receiving host's buffer fills, the next acknowledgment contains a 0 in the window size, to stop transfer and allow the data in the buffer to be processed

13 SIMCom All right Reserved Confidential 13 TCP Port ● TCP port numbers: To identify sending and receiving application end-points on a host, or Internet sockets. Each side of a TCP connection has an associated 16-bit unsigned port number (0-65535) reserved by the sending or receiving application. ●Categories ●Well-known ports (0~1023): assigned by the Internet Assigned Numbers Authority (IANA). used by system-level or root processes. Well-known applications running as servers and passively listening for connections typically use these ports: FTP (20 and 21), SSH (22), TELNET (23), SMTP (25) and HTTP (80).FTPSSHTELNETSMTPHTTP ●Registered ports(1024~49151) ●Dynamic/private ports(49152~65535)

14 SIMCom All right Reserved Confidential 14 UDP(User Datagram Protocol) ● UDP is a minimal message-oriented Transport Layer protocol. ● UDP provides no guarantees to the upper layer protocol for message delivery and the UDP protocol layer retains no state of UDP messages once sent. For this reason, UDP is sometimes referred to as Unreliable Datagram Protocol. ● UDP provides application multiplexing (via port numbers) and integrity verification (via checksum) of the header and payload.If transmission reliability is desired, it must be implemented in the user's application.

15 SIMCom All right Reserved Confidential 15 Comparision of UDP and TCP ●TCP ●Reliable – TCP manages message acknowledgment, retransmission and timeout. Multiple attempts to deliver the message are made. If it gets lost along the way, the server will re-request the lost part. In TCP, there's either no missing data, or, in case of multiple timeouts, the connection is dropped. ● Ordered – if two messages are sent over a connection in sequence, the first message will reach the receiving application first. When data segments arrive in the wrong order, TCP buffers the out-of-order data until all data can be properly re-ordered and delivered to the application. ● Heavyweight – TCP requires three packets to set up a socket connection, before any user data can be sent. TCP handles reliability and congestion control. ● Streaming – Data is read as a byte stream, no distinguishing indications are transmitted to signal message (segment) boundaries. ●UDP ●Unreliable – When a message is sent, it cannot be known if it will reach its destination; it could get lost along the way. There is no concept of acknowledgment, retransmission or timeout. ● Not ordered – If two messages are sent to the same recipient, the order in which they arrive cannot be predicted ● Lightweight – There is no ordering of messages, no tracking connections, etc. It is a small transport layer designed on top of IP. ● Datagrams – Packets are sent individually and are checked for integrity only if they arrive. Packets have definite boundaries which are honored upon receipt, meaning a read operation at the receiver socket will yield an entire message as it was originally sent.

16 SIMCom All right Reserved Confidential 16 2. SIM900 TCP/IP TCPIP: TCP/UDP SAP: HTTP/FTP

17 SIMCom All right Reserved Confidential 17 Structure of SIM900 TCPIP

18 SIMCom All right Reserved Confidential 18 Connection mode ◆ GPRS mode---data transferring via PS AT+CIPCSGP=1, “APN”, “username”, “password” --default mode with default APN “CMNET” ◆ CSD mode----data transferring via CS AT+CIPCSGP=0, “dial_number”, “username”, “password”

19 SIMCom All right Reserved Confidential 19 Activating/Deactivating PDP context 1, Activating: By command group AT+CSTT=“APN”, “username”, “password” -----start task and set APN, it needs GPRS attached (AT+CGATT? Return 1)firstly. AT+CIICR ---bring up wireless connection For CSD mode, timeout 60s; GPRS mode, timeout 40s. AT+CIFSR ----get local IP In single connection ◆ by command AT+CIPSTART =,”IP”, ◆ by command AT+CIPSERVER=1, 2, Deactivating AT+CIPSHUT ---If there are connections existed, close the connections. Timeout 20s.

20 SIMCom All right Reserved Confidential 20 Establishing connection 1, Single connection (AT+CIPMUX=0) AT+CIPSTART=“TCP/UDP”, “IP_Addr or Domain name”, CONNECT OK--------- Connection to remote server is established. --Timeout 60s It only can be used when the state is IP INITIAL or IP STATUS. 2, Multi connection (AT+CIPMUX=1) AT+CIPSTART=, “TCP/UDP”, “IP_Addr or Domain name”,, CONNECT OK----Connection to remote server is established. It only can be used when the state is IP INITIAL.

21 SIMCom All right Reserved Confidential 21 Handshake during SIM900 TCP establishment Set local TCP/UDP port AT+CLPORT=“TCP/UDP”, port: 0~65535

22 SIMCom All right Reserved Confidential 22 Three-way handshaking SIM900Server (Seq=0), (Flag: SYN=1) (Seq=0),(ACK=1),(Flag: SYN=1,ACK=1) (Seq=1),(ACK=1),(Flag: ACK=1)

23 SIMCom All right Reserved Confidential 23 Data sending 1, Normal sending mode (AT+CIPQSEND=0) ◆ AT+CIPSEND? –Query current maximum length data available to be sent. +CIPSEND: ---determined by current network status, maximum 1460 bytes. ◆ AT+CIPSEND= --Sending with fixed length, length<=size. >123456…length SEND OK --Sending successfully and received by TCP server ◆ AT+CIPSEND >123456789……size ---Sending with variable length ◆ AT+CIPATS=1, --Auto sending AT+CIPSEND

24 SIMCom All right Reserved Confidential 24 2, Quick sending mode (AT+CIPQSEND=1) ◆ AT+CIPSEND >123456789 DATA ACCEPT:9 --UART accepts 9 bytes data, no ACK from server AT+CIPSEND >123456 DATA ACCEPT:6 --Continuously sending, not wait for SEND OK ◆ AT+CIPACK +CIPACK:,, --Query current active connection data transmitting state only useful for TCP

25 SIMCom All right Reserved Confidential 25 TCP data sending example (seq=1,ack=1,size=5),(flag: PSH=1,ACK=1) SIM900 Server (seq=1,ack=6,size=0),(flag:ACK=1)

26 SIMCom All right Reserved Confidential 26 Data receiving 1, Automatically receive (AT+CIPRXGET=0) AT+CIPHEAD=1 ---display IP header AT+CIPSHOWTP=1---display protocol in IP header AT+CIPSRIP=1---display source IP_Addr and port RECV FROM:116.236.221.75:8500 +IPD,5,TCP:HELLO 2, Manually receive (AT+CIPRXGET=1) +CIPRXGET: 1 ---indicate data received from remote side AT+CIPRXGET=2, ---ordinary format, length less than 1460bytes AT+CIPRXGET=3, --- HEX format, length less than 730bytes AT+CIPRXGET=4 ---query how many data not read yet

27 SIMCom All right Reserved Confidential 27

28 SIMCom All right Reserved Confidential 28 Closing connection 1, SIM900 local side ◆ Normal closing AT+CIPCLOSE=0 (Timeout: 2minutes) (Seq=11,ack=1),(flag: ACK=1,FIN=1) (Seq=1,ack=12),(flag: ACK=1) (Seq=1,ack=12),(flag: ACK=1,FIN=1) (Seq=12,ack=2),(flag: ACK=1) SIM900 server Four-way handshaking– TCP closing

29 SIMCom All right Reserved Confidential 29 TCP normal closing example ◆ Quick closing AT+CIPCLOSE=1 (Timeout: 100ms) RST, no ACK

30 SIMCom All right Reserved Confidential 30 2, Remote side ◆ Normal closing AT+CIPQRCLOSE=0 FIN, four-way handshaking ◆ Quick closing AT+CIPQRCLOSE=1 RST, no ACK

31 SIMCom All right Reserved Confidential 31 TCP server 1, For single connection AT+CIPSERVER=1, --start TCP server, set listening port SERVER OK --server established. REMOTE IP: 211.136.130.1 --remote client connect in AT+CIPSEND AT+CIPSERVER=0 --close listening status, connection active AT+CIPCLOSE --close connection 2, For multi connection AT+CIPSERVER=1, SERVER OK, REMOTE IP: 211.136.130.129 --remote client connect in AT+CIPSEND= AT+CIPSTART=, “TCP/UDP”, “IP_Addr”, AT+CIPSERVER=0 AT+CIPCLOSE=

32 SIMCom All right Reserved Confidential 32 Transparent mode ◆ Establishment AT+CIPMODE=1 ---enable transparent mode AT+CIPCCFG=,,, AT+CIPSTART=“TCP/UDP”, “IP_Addr”, port CONNECT ---connection established, enter into transparent mode 123456789 ---receive data from remote server. OK ---quit to command mode by +++ or DTR ATO ---switch back to transparent mode ◆ Flow control AT+IFC=2,2 ---enable hardware flow control rise to 6k: CTS  high 8k drop to 2k: CTS  low

33 SIMCom All right Reserved Confidential 33 ◆ Handle incoming call/SMS incoming call incoming SMS

34 SIMCom All right Reserved Confidential 34 Multi-connection AT+CIPMUX=1 …... 0,“TCP” 7,”UDP” Client 1, “TCP” 2, “UDP” 7, “UDP” TCP server...

35 SIMCom All right Reserved Confidential 35 GPRS/Connection states ◆ AT+CIPSTATUS ◆ GPRS states Single connection

36 SIMCom All right Reserved Confidential 36 Multi connection

37 SIMCom All right Reserved Confidential 37 UDP extended mode ---something like TCP server in multi connection AT+CIPUDPMODE=1 ---enable UDP extended mode AT+CLPORT=“UDP”,3333 AT+CIPHEAD=1 AT+CIPSRIP=1 AT+CIPSTART=“UDP”, “IP_Addr1”, port1 RECV FROM:IP_Addr1, port1 +IPD,5:test1 RECV FROM:IP_Addr2, port2 +IPD,5:test2 AT+CIPSEND ---send data to IP_Addr1 AT+CIPUDPMODE=2,"IP_Addr3",port3 ---reconfigure remote server AT+CIPSEND ------send data to IP_Addr3

38 SIMCom All right Reserved Confidential 38 3. SAP ---- SIMCom Application Protocol AT+SAPBR=3,1,"CONTYPE","GPRS" AT+SAPBR=3,1,"APN","CMENT“ AT+SAPBR=3,1,"USER","" AT+SAPBR=3,1,"PWD","“ AT+SAPBR=1,1 --Open bearer, CID1 AT+SAPBR=2,1 --Query bearer +SAPBR: 1,1,"10.157.189.6“ AT+SAPBR=0,1 -- Close bearer AT+SAPBR=2,1 +SAPBR: 1,3,"0.0.0.0" Configuration for GPRS mode, Also can configurate for CSD

39 SIMCom All right Reserved Confidential 39 SIM900 HTTP ◆ HTTP Parameters 1)CID, profile identifier same as SAPBR; 2)HTTP/1.1 (keep alive) 3)Proxy Server, IP address and port; 4)Redirection switch; 5)Break point to GET. ◆ HTTP Methods 1)GET 2)POST 3)HEAD Break Redirection Proxy server HTTP/1.1 CID

40 SIMCom All right Reserved Confidential 40 HTTP Get AT+HTTPINIT OK AT+HTTPPARA="CID",1 OK AT+HTTPPARA="URL","www.google.com" OK AT+HTTPACTION=0 OK +HTTPACTION:0,302,376 AT+HTTPREAD +HTTPREAD:376 302 Moved 302 Moved The document has moved here. OK

41 SIMCom All right Reserved Confidential 41 Break point (need web server support) AT+HTTPINIT OK AT+HTTPPARA="CID",1 OK AT+HTTPPARA="URL","http://www.baidu.com/img/baidu_sylogo1.gif" OK AT+HTTPACTION=0 OK +HTTPACTION:0,200,1630 +HTTPREAD:1630 ----data------ AT+HTTPPARA="BREAK",1600 OK AT+HTTPACTION=0 OK +HTTPACTION:0,206,30 AT+HTTPREAD +HTTPREAD:30 ----data------

42 SIMCom All right Reserved Confidential 42 HTTP post AT+HTTPPARA="CID",1 OK AT+HTTPPARA="URL","116.228.221.51:8011" OK AT+HTTPDATA=5,20000 DOWNLOAD OK AT+HTTPACTION=1 OK AT+HTTPDATA=5,20000 DOWNLOAD // HELLO OK AT+HTTPACTION=1 OK +HTTPACTION:1,200,424 POST / HTTP/1.1 Host: 116.228.221.51:8011 Accept: */* Connection: Keep-Alive User-Agent: SIMCOM_MODULE Content-Length: 5 HELLO SERVER side: Post to server Response to module

43 SIMCom All right Reserved Confidential 43 SIM900 FTP ◆ FTP parameters: 1)Port, default 21; 2)Active/ Passive mode; 3)file transfer types: ASCII / Binary; 4)CID, bearer profile identifier; 5)Username/password; 6)Server; ◆ FTP methods: 1)GET ◆ getname ◆ getpath ◆ resume broken dowload 2) PUT ◆ putname ◆ putpath ◆ put type: append, store, store unique

44 SIMCom All right Reserved Confidential 44 FTP Put AT+FTPCID=1 OK AT+FTPSERV="simcom.exavault.com" OK AT+FTPUN=“cdm" OK AT+FTPPW=“cdm" OK AT+FTPPUTOPT="STOR" OK AT+FTPPORT=21 OK AT+FTPTYPE="A" OK AT+FTPPUTPATH="/" OK AT+FTPPUTNAME="2011.TXT" OK AT+FTPPUT=1 OK +FTPPUT:1,1,1360 AT+FTPPUT=2,6 +FTPPUT:2,6 OK +FTPPUT:1,1,1360 AT+FTPPUT=2,0 OK +FTPPUT:1,0

45 SIMCom All right Reserved Confidential 45 FTP Get AT+SAPBR=3,1,"Contype","GPRS" OK AT+SAPBR=3,1,"apn","cmnet" OK AT+SAPBR=2,1 +SAPBR: 1,3,"0.0.0.0" OK AT+SAPBR=1,1 OK AT+FTPSERV="simcom.exavault.com" OK AT+FTPUN="myd" OK AT+FTPPW="myd" OK AT+FTPGETNAME="2010.TXT" OK AT+FTPGETPATH="/" OK AT+FTPCID=1 // do not forget configure this OK AT+FTPGET=1 OK +FTPGET:1,1 AT+FTPGET=2,1460 // try to get 1460 bytes +FTPGET:2,6 // here only 6 bytes data SIMCOM OK AT+FTPREST=5 // broken download from fifth byte OK AT+FTPGET=1 OK +FTPGET:1,1 AT+FTPGET=2,1460 +FTPGET:2,1 // just get one byte data M OK

46 SIMCom All right Reserved Confidential 46 Reference document ◆ SIM900_TCPIP_Application Note_V1.02 ◆ SIM900_IP_Application Note_V1.01 ◆ SIM900_AT Command Manual_V1.04

47 SIMCom All right Reserved Confidential 47 Thank you!


Download ppt "Confidential SIMCom All right Reserved Plato Chen, Aug 2011 SIMCom SIM900 Technical training TCP/IP."

Similar presentations


Ads by Google