Update time：2018-04-13 Views：1826
WiFi network communication
Generally set up WiFi wireless network is made up of an Access Point (AP) and multiple wireless card site (STA).AP generally referred to as a network bridge or access point,commonly known as "hot spots".It is used as a bridge between the traditional wired local area networks and wireless local area network,so any a site with wireless network card (STA) are available through the AP to share the resources of the wired LAN or WAN.Its working principle is equivalent to a built-in wireless transmitter HUB or routing,but the wireless network card is a CLIENT equipment which is responsible for receiving the signal transmitted by the AP.So then you can in a wireless mode,cooperate with the existing cable structure to share network resources,set up complexity is much lower than the traditional wired network.
Fireduino WiFi to realize communication
In the previous section,through Fireduino SDK provides the API to join the wireless AP and get or configure the network settings,you can communicate with other STA.If AP have network conditions,you can also communicate with the remote device.
Network uses physical link to connect the various isolated workstation or host together to form a data link,so as to achieve the purpose of resource sharing and communication.Communication is the exchange and transmission of information between people through some media.Network communication is through the network to connect each isolated equipment,realize people to people through information exchange,people with the computer,communications between the computer and the computer. Network communication is the most important network communication protocols.There are many network protocols today and the most commonly used in LAN has three network protocol: NETBEUI of MICROSOFT,IPX/SPX and TCP/IP protocol of NOVELL. Freeduino network communication protocol is TCP/IP protocol.
Some basic common sense
Before learning agreement,we should have some basic knowledge.
1.The Internet address (IP address)
Every node on the network must have a separate Internet address (also known as IP address).Now,the IP address of the in common use is a 32 bit number,that is,we often say IPv4 standard,the 32bit digital is divided into four groups,which is the common style of 255.255.255.255. on the IPv4 standard,the address is divided into five categories,we commonly used is a class B address.he classification of the specific please refer to other documents.But note that the IP address is a combination of network ID + host ID,which is very important.
2.The domain name system
The Domain Name System is a distributed database that provides the host name (it is a URL) into an IP address service.
Note that this number is used in the TCP and UDP on a logical number,is not a hardware port,the certain port sealing off we say at ordinary times,also just in IP layer with the number of IP packet to filtered out.
4.Application programming interface
Now PC,handheld devices such as commonly used network programming interface has socket.While Fireduino on top of this designed and developed a set of API that is compatible with the Arduino WiFi,under the condition of without modifying the Arduino WiFi shields sample can be directly run on Fireduino,Obviously,Firefly team have made great efforts to complete the Fireduino.
TCP 与 UDP
TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) Protocol belongs to the transport layer Protocol.TCP provides reliable data transmission of the IP environment,which provides services including data streaming,reliability,efficient flow control,full-duplex operation and multiplexing.And via connection-oriented,end-to- end and reliable data packet transmission.Popular said,it is prior to sending the data into the connected channels, and then to send the data;and UDP is not to provide reliability and flow control or error recovery function for IP.Generally,TCP is the application of high reliability requirements,and the UDP is the corresponding low reliability, applications of economy transmission.
"Connection-oriented" must establish a connection with each other before the official communication.For example,you call someone else,must wait for the line is connected,the other picked up the phone to talk to each other. TCP(Transmission Control Protocol)is a protocol based on connection，That is to say,before the formal to send and receive data,must be to establish a reliable connection with each other.A TCP connection must go through three "dialogue" can be established,in which the process is very complex,we only do simple introduction here.Now,Let's take a look at the three simple process of dialogue:Host A send the connection request packet to Host B:"I want to send the data to you,will you?",this is dialogue for the first time;Host B send agreed to host A connection and requires synchronization of data packets(Synchronization is the two hosts in coordination,one transmit and one receiving):"Ok, when will you send?",this is the second time;Host A sends a packet to confirm synchronization of the host B,this is the three time.This three "dialogue" aim to make the packets sent and received simultaneously,after three "dialogue,A host to send data to host B officially. TCP protocol provides reliable communication connection for the application to make a byte sent from a computer error-free stream sent to other computers on the network,to require high reliability of data communication system often use TCP protocol to transmit data.
“面向非连接”就是在正式通信前不必与对方先建立连接，不管对方状态就直接发送。与手机短信非常相似：你在发短信的时候，只需要输入对方手机号就OK了。 UDP（User Data Protocol，用户数据报协议）是与TCP相对应的协议。它是面向非连接的协议，它不与对方建立连接，而是直接就把数据包发送过去！ UDP是一个无连接协议，传输数据之前源端和终端不建立连接，当它想传送时就简单地去抓取来自应用程序的数据，并尽可能快地把它扔到网络上。
Client and Server
Client server also known as master-slave architecture,referred to as C/S structure,is a kind of network architecture,it is the client (Client) and server (Server) to distinguish.Examples of each client software can send a request to a server or application server.
Client is an active role,send a request and wait to receive a response.But there are with state or stateless server.Stateless server does not retain information between any two requests,stateful server remembers information between requests.The scope of these information can be global or a session.
Server is a passive role,waiting from the client's requirement,then process requirements and back to the results.
Several cases of the client and the server
Browse the web page
Browser (IE) is the client program, site on the server is the server program.
Use QQ to chat
QQ is the client program,and the program of tencent chat room on the storage and exchange of information is the server side
Play World of Warcraft (a network game)
WoW Tops PC program is the client program,and you connect server is the server program.