CS434/534: Topics in Networked (Networking) Systems Mobile Networking System: Making Connections: Bluetooth; WiFi Direct; Cellular Yang (Richard) Yang.

Slides:



Advertisements
Similar presentations
Categories of I/O Devices
Advertisements

Bluetooth. Wireless networking technology Limited broadcast range (< 10 meters) Example uses include Connecting headsets to phones, keyboard/mouse to.
1 Working with the Bluetooth radio Nilanjan Banerjee Mobile Systems Programming University of Arkansas Fayetteville, AR
CPSC Network Layer4-1 IP addresses: how to get one? Q: How does a host get IP address? r hard-coded by system admin in a file m Windows: control-panel->network->configuration-
Link/Network Layer: MIMO, Cognitive Radio; Energy Management of Radio Resource Control (RRC) Y. Richard Yang 11/15/2012.
28.2 Functionality Application Software Provides Applications supply the high-level services that user access, and determine how users perceive the capabilities.
Socket Programming.
1 Creating a network app Write programs that  run on different end systems and  communicate over a network.  e.g., Web: Web server software communicates.
1 Overview r Socket programming with TCP r Socket programming with UDP r Building a Web server.
Chapter 15 – Part 2 Networks The Internal Operating System The Architecture of Computer Hardware and Systems Software: An Information Technology Approach.
1 School of Computing Science Simon Fraser University CMPT 771/471: Internet Architecture and Protocols Socket Programming Instructor: Dr. Mohamed Hefeeda.
TCP. Learning objectives Reliable Transport in TCP TCP flow and Congestion Control.
Cellular Networks Guest lecture by Li Erran Li, Bell Labs COS 461: Computer Networks 4/18/2012 W 10-10:50am in Architecture N101 1 Cellular Core Network.
Fundamentals of Python: From First Programs Through Data Structures
1 CMSC628: Introduction to Mobile Computing Nilanjan Banerjee Mobile Systems Programming (Acknowledgment to Deepa Shinde and Cindy Atheron University of.
Cosc 5/4730 Android Bluetooth. Bluetooth Basics First off Bluetooth is NOT – Infrared, which requires line-of-sight – a/b/g/n. It was designed as.
Bluetooth. Bluetooth is an open, wireless protocol for exchanging data between devices over a short distance. –managed by the Bluetooth Special Interest.
CEG3185 Tutorial 4 Prepared by Zhenxia Zhang Revised by Jiying Zhao (2015w)
CN2668 Routers and Switches Kemtis Kunanuraksapong MSIS with Distinction MCTS, MCDST, MCP, A+
LWIP TCP/IP Stack 김백규.
 Socket  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming.
Distributed Topology Construction of Bluetooth Personal Area Networks Theodoros Salonidis, Pravin Bhagwat, Leandros Tassiulas and Richard LaMaire.
Practicum: - Client-Server Computing in Java Fundamental Data Structures and Algorithms Margaret Reid-Miller 13 April 2004.
Dr. John P. Abraham Professor University of Texas Pan American Internet Applications and Network Programming.
Cellular Networks and Mobile Computing COMS , Spring 2012 Instructor: Li Erran Li
LRPC Firefly RPC, Lightweight RPC, Winsock Direct and VIA.
Profiling Resource Usage for Mobile Applications: a Cross-layer Approach Feng Qian 1, Zhaoguang Wang 1, Alexandre Gerber 2, Z. Morley Mao 1, Subhabrata.
1 COMP 431 Internet Services & Protocols Client/Server Computing & Socket Programming Jasleen Kaur February 2, 2016.
Socket programming in C. Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
Socket Programming original by Joonbok Lee KAIST heavily adapted by /Jens.
Introduction to Operating Systems Concepts
Scaling the Network: Subnetting and Protocols
Presenter: Tyler Newsome
Scaling the Network Chapters 3-4 Part 2
Virtualization of networks
Chapter 9: Transport Layer
Android Application -Architecture.
Instructor Materials Chapter 9: Transport Layer
Bluetooth.
Broadcast receivers.
Chapter 5 Network and Transport Layers
BLUETOOTH THE STANDARD & ISSUES.
Chapter 3 Internet Applications and Network Programming
CS 1652 Jack Lange University of Pittsburgh
BOOTP and DHCP Objectives
Reactive Android Development
Net 323: NETWORK Protocols
Client-Server Interaction
Chapter 3: Windows7 Part 4.
Transport Layer Our goals:
Wireless Communication between Android Application and Sensors
CS703 - Advanced Operating Systems
Multiple Processor Systems
Architectures of distributed systems Fundamental Models
Android Topics UI Thread and Limited processing resources
Socket Programming.
Chapter 15 – Part 2 Networks The Internal Operating System
Architectures of distributed systems Fundamental Models
TCP/IP Protocol Suite: Review
CSCD 330 Network Programming
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
CS4470 Computer Networking Protocols
Android Developer Fundamentals V2 Lesson 5
AT&T Developer Services Application Resource Optimizer (ARO)
Ch 17 - Binding Protocol Addresses
Architectures of distributed systems Fundamental Models
Computer Networks Protocols
Chapter 13: I/O Systems.
Exceptions and networking
Mobile Programming Broadcast Receivers.
Presentation transcript:

CS434/534: Topics in Networked (Networking) Systems Mobile Networking System: Making Connections: Bluetooth; WiFi Direct; Cellular Yang (Richard) Yang Computer Science Department Yale University 208A Watson Email: yry@cs.yale.edu http://zoo.cs.yale.edu/classes/cs434/

Admin. Project planning Start: Apr. 5 A meeting w/ instructor; Due: team, potential topics Checkpoint I: Apr. 13 (updated; Thursday) Initial ideas; survey of related work; feedback from instructor/TF Checkpoint II: Apr. 20 (updated) Initial design; feedback from instructor/TF Checkpoint III: Apr. 27 (updated) Design refined; key components details Final report: May 4 No more than 6 page write up

The data is called transaction data. The Binder Protocol %adb shell ls /sys/kernel/debug/binder see transactions If one process sends data to another process, it is called transaction. The data is called transaction data.

Recap: Binder + Service Manager $ adb shell service list Recap: Binder + Service Manager Client Service Manager Server service list 1 IXXX Name:Handle onTransact(…) Name:Handle 2 thread pool Name:Handle Handle=0 transact(…) Service manager: DNS Binder driver: rounter 3 4 5 User Space Kernel Space Binder Driver: /dev/binder memory mapping

Recap: Network Service Discovery and Execution request src dst result location service SD

Recap: The Linda Paradigm Naming scheme: arbitrary tuples (heterogeneous-type vectors) Name resolution: Nodes write into shared memory Nodes read matching tuples from shared memory exact matching is required for extraction                                                                                        

Recap: DNS DNS clients <name, service> routers IP address Lots of problems with what the Internet is tuned to do today DNS is rather static servers

Recap: DNS-Service Discovery Leverage DNS message format, but each node can announce its own services Multicast in a small world no central address server each node is a responder link-local addressing send to multicast address: 224.0.0.251 Printer Network 169.254.1.219 169.254.4.51 169.254.10.29

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 Making standard connection: TCP Socket

TCP Socket Big Picture Welcome socket: the waiting room connSocket: the operation room TCP Socket Big Picture

Client/server Socket Workflow: TCP Server (running on hostid) Client create socket, port=x, for incoming request: welcomeSocket = ServerSocket(x) TCP connection setup create socket, connect to hostid, port=x clientSocket = Socket() wait for incoming connection request connectionSocket = welcomeSocket.accept() send request using clientSocket read request from connectionSocket write reply to close connectionSocket read reply from clientSocket

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 Making standard connection: TCP Socket Bluetooth

Recall: Bluetooth Physical Layer Nodes form piconet: one master and upto 7 slaves Each radio can function as a master or a slave The slaves discover the master and follow the pseudorandom jumping sequence of the master A piconet http://www.althos.com/tutorial/Bluetooth-tutorial-summary.html

Bluetooth Details Each BT device is identified by a 48 bit MAC address Operation Device Discovery Inquiry scan (Sender. at faster jumping freq than recv) Connection Inquiry scan: get device address; Page Scan: Use dest hop seq Pairing Authentication/share keys; after pairing, they become bonded https://learn.sparkfun.com/tutorials/bluetooth-basics

Bluetooth Profiles Src: http://www.althos.com/tutorial/Bluetooth-tutorial-hands-free-profile.html

Example: Handfree Profile

Bluetooth Software Framework Design in Android Discussion: How may Bluetooth be supported in Android? https://developer.android.com/guide/topics/connectivity/bluetooth.html

Bluetooth Software Framework Design in Android Announce permission Use intents to turn on BT, request discoverable <manifest ... >   <uses-permission android:name="android.permission.BLUETOOTH" />   <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />   ... </manifest> Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); Intent discoverableIntent =         new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300); startActivity(discoverableIntent); https://developer.android.com/guide/topics/connectivity/bluetooth.html

Accessor: Query Paired (Bonded) Devices Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices(); if (pairedDevices.size() > 0) {     // There are paired devices. Get the name and address of each paired device.     for (BluetoothDevice device : pairedDevices) {         String deviceName = device.getName();         String deviceHardwareAddress = device.getAddress(); // MAC address     } }

Accessor: Notified as Device Being Discovered @Override protected void onCreate(Bundle savedInstanceState) {     ...     // Register for broadcasts when a device is discovered.     IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);     registerReceiver(mReceiver, filter); } // Create a BroadcastReceiver for ACTION_FOUND. private final BroadcastReceiver mReceiver = new BroadcastReceiver() {     public void onReceive(Context context, Intent intent) {         String action = intent.getAction();         if (BluetoothDevice.ACTION_FOUND.equals(action)) {             // Discovery has found a device. Get the BluetoothDevice             // object and its info from the Intent.             BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);             String deviceName = device.getName();             String deviceHardwareAddress = device.getAddress(); // MAC address         }     } }; @Override protected void onDestroy() {     super.onDestroy();     ...     // Don't forget to unregister the ACTION_FOUND receiver.     unregisterReceiver(mReceiver); }

Mutator: Connecting as Server private class AcceptThread extends Thread {     private final BluetoothServerSocket mmServerSocket;     public AcceptThread() {         // Use a temporary object that is later assigned to mmServerSocket         // because mmServerSocket is final.         BluetoothServerSocket tmp = null;         try {             // MY_UUID is the app's UUID string, also used by the client code.             tmp = mBluetoothAdapter.listenUsingRfcommWithServiceRecord(SNAME, MY_UUID);         } catch (IOException e) {             Log.e(TAG, "Socket's listen() method failed", e);         }         mmServerSocket = tmp;     }     public void run() {         BluetoothSocket socket = null;         // Keep listening until exception occurs or a socket is returned.         while (true) {             try {                 socket = mmServerSocket.accept();             } catch (IOException e) {                 Log.e(TAG, "Socket's accept() method failed", e);                 break;             }             if (socket != null) {                 // A connection was accepted. Perform work associated with                 // the connection in a separate thread.                 manageMyConnectedSocket(socket);                 mmServerSocket.close();                 break;             }         }     }     // Closes the connect socket and causes the thread to finish.     public void cancel() {         try {             mmServerSocket.close();         } catch (IOException e) {             Log.e(TAG, "Could not close the connect socket", e);         }     } }

Mutator: Connecting as Client     public void run() {         // Cancel discovery because it otherwise slows down the connection.         mBluetoothAdapter.cancelDiscovery();         try {             // Connect to the remote device through the socket. This call blocks             // until it succeeds or throws an exception.             mmSocket.connect();         } catch (IOException connectException) {             // Unable to connect; close the socket and return.             try {                 mmSocket.close();             } catch (IOException closeException) {                 Log.e(TAG, "Could not close the client socket", closeException);             }             return;         }         // The connection attempt succeeded. Perform work associated with         // the connection in a separate thread.         manageMyConnectedSocket(mmSocket);     }     // Closes the client socket and causes the thread to finish.     public void cancel() {         try {             mmSocket.close();         } catch (IOException e) {             Log.e(TAG, "Could not close the client socket", e);         }     } } private class ConnectThread extends Thread {     private final BluetoothSocket mmSocket;     private final BluetoothDevice mmDevice;     public ConnectThread(BluetoothDevice device) {         // Use a temporary object that is later assigned to mmSocket         // because mmSocket is final.         BluetoothSocket tmp = null;         mmDevice = device;         try {             // Get a BluetoothSocket to connect with the given BluetoothDevice.             // MY_UUID is the app's UUID string, also used in the server code.             tmp = device.createRfcommSocketToServiceRecord(MY_UUID);         } catch (IOException e) {             Log.e(TAG, "Socket's create() method failed", e);         }         mmSocket = tmp;     }

(Offline) Remaining Design Issue How may you design a software framework supporting BT profiles?

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 also called WiFi P2P

WiFi Direct Initial support by a major vendor: Intel in their Centrino 2 platform in 2008 Google announced Wi-Fi Direct support in Android 4.0 in October 2011 Xbox in Xbox One in 2013 Windows 8 on PC iOS has its own proprietary feature

WiFi Direct: Basic Ideas Essentially embeds a software access point ("Soft AP"), into any device that must support Direct. The soft AP provides a version of Wi-Fi Protected Setup with its push-button or PIN-based setup Only one device needs to be aware of WiFi Direct Allow devices to form groups https://briolidz.wordpress.com/2012/01/10/wi-fi-protected-setup-wps/

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

Group Formation: Standard See backup slides on other types of Group Formation

WPS Provisioning See https://en.wikipedia.org/wiki/Wi-Fi_Protected_Setup

Discussion: Software API Design https://developer.android.com/guide/topics/connectivity/wifip2p.html

WiFi Direct Software Framework (Android) Setup permission in Manifest Create IntentFilter and Broadcast Receiver intentFilter.addAction WIFI_P2P_STATE_CHANGED_ACTION WIFI_P2P_PEERS_CHANGED_ACTION WIFI_P2P_CONNECTION_CHANGED_ACTION WIFI_P2P_THIS_DEVICE_CHANGED_ACTION In life cycle /** register the BroadcastReceiver with the intent values to be matched */     @Override     public void onResume() {         super.onResume();         receiver = new WiFiDirectBroadcastReceiver(mManager, mChannel, this);         registerReceiver(receiver, intentFilter);     }     @Override     public void onPause() {         super.onPause();         unregisterReceiver(receiver);     } Initiate Call discoverPeers mManager.discoverPeers(mChannel, new WifiP2pManager.ActionListener() { … Call connect requestGroupInfo

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 WiFi Direct Cellular connect

Recall: GSM Logical Channels and Request call setup from an MS Many link layers use a hybrid approach Mobile device uses random access to request radio resource The device holds the radio resource during a session MS BTS RACH (request signaling channel) AGCH (assign signaling channel) SDCCH (request call setup) SDCCH message exchange SDCCH (assign TCH) Communication

RRC State Management in UMTS Given the large overhead to set up radio resources, UMTS implements RRC state machine on mobile devices for data connection Channel Radio Power IDLE Not allocated Almost zero CELL_FACH Shared, Low Speed Low CELL_DCH Dedicated, High Speed High https://developer.android.com/training/efficient-downloads/efficient-network-access.html Courtesy: Erran Li.

RRC of a Large Commercial 3G Net Promo Delay: 2 Sec DCH Tail: 5 sec FACH Tail: 12 sec Tail Time: waiting inactivity timers to expire DCH: High Power State (high throughput and power consumption) FACH: Low Power State (low throughput and power consumption) IDLE: No radio resource allocated

RRC Effects on Device/Network FACH and DCH Wasted Radio Energy 34% Wasted Channel Occupation Time 33%

Case Study: Pandora Streaming Problem: High resource overhead of periodic audience measurements (every 1 min) Recommendation: Delay transfers and batch them with delay-sensitive transfers

Case Study: Google Search UL Packets DL Packets Bursts Usr Input RRC States Search three key words. ARO computes energy consumption for three phases I: Input phase S: Search phase T: Tail Phase Problem: High resource overhead of query suggestions and instant search Recommendation: Balance between functionality and resource when battery is low

Summary App developers may not be aware of interactions with underlying network radio resource management See backup slides on Radio Resource Control (RRC) on 3G and LTE A good topic to think about as a part of your project

Backup Slides

Other Types of WiFi Group Formation Settings

Wifi Direct Group Formation: Autonomous Group

WiFi Direct Group Formation: Persistent

Eval: Formation Types Comparison

RRC State Transition in 3G and LTE

Radio Resource Control Setup for Data in 3G + RRC connection setup: ~ 1sec Radio Bearer Setup: ~ 1 sec Figure source: HSDPA/HSUPA for UMTS: High Speed Radio Access for Mobile Communications. John Wiley and Sons, Inc., 2006. Source: Erran Li.

RRC State Transitions in LTE

RRC State Transitions in LTE RRC_IDLE No radio resource allocated Low power state: 11.36mW average power Promotion delay from RRC_IDLE to RRC_CONNECTED: 260ms

RRC state transitions in LTE RRC_CONNECTED Radio resource allocated Power state is a function of data rate: 1060mW is the base power consumption Up to 3300mW transmitting at full speed Cellular Networks and Mobile Computing (COMS 6998-11) Courtesy: Junxian Huang et al.

RRC state transitions in LTE Continuous Reception Send/receive a packet Promote to RRC_CONNECTED Reset Ttail Cellular Networks and Mobile Computing (COMS 6998-11) Courtesy: Junxian Huang et al.

RRC state transitions in LTE DRX Ttail expires Ttail stops Demote to RRC_IDLE Cellular Networks and Mobile Computing (COMS 6998-11) Courtesy: Junxian Huang et al.