Wide Area Networks
Cellular networking standards are governed by global organizations such as 3GPP: Third Generation Partnership Project1 involving thousands of people.
Cellular Network Evolution
2G mobile technologies
Global System for Mobile Communications (GSM)
- GSM is originally designed for voice.
- Introduced SIM (Subscriber Identity Module).
- Mass adoption of mobile phones started with GSM. Even today GSM is the leading mobile communication technology
- 900MHz and 1800MHz frequency bands.
- Frequency Division and Time Division Multiple Access (FDMA/TDMA) mechanism.
- 2.5G extension: GRPS (General Packet Radio Services) and EDGE (Enhanced Data Rate for GSM Evolution) for Data.
- Data rates were limited – struggled to support the demand for Internet/email
3G mobile technologies
UMTS (Universal Mobile Telecommunication Service)
- W-CDMA, TD-CDMA, and TD-SCDMA (China)
- SDPA,HSPA, HSPA+ are Data specific releases.
- HSPA+ provides data rates up to 56Mbits/s
- In North America and South Korea
- EVDO are Data specific releases.
- EVDO Rev B provides data rates up to 14.7Mbits/s
850, 900, 1900, 2100MHz
Failure of WAP for Internet access
Tied to mobile specific architectures and protocols.
4G mobile technologies
LTE Advanced: 3GPP Long Term Evolution
- Advanced: 3GPP Long Term Evolution I Downlink data rates up to 300Mbits/s and uplink data 75Mbit/s
- E-UTRA (Evolved UMTS Terrestrial Radio Access – High Speed OFDM Packet Access
- Similar frequency bands as 3G.
WLAN – WiFi
IEEE 802.11 Standards
First version is released in 1997.
Medium Access Control (MAC) and Physical layer
CSMA/CA – carrier sense multiple access with collision avoidance (recall: Ethernet use CSMA/CD)
Does not support global mobility
5G heterogenous networking supports seamless integration with WiFi hotsposts.
ISM (industrial, scientific and medical) frequencies
IEEE 802.11b, 802.11g, 802.11n
11/14 channels (overlapping)
Very crowded frequency band – may suffer interference from Bluetooth, microwave oven, etc.
IEEE 802.11a, 802.11n, 802.11ac
Range lower than 2.4GHz ⇡35m
23 channels (non overlapping)
WEP – not secure anymore!
WPA/WPA2 (WiFi Protected Access)
Use AES encryption – Enterprise networks – WPA2 along with RADIUS authentication server
IEEE 802.15.1 – now maintained by Bluetooth SIG3
ISM band 2.4GHz
Latest version – Bluetooth v4.1
Data rates up to 4Mbps.
- Bluetooth device in discoverable mode transmits the following info on demand:
Device name, Device class, List of services, Some Technical information (e.g: device features, manufacturer, Bluetooth specification)
- Traditional pairing:
Needs user interaction
If not, PINs are hardcoded in the device.
- Secure Simple Pairing (SSP)
Since Bluetooth v2.1
Works without user interaction.
Use other technologies such as NFC to bootstrap the authentication.
Established a shared secret key and if both device store the same key, they are paired after that.
Bluetooth networking basics
- Infrastructure-less network ->self-organized
- Time Division Multiple (TDM) access with random channel hopping 625μs timeslot.
- 40 channels with 37 data channels and 3 advertising channels.
Master – Salve approach
Up to 8 slave devices
Up to 255 parked devices (not actively transmit data)
Master transmits in even slots and receives in odd slots
Bluetooth state machine
Standby: Does not transmit or receive any packets.
Advertising: Transmitting advertising channel packets and listing to responses.
Scanning: Listing to advertising packets from others.
Initiating: Listing to advertising packets from a specific device.
Connection: Two roles are defined.
Master: When entering from Initiating state.
Slave: When entering from Advertising state.
Near Field Communication (NFC)
Range ⇡4cm of each other.
ISM band – 13.56MHz
Data rates ⇡106 to 424 kbits/s.
Multiple standardization organizations: ISO/IEC, GSMA, NFC Foruma
Passive NFC tags: credit/debit card, loyalty cards, etc.
- Use WiFi networking interface: Range and Data rates are similar to WiFi.
Activates Software AP within the device.
Specifications are administered by WiFi Alliance4
AirDrop by Apple
WiFi-Tethering (Mobile Hotspot)
Some network operators block WiFi-Tethering
Which interface ? Factors to consider
Location of the end hosts I Mobility
For the network operator
For the consumer
Real time or delay-tollerant
Privacy and Security
Public content or personal data
Location of the end hosts
Smartphone energy consumption
What we can do as app developers?
- Data offloading to alternative networks
- Reduce the amount of data
Select the appropriate content for the end device
- Reuse the data as much as possible
Cache content in the network and in the device
Store static content on the device
offload to another network, e.g. WiFi, when it is available.
Benefits of Wi-Fi offloading
Faster connections (depends on the location)
Lesser battery drain
Overall improved quality of user experience
Reduces cellular network capacity issues
Reactive Wi-Fi Offloading
- All most all current smartphones automatically prioritise WiFi networks over Cellular (3G/4G) networks
To automatically connect to WiFi, the available WiFi network has to be in the previously connected list of networks.
- If your application require
Frequent interactions with a web-server.
To transfer large amount of data.
It is better to scan the available WiFi networks and offer the user option to the switch to WiFi
Predictive WiFi Offloading
- Predict near future WiFi availability and delay the transmission.
- Predict future demand and effectively pre-load the content when the user is connected to WiFi.
- Only works for non-real time content (delay-tolerant content)
- Social networking content.
- Software updates.
- Environmental monitoring, data collection.
Can we really predict ?
time elasticity of majority of today’s Internet traffic
Predictable regular patterns of human behaviour
Users have regular weekly patterns e.g. 9:00am -5:00pm work hours.
It is possible to delay the transmission until the user get to a WiFi area
Long-tail content popularity1
It is possible to pre-load the popular content when the user is connected to WiFi
Device-to-device communication using short-range networks, e.g. Bluetooth, WiFi Direct, NFC
Reduce the amount of data
Select the appropriate content for the end device
Selecting the right content
Don’t hard-code to download Full HD video all the time.
The user expectation dependent on;
Users’ activity, e.g. running or sitting in the living room.
Time of the day.
End device resources, e.g. screen resolution
Type of the content, e.g. music video, news clip.
Images, video, voice are usually do not benefit from compression
Files less than 1KB do not benefit from compression.
- The compression and decompression have to be supported by the end-points.
Common algorithms – GZIP, DEFLATE
- Minification of JS, CSS and HTML
Remove unnecessary characters
Manually and automatically. e.g. eMinifier, Webmini
- Proper programming practices
e.g. short key IDs for a JSON structure
Reuse data as much as possible
- Design the app and the communication protocol to reuse data, if you control both the client and the server.
- For web-content, HTTP/1.1 provides number of flexible cache-control parameters.
- HTTPS content cannot be cached.
- HTTP Header cache-control directives:
- no-store – cannot cache the content
- no-cache – cannot use unless checking with the server
- public – can be cached
- private – can be cached for only one user
- max-age – maximum time in seconds that the cached content can be used
- Memory cache vs Disk cache
- Use the most suitable cache replacement policy for the app.
FIFO – First In First Out
LRU – Least Recently Used
LFU – Least Frequently Used
GreadyDual – Considers both recency and frequency
- Screen & CPU
Foreground vs Background
Activity vs Services
Sleep vs Active
Location (GPS vs Network)
Activity monitoring sensors – Accelerometer, Gyroscope, Magnetometer, etc. I Camera
- Input modalities
Type, Talk or Swype
- Network interface
Cellular > WiFi > Bluetooth in general
Communication protocol, e.g. HTTPS vs HTTP, content refresh rate
- Move the app to background, if the user interaction is not required.
Activity vs Services in Android
- Good programming practices
Reduce disk access frequency
Accuracy vs Energy trade-off
Network Location – Cell-ID, WiFi
By other applications
- Activity sensors – Accelerometer, Gyroscope, Magnetometer, etc.
Efficient activity recognition algorithms
Sensing frequency matters a lot.
- In general, LTE>3G>WiFi.
Dependent on the network conditions, e.g. available bandwidth, signal strength, interference, etc. • Good programming practices
Data bundling save wasted tail energy.
Reduce the frequency of communication.
Energy cost of HTTPS
- Energy cost of secure protocols is not negligible.
- Security is important in today’s mobile world.
It is worth the cost of energy
Always there is cost for everything
- Securing the device I Use standard authentication mechanisms.
- Securing the communication
Approximately 50% of toady’s Internet traffic is HTTPS (HTTP over TLS – Transport Layer Security).
- Higher page load time and higher amount of data.
- Caching at any level is not possible
Android OS Architecture
Android is built on top of the Linux kernel with additional architectural changes done by Google Inc. to suit the conditions of smart devices. The kernel provides a level of abstraction between the device hardware and the upper layers and contains the device drivers for hardware such as camera, or touchpad. Moreover, it provides basic operating system functionalities such as process management and memory management.
Native libraries are C/C++ libraries that contain instructions to the device on handling different types of data. For example, Webkit is responsible for browser support and media framework is responsible for audio and video related activities. Other examples of native libraries are SSL, SQLite, LIBS, and OpenGL ES. The core Java libraries in Android runtime environment (described later) act as wrappers to these native libraries and Android apps access the services of the native libraries through the wrappers.
Android Runtime Environment:
There are two components in the Android Run-Time Environment: Dalvik Virtual Machine (DVM) and Core Libraries.
The Dalvik Virtual Machine (DVM) is similar to a conventional Java Virtual Machine with some specific modifications related to Android. Each app instance will have its own DVM. The classes in the apps are compiled into a proprietary byte-code format of the DVM.
The core libraries enable app developers to develop Android apps using Java. There are two categories of core libraries: Java interoperability libraries and Android libraries.
Android apps interact with the entities in Android Framework and they manage the basic functions of the phone such as resource management and voice call management. For example, content providers manage data exchange between apps and the activity manager is responsible for life cycle management of the apps.
The apps are at the top most layer of the Android architecture. In addition to the default apps that come along with the Android distributions Android Operating System such as browser, dialler, SMS, and calculator, users can install third party apps such as Facebook, Pinterest, and Twitter from app markets.
Due to sandbox restrictions, apps must explicitly share resources and actions by declaring the required permissions for additional capabilities not provided by the basic sandbox such as sensitive APIs (E.g. location data, telephony functions, user accounts).
Intent is a messaging object to request an action from another app component.
To start an activity
- To start a service
- To deliver a broadcast
Explicit Intents: Communicate within the same application.
Need to specify the exact name of the component, e.g. class name.
Open another activity when the user click on the button.
Let the user to enter some text.
Return back to the original activity with the entered text and display the text.
Implicit Intents: Communicate between applications.
Requested by declaring the general action to perform, e.g. location.
Open Browser application.
- Things are happening all the time on an Android device.
- Many components need to know that some event has occurred.
- New package installation.
- Phone call received.
- WiFi is connected.
- Device is rebooted.
- Android uses a Broadcast Intents to tell everyone about it.
BroadcastReceivers register to receive events.
- Android routes the Broadcast Intents to BroadcastReceivers that have registered to receive them.
- Register for Broadcast Intents
- Statically: at AndroidManifest.xml
- Dynamically: by calling a registerReceiver() method
- Fragments are modular sections of an activity, like sub activity.
- Multiple Fragments can be embedded in an activity to create a multi-pane UI
- A single Fragment can be reused among multiple activities.
Fragment Lifecycle States
- Fragment lifecycle is coordinated with the lifecycle of its hosting activity.
- But, Fragments have their own lifecycles and their own callbacks.
- Fragment lifecycle methods are called by the hosting activity, not the OS.
Resumed: – Fragment is visible in the running activity.
Paused: – Another activity is in the foreground. The hosting activity is still visible.
Stopped: – The activity/fragment is not visible.
Provides access to a central repository of structured data.
Use to exchange data between applications.
API are provided to:
Retrieve, insert, update and delete data.
Access ContentProviders through a ContentResolver
Database style interface.
Android content providers:
Contacts, Media, Call Logs.
Android provides two main methods to obtain the location of a device.
- Previous method: Location API in android.location
There are two main location providers:
More work for developer
- Current method [Recommended by Google]2.
Provides a much higher level view for the developer.
Better accuracy and power management
Use the signals received from satellites for localisation.
Each location in the world is covered by at least four satellites.
User device receives the signal and measure the time lag to estimate the distance to each satellite.
There are two main constellations smartphones connect to: GPS or GLONASS & use the combined result.
Pros & Cons of GPS Location
- Accurate (In the level of 2-8m in worst case).
- Available anywhere around the globe (Almost !!).
- No data connection is required.
- Energy consumption.
- Longer time-to-fix.
Identifying the satellites
Synchronising the clocks.
Tries to address some of the problems in GPS.
Faster set-up time by getting satellite information through data connection.
- Use near by cell tower & WiFi access point information to query a geo tagged database.
- Energy Efficient.
- Needs a data connection.
- Who provide data to the geo DBs?
- Motion Sensors
- Gravity Sensors
- Environmental Sensors
- Ambient light
- Air pressure
- Position Sensors
- Body Sensors
Hardware vs. Software Sensors
- Hardware Sensors
- Physical components built into a handset
- g. Accelerometer, Gyroscope, Ambient light, Pressure
- Software Sensors
- Derive their data from one or more of the hardware-based sensors
- g. Step Counter, Orientation
- Each sensor is accessible through the Android Sensor Framework.
- Sensor availability is based on the actual handset and Android version.
- Acceleration is the second derivative of displacement.
- One method is to get the displacement signal and calculate the second derivative.
- Most common method is to measure something proportional to the force. (F = ma)
- There are various types of accelerometers. Smartphones usually comes with Tri-axial MEMS accelerometers.
Request the correct permission
- To do any kind of network activities should ask two permissions in the Manifest file
- Former allows to access the Internet and the latter is required to check whether there is an internet connection.
- An asynchronous task is defined by a computation that runs on a background thread and whose result is published on the UI thread4.
- To use the AsyncTask a subclass has to be created and at least doInBackground(Params…) method has to be overridden.
- Most of the time it is also require to override onPostExecute(Result) method as well.
- Other possible methods to override are onPreExecute and onProgressUpdate.
- Three parameters are associated with an AsyncTask.
- In the previous example we used AsyncTask<String,Void,String>
- Recall our input was a URL and our output was a XML string.
- And, we did not do any progress update.
Operation of HTTPS
- The most widely used protocol to achieve secure communications over the Internet is HTTPS (HTTP over TLS)
- There are four major phases in establishing a HTTPS connection.
- TCP handshake Starts with a usual TCP handshake
- TLS handshake
- Client sends it capabilities (TLS version / Cipher-suite / Compressions methods) & a random number (R1).
- The server has a certificate containing a public key and the corresponding private key.
- Server replies with a selected TLS version, cipher-suite, compression method & another random number (R2).
- Server also sends the certificate to the client.
- The client verifies the certificate (We will come to that later)
- Client generates a pre-master key and encrypts using the server’s public key and sends it to the server using Client Key Exchange message.
- Both server and client compute the master key which is a combination of the i) pre-master key ii) R1, and iii) R2.
- The client sends a Change Cipher Spec notification to the server indicating that all subsequent messages will be authenticated and encrypted using the master secret.
- Finally, the server sends a Change Cipher Spec back to the client, completing the handshake. After the TLS negotiation phase is over, the encrypted application data is transferred between the client and the server.
Validating the certificate
- A certificate is a simple text file containing some information such as Company Name, the domain name, and a public key.
- Anybody can create such file and create a server pretending to be somebody else.
- Answer is Certificate Authorities. Android comes with the set of CAs it trusts. Once you receive a certificate from a server & if it says it is issued by a trusted CA in the phones list Android can verify the certificate.
- Example CAs are Comodo, Symantex, DigiCert, and Entrust.
Performance monitoring by app developers
- Network and device specific content delivery.
- Low resolution device – low quality video
- High resolution device – high quality video
- Dynamic Adaptive Streaming over HTTP (DASH)
The video is encoded into several different versions, with each version having a different bit rate.
The client dynamically requests chunks of video segments of a few seconds in length from the different versions.
- Embed application performance data collection to apps.
- Received signal strength indicator (RSSI) – Unit is dBm.
- Practical range −5dBm to −120dBm.
- If the noise or interference is too high, signal strength will not give you a good indication
- Signal to Noise Ratio and its variations.
- SNR = Signal Power , SNR = 10 log Signal Power Noise Power dB 10 Noise Power
- SNRdB = Signal powerdB − Noise powerdB
- SINR – Signal to Interference plus noise ratio, RSRQ – Reference Signal Received Quality
- Bit Error Rate
- The probability that a transmitted bit is received in error at the receiver.
- BER = Bit erros /Transmitted bits
SNR vs BER
- BER is often used as a performance metric at the higher layers, e.g. computer scientists.
- SNR is often used as a performance metric at the lower layers, e.g. electrical engineers.
- Round Trip Time (RTT)
- RTT involves number of delays from the client to the server.
- g. Propagation delay, Buffering delay, Processing delay.
- Up and down two measures – Units are kbps, Mbps.
- Average throughput = Size of the file Time it takes to upload or download all bits
Video specific metrics
- Startup delay
- Time it takes to play the video since the user request.
- Statup delay = Playout buffer size (Q) / Throughput (x)
- Rebuffering time
- If x>r: Re-buffering will not occur.
- If x<r: Re-buffering will occur.
Discover Services in the Network
- Connect two phones to the same WiFi network.
- Install the two apps in two phones.
- One phone will keep sending mDNS service advertisements.
- Other phone will listen to the services that are being advertised.
What is mDNS
- Stands for multicast Domain Name System
- A Zero-Configuration Service
- Multicast DNS is used to resolve DNS Records in link-local networks without a central DNS Server
Android wear connectivity APIs
- Message API
- Designed for a request/response communication model
- The system queues the message for delivery and returns a successful result code
- – If the devices are not connected, an error is returned
- There is no end-to-end delivery guarantee
- Channel API
- To transfer large amount of data, e.g. movie.
- Reliable compared to MessageAPI
- Similar to a TCP connection – bi-directional.
- Data API
- To read and write data Items and assests.
- Synchronized across all devices in the Android Wear network
- Use assets for the transfer of larger, more persistent data objects such as images.