WiFi$Direct$in$Android$ $ Mobile$Compu5ng$ MEIC/MERC$2014/15$ $ - - PowerPoint PPT Presentation

wifi direct in android
SMART_READER_LITE
LIVE PREVIEW

WiFi$Direct$in$Android$ $ Mobile$Compu5ng$ MEIC/MERC$2014/15$ $ - - PowerPoint PPT Presentation

WiFi$Direct$in$Android$ $ Mobile$Compu5ng$ MEIC/MERC$2014/15$ $ Nuno$Santos$ WiFi$Direct:$What$Is$It?$ Client$1$ WiGFi$Direct$allows$devices$to$ connect$directly$to$each$ Acts$as$SoMware$ other$using$methods$similar$ Access$Point$


slide-1
SLIDE 1

WiFi$Direct$in$Android$

$ Mobile$Compu5ng$

MEIC/MERC$2014/15$ $ Nuno$Santos$

slide-2
SLIDE 2

WiFi$Direct:$What$Is$It?$

  • WiGFi$Direct$allows$devices$to$

connect$directly$to$each$

  • ther$using$methods$similar$

to$tradi5onal$WiGFi,$except$ without$a$preGestablished$ access$point$

– Instead,$they$nego5ate$to$ establish$one$peer$device$to$ act$as$a$soMware$access$point$ for$all$the$other$devices$in$the$ group$

Mobile$Compu5ng$2014/15$ 2$

Acts$as$SoMware$ 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$Compu5ng$2014/15$ 3$

GO$

  • f$Group$

Clients$

  • f$Group$

P2P# Group#

slide-4
SLIDE 4

WiFi$Direct$Supports$Many$Topologies$

Mobile$Compu5ng$2014/15$ 4$

slide-5
SLIDE 5

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

  • 1. Group$forma5on$

– Discovery,$GO$nego5a5on,$Address$config$

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

Mobile$Compu5ng$2014/15$ 5$

Group#Forma,on#

slide-6
SLIDE 6

THE#TERMITE#TESTBED#

Mobile$Compu5ng$2014/15$ 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$Compu5ng$2014/15$ 7$

T ermite Console Emulator Instances w/ T ermite Lib

slide-8
SLIDE 8

App

Termite$SoMware$Architecture$

Mobile$Compu5ng$2014/15$ 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$Compu5ng$2014/15$ 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$

  • h`p://developer.android.com/training/connectGdevicesG

wirelessly/wifiGdirect.html$$

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

  • h`p://developer.android.com/training/connectGdevicesG

wirelessly/nsdGwifiGdirect.html$$

Mobile$Compu5ng$2014/15$ 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$adver5se$and$ listen$for$nearby$services.$If$you$do$not$call$ WiFiP2pManager.discoverServices,$your$device$will$not$adver5se$ itself,$and$other$devices$will$not$be$able$to$find$it.$Issue$report$on$ the$Android$issue$tracker.$

– h`ps://code.google.com/p/android/issues/detail?id=37425$$

  • The$Android$specifica5on$claims$that$service$discovery$con5nues$

un5l$the$phone$finds$a$device,$but$it$was$not$very$reliable$in$our$ tests.$Some5mes$devices$failed$to$find$each$other,$but$later$found$ each$other$if$we$called$WiFiP2pManager.discoverServices$a$second$ 5me.$

Mobile$Compu5ng$2014/15$ 11$

slide-12
SLIDE 12

Connect$to$Peers$

  • Follow$the$developer$guide:$

– h`p://developer.android.com/guide/topics/connec5vity/wifip2p.html$

  • Quirks:$

– If$you$already$have$a$pending$connec5on$with$a$peer,$you$ cannot$a`empt$to$connect$to$a$second$peer.$If$you$wish$to$ automa5cally$connect$to$all$the$peers$you$discover,$you$ must$add$the$devices$to$a$queue,$and$connect$to$them$one$ at$a$5me.$We$recommend$sor5ng$peers$into$three$queues:$

  • available$
  • connec5ng$(max$size:$1)$
  • connected$

Mobile$Compu5ng$2014/15$ 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$connec5on,$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$Compu5ng$2014/15$ 13$

slide-14
SLIDE 14

Make$Peers$Talk$2/4$

  • Unfortunately,$the$WiGFi$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,$ ini5ate$a$socket$connec5on$from$the$client$to$the$group$

  • wner.$

Mobile$Compu5ng$2014/15$ 14$

slide-15
SLIDE 15

Make$Peers$Talk$3/4$

  • Once$that$socket$connec5on$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$connec5on$to$the$known$ MAC$of$the$client,$thereby$crea5ng$a$MAC,$IP$pair$

Mobile$Compu5ng$2014/15$ 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$connec5on$back$to$all$the$clients$

Mobile$Compu5ng$2014/15$ 16$

slide-17
SLIDE 17

Relevant$Pointers$

  • android.net.wifi.p2p$

h`p://developer.android.com/reference/android/net/wifi/p2p/packageGsummary.html$

  • Connec5ng$with$WiGFi$Direct

h`p://developer.android.com/training/connectGdevicesGwirelessly/wifiGdirect.html$

$

Mobile$Compu5ng$2014/15$ 17$