| Last Modified On : | April 29, 2008 2:47 AM PDT |
Rate |
|
This article shows how to provide applications with the ability to adapt to various network conditions. Use the Intel® Mobile Platform SDK to estimate and prioritize available bandwidth to your Windows* applications. Code samples included.
Estimating real-time network bandwidth accurately is a desirable feature for various applications in the wireless as well as wired world. End users typically enjoy having control over the available network bandwidth for their applications. The open source Intel® Mobile Platform Software Development Kit (SDK) 1.2 provides the needed functionality for estimating and prioritizing available bandwidth to adapt applications to varying network conditions. This article covers the APIs and their functionality and provides code samples that simulate and prioritize network bandwidth using Windows* sockets.
Typically, applications like to have an estimate of the available bandwidth in order to know how much content they can push to or pull from the Internet. While the information on the theoretical limits on upload and download rates can be found easily, real-time estimation is quite complex since it is dependent on the current network conditions. There may also be multiple sockets within the same application competing for the available bandwidth. In such cases, applications may also want to have a prioritization scheme to give higher priority to a particular socket over others.
The Intel Mobile Platform SDK offers a rich set of functionality for bandwidth estimation and prioritization. Such functionality and its use are demonstrated in the following examples:
Let's look at a demonstration application before jumping into the APIs needed to build this functionality into your own applications.
The Intel Mobile Platform SDK has a set of APIs for bandwidth estimation and control at multiple levels (application, system, process, and connection). A single application can not only control its own process and connection, but also other processes connections. APIs can be used to get the theoretical upload and download rates, current system upload and download rates, and set a limit on the upload and download rates on any given socket. There is also an adaptive option to change the bandwidth limiter accordingly. For example, if the link speed doubles, which can happen with WiFi, the previously set limit will be doubled automatically.
Demonstration
The included sample application demonstrates the bandwidth-related functionality using the Intel Mobile Platform SDK. The code was developed using C++ on a laptop system with Intel® Centrino® Mobile Technology and running the Windows* XP Professional operating system. The sample application simulates network traffic using Windows sockets between the client and a server node. The main functionality demonstrated in the demo includes real-time bandwidth estimation and bandwidth prioritization.
Figure 1: User Interface of Bandwidth Demo
The sample demonstration is run as follows:
The UploadRate or DownloadRate output provides the real-time upload and download rates estimated using the Intel Mobile Platform SDK. The results can be verified by noting the total time taken to upload and download the data size chosen in the Trial Data Size option.
The following steps demonstrate the Bandwidth Restriction functionality:
To get started, download and install the Intel Mobile Platform SDK. The distribution includes precompiled binaries, source code and API documentation.
All the capabilities for a given system are grouped into the ContextClass category in the Intel Mobile Platform SDK. For example, Connectivity/Bandwidth/Power falls into the ContextClass category. All bandwidth-related methods are invoked with the BandwidthInstance class. The following code shows an example of how to get the instance object for bandwidth and invoke some of the bandwidth related methods.
Creating an Instance Object for Bandwidth |
You'll probably do something exactly the same as this in your own application. Once you have the BandwidthInstance object you can start interrogating the instance about the current bandwidth. Here is some code that shows off some of the bandwidth estimation functionality:
In this code, we have set a factor that is used to calculate the transmit data by different measurement. You’ll see a few calls to the API too. For example, GetSessionLimitTx() returns the maximum kilobits per second the given socket can transmit over network devices, and getSessionRateTx() returns the measured transfer rate the connection has transmitted over network devices.
If you’re going to be restricting the bandwidth you’ll want to use the setSessionLimitXXX() set of methods. The SetSessionLimitedRx() method enables or disables enforcement of a connection limit for receiving data and SetSessionLimitedTx() enables or disables enforcement of a connection limit for sending data. Here’s some code that enforces the upload/download limits on sockets.
//active_socket is the socket descriptor |
As you can see, interrogating and limiting the bandwidth is really easy with the MPSDK. A question remains open though: how do you know when to limit and when to extend the bandwidth? Ideally, what you need is a way for your application to be notified when changes occur to the network connectivity. The MPSDK has just this functionality in the form of events. Essentially, you can register the application to listen in on network change events, and then take the appropriate action when they occur. The article, Intel® Mobile Platform SDK: Monitor Connectivity Status, demonstrates this functionality.
Click here to download the sample code for this article. The zip file contains Powbat.sln and readme,txt files. Please read readme.txt before you open the solution files.
Bandwidth estimation and prioritization are desirable features that can enhance the end-user experience. This article demonstrates how to use the Intel Mobile Platform SDK for bandwidth estimation prioritization. For more information on the Intel Mobile Platform SDK, visit http://ossmpsdk.intel.com/
Intel Mobile Platform SDK 1.2 Open Source Project
Karthik Krishnan is a software engineer with the Software Solutions Group at Intel. He holds a Masters degree in Mathematics from the Indian Institute of Technology. His current focus is on power and performance optimization of software applications on dual-core platforms.
Joe Zhao is a Software Technical Consulting Engineer working for Intel Corporation's Software and Solutions Group in Shanghai, China. He worked for nearly 2 years in Intel. He was the engineer in supporting Mobile Platform SDK, and now he is in charge of the maintenance of MPSDK Open Source project website. He got Master degree from the University of East Anglia in England.
