WiFi Direct in Android Mobile and Ubiquitous Compu9ng - - PowerPoint PPT Presentation

wifi direct in android
SMART_READER_LITE
LIVE PREVIEW

WiFi Direct in Android Mobile and Ubiquitous Compu9ng - - PowerPoint PPT Presentation

WiFi Direct in Android Mobile and Ubiquitous Compu9ng MEIC/MERC 2015/16 Nuno Santos WiFi Direct: What Is It? Client 1 Wi-Fi Direct allows


slide-1
SLIDE 1

WiFi ¡Direct ¡in ¡Android ¡

¡ Mobile ¡and ¡Ubiquitous ¡Compu9ng ¡

MEIC/MERC ¡2015/16 ¡ ¡ Nuno ¡Santos ¡

slide-2
SLIDE 2

WiFi ¡Direct: ¡What ¡Is ¡It? ¡

  • Wi-­‑Fi ¡Direct ¡allows ¡devices ¡to ¡

connect ¡directly ¡to ¡each ¡

  • ther ¡using ¡methods ¡similar ¡

to ¡tradi9onal ¡Wi-­‑Fi, ¡except ¡ without ¡a ¡pre-­‑established ¡ access ¡point ¡

– Instead, ¡they ¡nego9ate ¡to ¡ establish ¡one ¡peer ¡device ¡to ¡ act ¡as ¡a ¡soOware ¡access ¡point ¡ for ¡all ¡the ¡other ¡devices ¡in ¡the ¡ group ¡

Mobile ¡and ¡Ubiquitous ¡Compu9ng ¡2015/16 ¡ 2 ¡

Acts ¡as ¡SoOware ¡ Access ¡Point ¡ Client ¡1 ¡ Client ¡2 ¡ Client ¡3 ¡

slide-3
SLIDE 3

Devices ¡Form ¡P2P ¡Groups ¡

  • WiFi ¡Direct ¡device ¡roles ¡

– WiFi ¡AP ¡and ¡client ¡

  • Devices ¡form ¡P2P ¡Groups ¡

– Group ¡Owner ¡(GO) ¡is ¡the ¡AP ¡ ¡ – Clients ¡connect ¡to ¡the ¡GO ¡ – The ¡GO ¡assigns ¡IPs ¡to ¡clients ¡

Mobile ¡and ¡Ubiquitous ¡Compu9ng ¡2015/16 ¡ 3 ¡

GO ¡

  • f ¡Group ¡

Clients ¡

  • f ¡Group ¡

P2P ¡ Group ¡

slide-4
SLIDE 4

WiFi ¡Direct ¡Supports ¡Many ¡Topologies ¡

Mobile ¡and ¡Ubiquitous ¡Compu9ng ¡2015/16 ¡ 4 ¡

slide-5
SLIDE 5

P2P ¡Groups ¡Must ¡Be ¡Managed ¡by ¡ App ¡Developers ¡

  • 1. Group ¡forma9on ¡

– Discovery, ¡GO ¡nego9a9on, ¡Address ¡config ¡

  • 2. Data ¡transfer ¡
  • 3. Group ¡tear ¡down ¡

Mobile ¡and ¡Ubiquitous ¡Compu9ng ¡2015/16 ¡ 5 ¡

Group ¡Forma,on ¡

slide-6
SLIDE 6

THE ¡TERMITE ¡TESTBED ¡

Mobile ¡and ¡Ubiquitous ¡Compu9ng ¡2015/16 ¡ 6 ¡

slide-7
SLIDE 7

Termite: ¡WiFi ¡Direct ¡Simulator ¡

  • Wdirect ¡testable ¡only ¡w/ ¡real ¡devices ¡

– Emulator ¡does ¡not ¡emulate ¡WiFi ¡Direct ¡

  • Use ¡Termite ¡to ¡emulate ¡WDirect ¡nets ¡
  • Termite ¡consists ¡of: ¡

– Sandalone ¡console ¡ – Library ¡packaged ¡with ¡apps ¡

  • Tertmite ¡workings ¡

– Console ¡takes ¡net ¡topology ¡script ¡ – Fires ¡net ¡events ¡to ¡emulator ¡instances ¡ – Library ¡emulates ¡WDirect ¡events ¡ – App ¡captures ¡and ¡handles ¡WDSim ¡events ¡

¡

Mobile ¡and ¡Ubiquitous ¡Compu9ng ¡2015/16 ¡ 7 ¡

T ermite Console Emulator Instances w/ T ermite Lib

slide-8
SLIDE 8

App

Termite ¡SoOware ¡Architecture ¡

Mobile ¡and ¡Ubiquitous ¡Compu9ng ¡2015/16 ¡ 8 ¡

Android on Hardware WiFi Direct API

Software Stack WiFi Direct

App Android on Emulator

Software Stack WDSim

WDSim API WDSim Console

Attention: Termite API not fully compatible with WDirect

slide-9
SLIDE 9

WIFI ¡DIRECT ¡ON ¡ANDROID ¡

Mobile ¡and ¡Ubiquitous ¡Compu9ng ¡2015/16 ¡ 9 ¡

slide-10
SLIDE 10

Finding ¡Nearby ¡Peers ¡

  • There ¡are ¡two ¡methods ¡of ¡finding ¡nearby ¡peers: ¡

– Peer ¡discovery ¡finds ¡all ¡nearby ¡peers ¡with ¡WiFi ¡Direct ¡

  • hap://developer.android.com/training/connect-­‑devices-­‑

wirelessly/wifi-­‑direct.html ¡ ¡

– Service ¡discovery ¡finds ¡all ¡nearby ¡peers ¡with ¡WiFi ¡ Direct ¡that ¡are ¡running ¡the ¡same ¡app ¡

  • hap://developer.android.com/training/connect-­‑devices-­‑

wirelessly/nsd-­‑wifi-­‑direct.html ¡ ¡

Mobile ¡and ¡Ubiquitous ¡Compu9ng ¡2015/16 ¡ 10 ¡

slide-11
SLIDE 11

Quirks ¡If ¡You ¡Use ¡Service ¡Discovery ¡

  • In ¡order ¡to ¡find ¡each ¡other, ¡both ¡devices ¡must ¡call ¡

WiFiP2pManager.discoverServices, ¡not ¡just ¡one. ¡This ¡method ¡puts ¡ the ¡devices ¡in ¡the ¡FIND ¡phase, ¡in ¡which ¡they ¡both ¡adver9se ¡and ¡ listen ¡for ¡nearby ¡services. ¡If ¡you ¡do ¡not ¡call ¡ WiFiP2pManager.discoverServices, ¡your ¡device ¡will ¡not ¡adver9se ¡ itself, ¡and ¡other ¡devices ¡will ¡not ¡be ¡able ¡to ¡find ¡it. ¡Issue ¡report ¡on ¡ the ¡Android ¡issue ¡tracker. ¡

– haps://code.google.com/p/android/issues/detail?id=37425 ¡ ¡

  • The ¡Android ¡specifica9on ¡claims ¡that ¡service ¡discovery ¡con9nues ¡

un9l ¡the ¡phone ¡finds ¡a ¡device, ¡but ¡it ¡was ¡not ¡very ¡reliable ¡in ¡our ¡

  • tests. ¡Some9mes ¡devices ¡failed ¡to ¡find ¡each ¡other, ¡but ¡later ¡found ¡

each ¡other ¡if ¡we ¡called ¡WiFiP2pManager.discoverServices ¡a ¡second ¡

  • 9me. ¡

Mobile ¡and ¡Ubiquitous ¡Compu9ng ¡2015/16 ¡ 11 ¡

slide-12
SLIDE 12

Connect ¡to ¡Peers ¡

  • Follow ¡the ¡developer ¡guide: ¡

– hap://developer.android.com/guide/topics/connec9vity/wifip2p.html ¡

  • Quirks: ¡

– If ¡you ¡already ¡have ¡a ¡pending ¡connec9on ¡with ¡a ¡peer, ¡you ¡ cannot ¡aaempt ¡to ¡connect ¡to ¡a ¡second ¡peer. ¡If ¡you ¡wish ¡to ¡ automa9cally ¡connect ¡to ¡all ¡the ¡peers ¡you ¡discover, ¡you ¡ must ¡add ¡the ¡devices ¡to ¡a ¡queue, ¡and ¡connect ¡to ¡them ¡one ¡ at ¡a ¡9me. ¡We ¡recommend ¡sor9ng ¡peers ¡into ¡three ¡queues: ¡

  • available ¡
  • connec9ng ¡(max ¡size: ¡1) ¡
  • connected ¡

Mobile ¡and ¡Ubiquitous ¡Compu9ng ¡2015/16 ¡ 12 ¡

slide-13
SLIDE 13

Make ¡Peers ¡Talk ¡1/4 ¡

  • Every ¡phone ¡has ¡a ¡MAC ¡address ¡and ¡an ¡IP ¡address. ¡By ¡the ¡nature ¡of ¡

the ¡WiFi ¡Direct ¡connec9on, ¡the ¡group ¡owner ¡is ¡aware ¡of ¡all ¡the ¡ clients ¡MAC ¡addresses, ¡but ¡the ¡clients ¡are ¡not ¡aware ¡of ¡each ¡other ¡

  • In ¡order ¡to ¡get ¡clients ¡to ¡talk ¡to ¡each ¡other, ¡they ¡must ¡be ¡aware ¡of ¡

each ¡other. ¡To ¡solve ¡this ¡problem, ¡we ¡needed ¡to ¡make ¡the ¡group ¡

  • wner ¡distribute ¡a ¡list ¡of ¡the ¡clients ¡MAC ¡and ¡IP ¡addresses ¡to ¡all ¡

clients ¡

Mobile ¡and ¡Ubiquitous ¡Compu9ng ¡2015/16 ¡ 13 ¡

slide-14
SLIDE 14

Make ¡Peers ¡Talk ¡2/4 ¡

  • Unfortunately, ¡the ¡Wi-­‑Fi ¡Direct ¡API ¡does ¡not ¡give ¡the ¡

group ¡owner ¡direct ¡access ¡to ¡the ¡IP ¡addresses ¡of ¡the ¡

  • clients. ¡The ¡group ¡owner ¡only ¡has ¡access ¡to ¡its ¡clients’ ¡

MAC ¡addresses. ¡To ¡get ¡access ¡the ¡clients’ ¡IP ¡addresses, ¡ ini9ate ¡a ¡socket ¡connec9on ¡from ¡the ¡client ¡to ¡the ¡group ¡

  • wner. ¡

Mobile ¡and ¡Ubiquitous ¡Compu9ng ¡2015/16 ¡ 14 ¡

slide-15
SLIDE 15

Make ¡Peers ¡Talk ¡3/4 ¡

  • Once ¡that ¡socket ¡connec9on ¡is ¡established, ¡the ¡client ¡

can ¡send ¡a ¡string ¡containing ¡its ¡MAC ¡address ¡to ¡the ¡ group ¡owner, ¡so ¡the ¡group ¡owner ¡would ¡be ¡able ¡to ¡ add ¡the ¡IP ¡of ¡the ¡socket ¡connec9on ¡to ¡the ¡known ¡ MAC ¡of ¡the ¡client, ¡thereby ¡crea9ng ¡a ¡MAC, ¡IP ¡pair ¡

Mobile ¡and ¡Ubiquitous ¡Compu9ng ¡2015/16 ¡ 15 ¡

slide-16
SLIDE 16

Make ¡Peers ¡Talk ¡4/4 ¡

  • The ¡group ¡owner ¡can ¡store ¡all ¡IP, ¡MAC ¡address ¡pairs ¡

in ¡a ¡hashmap, ¡and ¡distribute ¡this ¡hash ¡map ¡via ¡ socket ¡connec9on ¡back ¡to ¡all ¡the ¡clients ¡

Mobile ¡and ¡Ubiquitous ¡Compu9ng ¡2015/16 ¡ 16 ¡

slide-17
SLIDE 17

Relevant ¡Pointers ¡

  • android.net.wifi.p2p ¡

hap://developer.android.com/reference/android/net/wifi/p2p/package-­‑summary.html ¡

  • Connec9ng ¡with ¡Wi-­‑Fi ¡Direct

hap://developer.android.com/training/connect-­‑devices-­‑wirelessly/wifi-­‑direct.html ¡

¡

Mobile ¡and ¡Ubiquitous ¡Compu9ng ¡2015/16 ¡ 17 ¡