当前位置:网站首页>Research on WLAN direct connection (peer-to-peer connection or P2P) and cross platform research of IOS

Research on WLAN direct connection (peer-to-peer connection or P2P) and cross platform research of IOS

2020-11-08 11:18:15 Said little lamb

# Research background

  1. After two devices are connected to the same LAN with different frequencies , There may be problems of communication between the two ends .
  2. If you pass Socket Local area network communication , If you don't have a network, you can't find the device IP, The problem of being unable to connect , There will be a delay when the Internet goes to the server 、 The problem of inaccurate data synchronization .
  3. In a hybrid network scenario , In connection AP when , It can communicate point-to-point at both ends at the same time , And both ends can also access the Internet separately .
  4. Necessary conditions for new technology direction : Need to support at the same time Android and iOS Both ends .

Andorid End :WiFi-P2P

Wifi P2P (peer to peer): Defined as Wifi Point to point , Also called Wifi Direct connection (Wifi Direct), It is Wifi Display( For screen ) The technical basis of application .

The official definition of

Use WLAN Direct connection (P2P) technology , It can make the corresponding hardware Android 4.0(API Level 14) Or later devices without an intermediate access point , adopt WLAN Direct interconnection . Use these API, You can implement support for WLAN P2P Devices that discover and connect to each other , In this way, the communication effect of high-speed connection is further than that of Bluetooth connection . For applications that need to share data between users, such as multiplayer games or photo sharing , This technology is very useful .

Other definitions

WiFi Direct It refers to allowing devices in a wireless network to connect to each other without passing through a wireless router . The principle is similar to Bluetooth Technology , This standard allows wireless devices to interconnect in a point-to-point manner . And more importantly ,WiFi Direct A technology allows WiFi The device establishes multiple wireless connections at the same time , This is a lot of new forms right now WiFi Apply the most critical technology .

WiFi Direct It's a kind of P2P Wireless Internet technology of , The network it builds is an improved one adhoc The Internet , Using wireless communication mode .

WiFi Two network modes :Infrastructure Mode and Ad Hoc Mode.

WiFi Direct It mainly solves the connection problem of physical layer , Including device discovery and service discovery . Related technologies are NFC and DLNA.

WiFi Direct Other features :

  • Unwanted AP Or a router , Device built in “soft AP”
  • The two sides of a peer-to-peer connection need only one support WiFi Direct Wireless connectivity can be achieved
  • Support infrastructure networks and P2P The Internet .
  • Devices can be interconnected in a one-to-one or one to many manner
  • As a minimum 802.11g The agreement can be passed WiFi Direct CERTIFIED verification
  • The maximum transmission distance can reach 200 rice , The maximum transmission speed is 250Mbps, Use 2.4GHz And 5GHz Two frequency bands , And it supports one-on-one , And the one to many model .

Important features

  1. Wifi P2P Technology doesn't access the web , But because it will use Java Socket, So you need to apply for network permission .
  2. Just open it Wifi that will do , No need to join any network or AP, To achieve peer-to-peer connection communication .( notes : In the following text demo There's validation in )
  3. Support the server to send messages to the devices in the cluster .
  4. Wifi Direct It's just pairing between devices , After matching, the file transfer operation still needs to be done by developers themselves .

Expand

Miracast Rely on the Wi-Fi The technical items are :

  • Wi-Fi Direct, That is to say Wi-Fi P2P. It supports in the absence of AP(Access Point) Under the circumstances , Two Wi-Fi The device is directly connected and communicates .
  • Wi-Fi Protected Setup: Used to help users automatically configure Wi-Fi The Internet 、 add to Wi-Fi Equipment etc. .
  • 11n/WMM/WPA2: among ,11n Namely 802.11n agreement , It will 11a and 11g Provided Wi-Fi The transmission rate is from 56Mbps Upgrade to 300 even to the extent that 600Mbps.WMM yes Wi-Fi Multimedia Abbreviation , Is a real-time video and audio data QoS service . and WPA2 Meaning for Wi-Fi Protected Acess The second edition , It is mainly used to encrypt and protect the transmitted data .

Aforementioned Wi-Fi In technology , Most of the functions are implemented by hardware manufacturers . And in the Android in , Yes Miracast The most important thing is two basic technologies :

  • Wi-Fi Direct: The function consists of Android Medium WifiP2pService To manage and control .
  • Wi-Fi Multimedia: For support Miracast,Android 4.2 Yes MultiMedia The system has also been modified .

Use scenarios

  1. Mobile phone connected to AP surf the internet , function youtube Client watching video ; The mobile phone passes through at the same time Wi-Fi Direct Connect to the TV , Put the video through Wi-Fi Direct Display Projected onto the big screen .
  2. Realizable through Wifi Connect , Scenarios that use data networks at the same time , such as : Mobile phone remote control UAV at the same time , UAVs need to access remote servers to upload data .
  3. Now in the market ,Client form ( Customer 、 User used ) Of WiFi product ( Whether it's USB Interface 、SDIO Interface or UART Interface ) All support WiFi Direct, It's just that the user perception of this technology is not strong . In fact, there are many uses in the market WiFi Direct Underlying technology App, Fast teeth, for example 、 Wali FastPass and other smart phones use their own WiFi Modules build their own network and transfer files .

Demo Research

Android End

explain : According to the official demo, Put it in order Andorid Studio Compileable project in , And add test cases .

Code and testing apk Please click on :WiFiDirectDemo

Official documents :WLAN Direct connection ( Peer to peer connection or P2P) overview
Official source link :WiFiDirectDemo

Test the installation package :
stay apk Under the table of contents , The file named :wifidirectDemo.apk.

The test case :

Before the test , Remember to turn on the phone first WiFi, Otherwise, some mobile phones may have flashback problems .

Equipment support prerequisites : Turn on WiFI And allow access to location rights .

Here are five test scenarios :

  1. The same LAN scenario :

Two phones connected WLAN hotspot : Such as Fiture(2.4G/5G), Under the same network .
Running results : Two mobile phones can communicate normally , Can send and receive pictures normally .

  1. Two routes are separated from the same LAN :

A mobile phone connection WLAN hotspot : Such as Fiture-Slim(5G), The other phone is connected to Fiture(2.4G/5G).

Running results : Two mobile phones can communicate normally , Can send and receive pictures normally .

  1. AP Isolate the scene :

A mobile phone connection 4G Network virtual A hot spot , A mobile phone connection Fiture(2.4G/5G).
Running results : Two mobile phones can communicate normally , Can send and receive pictures normally .

  1. Two phones just need to be turned on WiFi, No need to connect to any network .

Running results : Two mobile phones can communicate normally , Can send and receive pictures normally .

  1. Test scenarios for development boards

    Same as the above four test scenarios .

Summary : As long as both ends are open wifi, Whether it's connected to the same network or not , Can connect and send and receive pictures .

Abnormal situation :

Sometimes you can't find it , It's going to take a few more attempts to make the search successful . In addition, we need Rom Cancel sending invitation 、 Make sure that the paired connection pop-up window .

iOS End

Multipeer connectivity It's a way to get nearby equipment through Wi-Fi The Internet 、P2P Wi-Fi And Bluetooth personal LAN communication framework .

Linked nodes can transmit information safely 、 Streams or other file resources , Not through the Internet Service .

This framework is in iOS7 Later launch , Designed to replace GameKit Under the GKPeerPickerController signal communication .

Through this framework, we can directly connect devices under the same network , Let it go directly like wechat ,qq That instant messaging effect .

Use scenarios :

How to be in iPhone Use on mobile devices Wi-Fi Direct function

Third party open source cross platform research

Android-iOS Research on cross platform transmission scheme

https://stackoverflow.com/que...

alljoyn( At present, only Android project services-simulators,iOS End did not find )

AllJoyn, The center for Innovation led by Qualcomm (Qualcomm Innovation Center) Open source project developed , It is mainly used for short distance wireless transmission , through Wifi Or Bluetooth Technology , Positioning and point-to-point file transmission .

(Android End sum iOS Each end has a corresponding App. No open source projects found )

FireChat, It's a special mobile phone APP, Developed by open garden company . It enables smartphones to , Bluetooth via wireless mesh network 、Wi-Fi, Or Apple's multipoint connection (Multipeer Connectivity) Peer to peer networking architecture connectivity .
  • udark (Android and iOS There are open source projects on both sides ,Android The bottom layer of the end is not used WiFi-P2P Interface , With Bluetooth and NSD Mainly , The document interface at both ends is not perfect )
Mobile peer-to-peer mesh networking library.Integrates into iOS and Android apps and works over Wi-Fi and Bluetooth.

Focus on udark Conduct Demo verification , After verification, the following problems are found :

Android End :

You can see the underlying source code ( Only through implementation 'io.underdark:underdark:1.0.12' see jar package ), The initial judgment of the underlying code is based on Bluetooth and WiFI(NSD) Mixed mode implementation . But the connection succeeded or failed , When looking for reasons , Because there is no document interface to explain the location problem .

iOS End : There is an adaptation system version on the real machine 13 And the above adaptation problems , At present, only in iOS Run through the simulator Demo. Code is not open source , Can't see the connection principle , Can't locate the problem .

file :

There is no interface documentation at both ends , Open source authors can't get further contact .

Conclusion

The open source project cannot be used in the project for the time being , Other directions need to be considered .

The next step is

  • MQTT
  • Bluetooth socket
  • ……

Last , If you read this article , Yes Wifi P2P And cross platform communication research , Welcome to exchange .

Reference resources

Wi-Fi Direct

In depth understanding of Wi-Fi P2P

Android 10.0 Change of relevant authority ( Use WiFi Direct Positioning has to be turned on )

WiFi and AP Research on coexistence scheme --Android8.0

Android Realize file transfer without network 1

Android Realize file transfer without network 2(wifi hotspot )

Mobile phone end to end direct connection technology

Android There is no network transmission file WifiP2P

WifiDirect (WIFIP2P) The most complete and detailed , For intelligent hardware ( Smart home , Car engine , Unmanned aerial vehicle (uav) ) etc.

Android Wi-Fi Display(Miracast) Introduce ( The fourth of them Miracast Topology map application scenarios are useful )

Introduction of three mainstream wireless technologies on the same screen (Miracast、DLNA And AirPlay technology )

版权声明
本文为[Said little lamb]所创,转载请带上原文链接,感谢