61
CS434/534: Topics in Networked (Networking) Systems Mobile Networking System: Making Connections: Cloud; NFC Yang (Richard) Yang Computer Science Department Yale University 208A Watson Email: [email protected] http://zoo.cs.yale.edu/classes/cs434/

CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

CS434/534: Topics in Networked (Networking) Systems

Mobile Networking System: Making Connections: Cloud; NFC

Yang (Richard) YangComputer Science Department

Yale University208A Watson

Email: [email protected]

http://zoo.cs.yale.edu/classes/cs434/

Page 2: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Admin.❒ Project planning

❍ Checkpoint II: Apr. 20• Initial design; feedback from instructor/TF

❍ Checkpoint III: Apr. 27• Design refined; key components details

❍ Final due: May 4• No more than 6 page write up

2

Page 3: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

3

Recap: Making Bluetooth Conn.❒ Underlying technology

❍ Nodes form piconet: one master and upto 7 slaves• A node makes itself discoverable• The slaves discover the master and follow the

pseudorandom jumping sequence of the master❍ Higher-layer introduces profiles to provide specific functions

❒ Android Bluetooth software API❍ Configuration: Announce Bluetooth permission❍ Intent to request systems service: turn on BT, become

discoverable❍ Obtaining bonded devices: query, register broadcast

receiver❍ Connection:

• Server: mBluetoothAdapter.listenUsingRfcommWithServiceRecord(SNAME,MY_UUID); …

A piconet

Page 4: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Recap: Making WiFi Direct Conn.

4http://www.it.uc3m.es/pablo/papers/pdf/2012_camps_commag_wifidirect.pdf

Page 5: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

WiFi Direct Software Framework (Android)❒ Setup permission in Manifest❒ Create IntentFilter and Broadcast Receiver to obtain related updates

❍ intentFilter.addAction• WIFI_P2P_STATE_CHANGED_ACTION• WIFI_P2P_PEERS_CHANGED_ACTION• WIFI_P2P_CONNECTION_CHANGED_ACTION• WIFI_P2P_THIS_DEVICE_CHANGED_ACTION

❍ /** register the BroadcastReceiver with the intent values to be matched */@Overridepublic void onResume() {

super.onResume();receiver = new WiFiDirectBroadcastReceiver(mManager, mChannel, this);registerReceiver(receiver, intentFilter);

}

@Overridepublic void onPause() {

super.onPause();unregisterReceiver(receiver);

}

❒ Initiate action❍ Call discoverPeers

mManager.discoverPeers(mChannel, new WifiP2pManager.ActionListener() {…

❍ Call connect ❍ Create group

5

Page 6: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

6

Recap: Making Cellular Conn. ❒ Issue: Given the large overhead to set up radio

resources, UMTS implements radio resource control (RRC) state machine on mobile devices

❒ How to best design this framework (or more generally power management framework for wireless) is not fully solved.

Channel Radio Power

IDLE Not allocated

Almost zero

CELL_FACH Shared, Low Speed

Low

CELL_DCH Dedicated, High Speed

High

Page 7: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

7

Outline❒ Admin❒ Android

❍ Platform overview❍ Basic concepts❍ Inter-thread: execution model with multiple threads❍ Inter-process: component composition❍ Inter-machine: network-wise composition

• Service discovery• Make connections

– Bluetooth– WiFi Direct– Cellular– Mobile cloud

Page 8: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Discussion: Mobile Cloud Connections

❒ What are some reasons (services) you can think of involving mobile-cloud connections?

8

Page 9: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Example Mobile Cloud Services

❒ Push notification service❒ Storage and sync, e.g.,

❍ Syncing and storage service (iCloud)❍http://blog.udinic.com/2013/07/24/write-

your-own-android-sync-adapter/❒ Compute and split architecture, e.g.,

❍ Siri, Amazon silk (http://docs.aws.amazon.com/silk/latest/developerguide/introduction.html)

9

Page 10: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

10

Outline❒ Admin❒ Android

❍ Platform overview❍ Basic concepts❍ Inter-thread: execution model with multiple threads❍ Inter-process: component composition❍ Inter-machine: network-wise composition

• Service discovery• Make connections

– Bluetooth– WiFi Direct– Cellular– Mobile cloud

» Cloud push notification

Page 11: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Setting: Data Refresh❒ A typical design pattern is that a device

updates/receives data (e.g., news) from publisher

❒ A first solution is mobile pull, but this can create large overhead

11

Page 12: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Shared Push Service

❒ A single persistent connection from device to a cloud push service provider

❒ Multiple application providers push to the service provider

❒ Service provider pushes to a device using the persistent connection

❒ Two examples❍ Apple Push Notification Service (APNS)❍ Firebase (Google) Cloud Messaging (FCM/GCM)

12

Page 13: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Design Requirements of a Shared Push Service

❒ Security/Authorization❍ Do not allow arbitrary app to push to a device

❒ Scalability❍ A large scale system may have millions of clients

❒ Fault tolerance❍ Client/device, push servers all can fail

❒ Generality❍ Can be used by diverse applications 13

Page 14: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Design Point: Authorization/Sub-Pub Management

❒ Many options, e.g.,❍ Open group, e.g., publishers push topics and

devices subscribe to topics❍ Closed group

14

App Device

Registration(DEV_ID, App_ID)

Device notifies registration ID to its server;

Page 15: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Design Point: What to Push?

❒ Option 1: Just push signal (data available) to devices and then devices fetch from app servers

❒ Option 2: push app data

15

App

Device

Page 16: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Apple Push Notification Service

16

❒ iOS device maintains a persistent TCP connection to an Apple Push Notification Server (APNS)

A push notification from a provider to a client application

Multi-providers to multiple devices

Page 17: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

APNS Authorization: Device Token

17

❒ Device token Contains information that enables APNS to locate the device❍ Client app needs to provide the token to its app provider❍ Device token should be requested and passed to providers

every time the application launches

Page 18: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Apple Push Notification Data

❒ Each push notification carries a payload❍ 256 bytes maximum❍ Best effort delivery

❒ App provider provides a JSON dictionary object, which contains another dictionary identified by the key aps

❒ App specifies the following actions• An alert message to display to the user• A number to badge the application icon with• A sound to play

18

Page 19: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

APNS Example: Client

19

1. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

2. {3. // Let the device know we want to receive push notifications4. [[UIApplication sharedApplication] registerForRemoteNotificationTypes:5. (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound |

UIRemoteNotificationTypeAlert)];6.7. return YES;8. }

9. - (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo

10. {//userInfo contains the notification11. NSLog(@"Received notification: %@", userInfo);12. }

13. - (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken

14. {15. NSLog(@"My token is: %@", deviceToken);16. }

Page 20: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

APNS Example: Server

20

1. $devicetoken ='f05571e4be60a4e11524d76e4366862128f430522fb470c46fc6810fffb07af7’;

2. // Put your private key's passphrase here:3. $passphrase = 'PushChat';4. // Put your alert message here:5. $message = ’CS434: my first push notification!';

1. $ctx = stream_context_create();2. Stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');3. stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);

4. // Open a connection to the APNS server5. $fp = stream_socket_client(6. 'ssl://gateway.sandbox.push.apple.com:2195', $err,7. $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);

8. if (!$fp)9. exit("Failed to connect: $err $errstr" . PHP_EOL);

10. echo 'Connected to APNS' . PHP_EOL;

Page 21: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

APNS Example: Server (cont’)

21

16. // Create the payload body17. $body['aps'] = array(18. 'alert' => $message,19. 'sound' => 'default'20. );

21. // Encode the payload as JSON22. $payload = json_encode($body);

23. // Build the binary notification24. $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload))

. $payload;

25. // Send it to the server26. $result = fwrite($fp, $msg, strlen($msg));

27. if (!$result)28. echo 'Message not delivered' . PHP_EOL;29. else30. echo 'Message successfully delivered' . PHP_EOL;

31. // Close the connection to the server32. fclose($fp);

Page 22: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Firebase Cloud Messaging

❒ Very similar to APNS

22

FCM Servers

https://developers.google.com/cloud-messaging/FCM is a newer version of GCM

Page 23: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

23

Outline❒ Admin❒ Android

❍ Platform overview❍ Basic concepts❍ Inter-thread: execution model with multiple threads❍ Inter-process: component composition❍ Inter-machine: network-wise composition

• Service discovery• Make connections

– Bluetooth– WiFi Direct– Cellular– Mobile cloud

» Basic use» Thialfi as an implementation example

Page 24: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Example Implementation: Thialfi

❒ Deployed in Chrome Sync, Contacts, Google Plus

❒ Goals❍ Scalable: tracks millions of clients and objects❍ Fast: notifies clients in less than a second❍ Reliable: even when entire data centers fail

24

Page 25: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Thialfi Overview

Thialfi client library

Register X Notify X

ClientData center

X: C1, C2

Client C1 Client C2

Thialfi Service

Update XRegister

Register

Update XApplication backend

Notify X Notify X

25

Page 26: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

26

Outline❒ Admin❒ Android

❍ Platform overview❍ Basic concepts❍ Inter-thread: execution model with multiple threads❍ Inter-process: component composition❍ Inter-machine: network-wise composition

• Service discovery• Make connections

– Bluetooth– WiFi Direct– Cellular– Mobile cloud

» Basic use» Thialfi as an implementation example

» Overview, abstraction

Page 27: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Thialfi Abstraction

❒ Objects have unique IDs and version numbers, monotonically increasing on every update

❒ Delivery guarantee❍ Registered clients learn latest version number❍ Reliable signal only: cached object ID X at version Y

• Why signal only: For most applications, reliable signal is enough

27

Page 28: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Thialfi Client API

28

Page 29: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

API Without Failure Recovery

Thialfi Service

Publish(objectId, version)

ClientLibrary

Register(objectId)Unregister(objectId)

Notify(objectId, version)

29

Page 30: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Architecture

ClientBigtable

• Matcher: Object ID à registered clients, version• Registrar: Client ID à registered objects, notifications

Client

Registrar

MatcherObjectBigtable

Data center

Notifications Application Backend

Registrations, notifications,acknowledgments

Client library

30

• Each server handles a contiguous range of keys• Each server maintains an in-memory version• Bigtable: log structured, fast write

Page 31: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

C1: x, v7C2: x, v7C1: x, v5C2: x, v5

x: v5; C1, C2x: v7; C1, C2x: v7; C1, C2

x

Life of a Notification

ClientBigtable

C1: x, v7

C2: x, v7

Notify: x, v7

Client C2

MatcherObjectBigtable

Data center

Publish(x, v7)x, v7

Ack: x, v7

31

Registrar

Page 32: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

32

Outline❒ Admin❒ Android

❍ Platform overview❍ Basic concepts❍ Inter-thread: execution model with multiple threads❍ Inter-process: component composition❍ Inter-machine: network-wise composition

• Service discovery• Make connections

– Bluetooth– WiFi Direct– Cellular– Mobile cloud

» Basic use» Thialfi as an implementation example

» Overview, abstraction» Failure recovery

Page 33: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Data center lossServer state loss/schema migrationPartial storage unavailability

Possible Failures

ClientLibrary

ClientBigtable Registrar

MatcherObjectBigtable

ClientBigtable Registrar

MatcherObjectBigtable

. . .

Data center 1 Data center nThialfi Service

ClientStore

Client restartClient state loss

Publish Feed

Network failures

33 3/5/12

Page 34: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Failures

❒ Client restart❒ Client state loss❒ Network failures❒ Partial storage unavailability❒ Server state loss / schema migration❒ Publish feed loss❒ Data center outage

34

Page 35: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

How to Handle Failures❒ Principle: Soft state only, where a state at the third

party is soft state if the the entity who sets up the state does not refresh it, the state will be pruned at the third party

❒ Thialfi has two types of states, and both are soft state❍ registration state❍ notification state

❒ State recovery❍ Registration state

• registratinoReissueRegistrations() at client• Registration Sync Protocol to propagate to server

❍ Notification state recovery• allow NotifyUnknown()

35

Page 36: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Recovering Client Registrations

36

Registrar

MatcherObjectBigtable

x

y

x yReissueRegistrations()

Register(x); Register(y)

Page 37: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Registrar

MatcherObjectBigtable

Register: x, y

Syncing Client Registrations

x

y

Hash(x, y) x y

• Goal: Keep client-registrar registration state in sync• Every message contains hash of registered objects• Registrar initiates protocol when detects out-of-sync• Allows simpler reasoning of registration state

Reg sync

37

Hash(x, y)

Merkle tree for syncing large number of objects

Page 38: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Recovering From Lost Versions

❒ Versions may be lost, e.g. schema migration

❒ Inform client with NotifyUnknown(objectId)❍ Client must refresh, regardless of its current state

38

Page 39: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Notification Latency Breakdown

0

100

200

300

Notification latency (ms)

Matcher to Registrar RPC (Batched)Matcher Bigtable Read

Matcher Bigtable Write (Batched)Bridge to Matcher RPC (Batched)App Backend to Bridge

Batching accounts for significant fraction of latency39

Page 40: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Thialfi Usage by Applications

40

Application Language Network Channel

Client Linesof Code(Semi-colons)

Chrome Sync C++ XMPP 535

Contacts JavaScript Hanging GET 40

Google+ JavaScript Hanging GET 80

Android Application

Java C2DM + Standard GET

300

Google BlackBerry Java RPC 340

Page 41: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Pointers to Additional Work

❒ See Facebook Wormhole pub/sub design

❒ See Sapphire automatic mobile/cloud split design

41

Page 42: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

42

Outline❒ Admin❒ Android

❍ Platform overview❍ Basic concepts❍ Inter-thread: execution model with multiple threads❍ Inter-process: component composition❍ Inter-machine: network-wise composition

• Service discovery• Make connections

– Bluetooth– WiFi Direct– Cellular– Mobile cloud– Near Field Communication (NFC)

Page 43: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

43

RFID (Radio Frequency Identification)

❒ The initial development of NFC is RFID, with many applications, e.g., ❍Secure Entry

cards ❍Supply chain

management

Page 44: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

RFID Basic Architecture

44

Page 45: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

RFID Tag

❒ Tag is a device used to transmit information such as a serial number to the reader in a contact less manner

❒ Classified as❍ Passive – energy from reader ❍ Active - battery battery❍ Semi-passive – battery and energy

from battery and energy from reader

45

Page 46: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

RFID Reader

❒ Also known an interrogator ❒ Reader powers passive tags with RF energy

(for passive tags)❒ Consists of:

❍ Transceiver❍ Antenna❍ Microprocessor❍ Network interface

46

Page 47: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Nexus Hardware

47

1.Front-facing camera2.Earpiece3.Power button4.Volume buttons5.Headset jack6.Speaker7.USB Type-C port8.Laser auto focus & dual-LED flash9.Rear-facing camera10.NFC11.SIM card tray12.Fingerprint sensor

Page 48: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

RFID Passive Receiver: Foundation

48

https://en.wikipedia.org/wiki/Faraday%27s_law_of_induction#/media/File:Faraday_emf_experiment.svg

Page 49: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Near Field RFID

❒ <= 100 Mhz 49

Page 50: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

How far can a passive tag be read?❒ Assume distance limited by power available

to run the tag’s circuits

50

Page 51: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Maximum Distances to Read UHF Passive Tag

51

Page 52: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Example NF Use: Contactless Smart Card

❒ Proximity Smart Cards (13.56 MHz)❍ Range = 4 inches (10 centimeter)❍ Baud rate = 106 kilobaud❍ ISO/IEC 14443

❒ Vicinity Smart Cards (13.56 MHz)❍ Range = 3 feet (1 meter)❍ Baud rate = 26.48 kilobaud❍ ISO/IEC 15693

❒ Animal Identification (134 KHz, 125 KHz@US)❍ ISO 11784/11785

❒ VeriChip as human plantable RFID tag (134 KHz)

52

Page 53: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Far Field RFID

53

Page 54: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

RFID MAC Protocol

❒ Select phase ❍ Single out particular tag population with one or more bits with query tree protocol protocol

❒ Inventory phase– identify individual tag using Q protocol (slotted-aloha based)❍ Reader sends Query with parameter Q and Session number (Q=4 is suggested

default) ❍ Reader creates slotted time ❍ Tags pick random 16-bit number as handle❍ Tags in requested session pick a random number in the range [0,2^Q-1] for

slot_number❍ If slot_number = 0, backscatter handle ❍ If slot_number != 0, wait that number of slots to backscatter ❍ Reader ACKs individual tag with handle and goes to access phase. All other tags wait. ❍ If more that one tag answers, reader can send same Q again or send modified Q

❒ Access phase❍ Reader interacts with tags requesting EPC number and any other information

54

Page 55: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Select Phase: Query Tree

55

Page 56: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Select Phase: Query Tree

56

Page 57: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Inventory Phase (Q Protocol; Slotted Aloha)

57

Page 58: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Android NFC User Programming API

❒ System discovers NFC tag❒ Key issue: how to determine the application

to be invoked❍ Implication: need a tag dispatch system

❒ Android tag dispatch design❍ Parsing the NFC tag and figuring out the MIME type or a URI that

identifies the data payload in the tag.❍ Encapsulating the MIME type or URI and the payload into an intent. ❍ Starts an activity based on the intent.

58

https://developer.android.com/guide/topics/connectivity/nfc/nfc.html

Page 59: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Tag to MIME/URI

❒ Requires tag uses NDEF (NFC Data Exchange Format), which consists of a sequence of NDEF records❍ First record provides 3-bit TNF (type name

format)

59

Page 60: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Intent Dispatch❒ ACTION_NDEF_DISCOVERED: This intent is used to start an

Activity when a tag that contains an NDEF payload is scanned and is of a recognized type. This is the highest priority intent, and the tag dispatch system tries to start an Activity with this intent before any other intent, whenever possible.

❒ ACTION_TECH_DISCOVERED: If no activities register to handle the ACTION_NDEF_DISCOVERED intent, the tag dispatch system tries to start an application with this intent. This intent is also directly started (without starting ACTION_NDEF_DISCOVERED first) if the tag that is scanned contains NDEF data that cannot be mapped to a MIME type or URI, or if the tag does not contain NDEF data but is of a known tag technology.

❒ ACTION_TAG_DISCOVERED: This intent is started if no activities handle the ACTION_NDEF_DISCOVERED or ACTION_TECH_DISCOVEREDintents.

60

Page 61: CS434/534: Topics in Networked (Networking) Systemszoo.cs.yale.edu/classes/cs434/cs434-2017-spring/lectures/22-mobil… · 3 Recap: Making Bluetooth Conn. Underlying technology Nodes

Backup Slides

61