mobile phone programming · 2013-07-18 · developed by sun microsystems. symbian c++, a...

30
Mobile Phone Programming

Upload: others

Post on 10-Apr-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Mobile Phone Programming

and

Mobile Phone Programmingand its Application to Wireless Networking

Frank H.P. FitzekAalborg UniversityDenmark

Frank Reichert

NorwayAgder University College

Edited by

A C.I.P. Catalogue record for this book is available from the Library of Congress.

Published by Springer,

www.springer.com

Printed on acid-free paper

© 2007 Springer

No part of this work may be reproduced, stored in a retrieval system, or transmitted

in any form or by any means, electronic, mechanical, photocopying, microfilming, recording

or otherwise, without written permission from the Publisher, with the exception

of any material supplied specifically for the purpose of being entered

and executed on a computer system, for exclusive use by the purchaser of the work.

ISBN 978-1-4020-5968-1 (HB)

P.O. Box 17, 3300 AA Dordrecht, The Netherlands.

ISBN 978-1-4020-5969-8 (e-book)

To Sterica and Lilith.— Frank H.P. Fitzek

I dedicate this book to Tim (WoW Level 70, mighty UndeadWarrior), Max (Wow Level 70, fearless Tauren Hunter), andAida (Reality Level 80++, loving Human Wife and Mother)

— Frank Reichert (Level 64)

Foreword

Saila Laitinen

Nokia

The technology evolution has been once and for all beyond comparison duringthe past decade or two. Any of us can nowadays do numerous things withnumerous devices to help in everyday life. This applies not least to mobilephones. If we compare the feature set of a mobile phone model in 1995 withthe latest smartphone models the most visible difference is of course in theuser interface, the mp3 player, integrated camera, and the access to the mobileInternet.

This evolution is a result of multiple members in the entire mobile eco-system: (1) device manufacturers have managed to bring richer devices intomarkets, (2) operators have invested in network enablers heavily, (3) develop-ers have found mobile platforms fancy to innovate on, and last but not least(4) consumers have discovered the benefits of using the rich feature set ofmobile devices and they have welcomed them into their lives.

This book gives a thorough picture of all options a developer can choosefrom when developing mobile applications or other content. It explains Python;that is especially suitable for scripting, supports procedural programming, andobject-oriented programming. Java, an object-oriented programming languagedeveloped by Sun Microsystems. Symbian C++, a programming language tai-lored to mobile programming. Open C provides the familiar standard C func-tion libraries in mobile development. Qtopia’s greenphone is a Linux mobiledevelopment device open for innovation. Maemo Linux, an embedded Linuxdevelopment environment for mobile innovation. Windows Mobile, a com-pact operating system combined with a suite of basic applications for mobiledevices based on the Microsoft Win32 API.

In addition to the above, the book focuses on mobile application designfor wireless communication systems. Besides the well-known cellular architec-ture also the peer-to-peer and cooperative networking is introduced. Conceptssuch as cross-layer design and the convergence of wireless sensors with mobilephones are introduced and examples are given. Furthermore the energy con-sumption of mobile phones is addressed and designing rules to develop energy-efficient mobile applications are presented. I truly see that once the wireless

viii Foreword

internet really goes live all around the world; there are only winners in thisindustry.

I highly recommend reading this book, start the real mobile innovation sothat together we can make people all around the world connected with eachother without compromising in our mobility.

Helsinki, Finland Saila LaitinenApril 2007 Head of Regional Operations, Forum Nokia

Preface

The main source of motivation to write this book is the beauty of the mobilephones as an inspiring platform for research as well as teaching activities.

To prove an idea or a concept in the research domain, there are mainlythree possibilities, namely analytical evaluation, simulative evaluation, andimplementation on an appropriate platform. The problem with the analyticaland the simulative evaluation is that analytical derivations become more andmore complicated reducing the possible audience or that the chosen simula-tion environment is not fully transparent. Therefore we need to implementour proof of concept on omnipresent platforms to introduce it to a largeraudience. The mobile phones are omnipresent entities and are suitable asproof-of-concept platforms as they have two advantages over any other plat-form; first they are not that cost-intensive and second mostly everybody ownsone mobile phone by themselves or at least has had experience with it. As wewill show throughout this book, the degree of freedom to implement whateveridea in the world of wireless networking is nearly infinite and sometime onlyrestricted on purpose by the mobile phone manufacturer. Of course a mobilephone has some limitations in the memory capacity, the processing power,and the limited energy due to the battery-driven entity. But those limitationsshould not be understood as a disadvantage, but more as setting design rulesfor new solutions in the real world.

To use the mobile platform in student and master projects we startedto introduce mobile phone programming within our teaching activities. Thistopic is mostly new to students and they come with heterogeneous knowl-edge of programming languages. Different courses cover Python, JAVA, andSymbian/C++. Within the book we have extended the group of programminglanguages and deployment environments with topics such as Windows Mobile,Maemo, Qtopia, and Open C. In addition to the programming teaching, weencourage students to use their new knowledge within future research projectsand to make their own mobile applications.

The importance of mobile applications introducing new kinds of serviceshas been and is still underestimated. With the introduction of the second

x Preface

generation networks, new services were provided to the customers namelymobile speech services, roaming between different countries, low data rate IPconnection, and more advanced security. The introduction of the third gen-eration did not bring de facto revolutionary new services, which may explainwhy this generation of mobile communication systems is not having the samesuccess as its forerunner had when it was introduced. Thus services are thekey for successful communication networks.

We sincerely hope that this book is a contribution to enable a new waveof exciting mobile applications that enrich our lives, and that gives studentsa great start ramp to launch their future careers.

Planet Earth Frank H.P. FitzekApril 2007 Frank Reichert

Contents

ForewordSaila Laitinen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii

Part I Introduction

1 Introduction to Mobile Phone ProgrammingFrank H.P. Fitzek, Frank Reichert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.1 Evolution of the Mobile Phones, Networks, and Services . . . . . . . . . 3

1.1.1 Mobile Phone Family . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.1.2 The Flexible Mobile Phone . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

1.2 Wireless Technologies and Architectures . . . . . . . . . . . . . . . . . . . . . . . 91.2.1 Cellular Communication Systems . . . . . . . . . . . . . . . . . . . . . . . 91.2.2 Short-Range Communication Systems . . . . . . . . . . . . . . . . . . . 11

1.3 Mobile Application Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141.4 Structure of the Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

Part II Mobile Phone Programming Languages

2 Python for Symbian PhonesJurgen Scheible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232.2 Python for S60 Installation and Resources . . . . . . . . . . . . . . . . . . . . . 24

2.2.1 Software Installation on the Phone . . . . . . . . . . . . . . . . . . . . . 242.2.2 Software Installation on the PC (for S60 Platform Device

Emulator Use) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252.3 Writing a Python Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

2.3.1 How Python Runs Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . 262.3.2 Three Basic Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262.3.3 The First Script Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

xii Contents

2.4 A Short Python Syntax Lesson . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282.5 Overview of Python for S60 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . 282.6 Modules – and How to Program Python for S60 Scripts . . . . . . . . . . 29

2.6.1 Messaging Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292.6.2 Appuifw Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312.6.3 Application Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362.6.4 Audio Module: Sound Recording and Playing . . . . . . . . . . . . 372.6.5 Variable Scope: Local, Global . . . . . . . . . . . . . . . . . . . . . . . . . . 392.6.6 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402.6.7 Inbox Module: Reading Incoming SMS . . . . . . . . . . . . . . . . . . 402.6.8 Graphics Module and the Use of Keyboard Keys . . . . . . . . . 412.6.9 Image Composition Application: MobileArtBlog . . . . . . . . . . 432.6.10 3D Graphics: gles and glcanvas Modules . . . . . . . . . . . . . . . . 442.6.11 Camera Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452.6.12 Video Download and Playing – the Use of Content Handler 462.6.13 File Upload to a URL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472.6.14 Mobile Photo Blogging Application . . . . . . . . . . . . . . . . . . . . . 482.6.15 File Handling and Data Storing . . . . . . . . . . . . . . . . . . . . . . . . 482.6.16 Socket Module: Bluetooth, TCP/IP, and SSL . . . . . . . . . . . . 492.6.17 sysinfo Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552.6.18 Location Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552.6.19 Telephone Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572.6.20 Contact Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

2.7 Creating Stand-Alone Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582.8 Symbian Platform Security and Python for S60 . . . . . . . . . . . . . . . . . 592.9 Creating Python Extensions in C++ . . . . . . . . . . . . . . . . . . . . . . . . . . 602.10 Further Reading Sources on Python for S60 . . . . . . . . . . . . . . . . . . . . 602.11 Code Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602.12 Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

3 Java 2 Micro EditionGian Paolo Perrucci, Andreas Haber . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633.1 Java Family Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633.2 J2ME Platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

3.2.1 Less Capable Devices: Targeting CLDC . . . . . . . . . . . . . . . . . 663.2.2 More Capable Devices: Targeting CDC . . . . . . . . . . . . . . . . . 673.2.3 Networking Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683.2.4 Optional Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703.2.5 Java Technology Standardization . . . . . . . . . . . . . . . . . . . . . . . 71

3.3 Development Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743.3.1 Java Development Kit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743.3.2 NetBeans IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 753.3.3 Developing MIDP Applications for CLDC . . . . . . . . . . . . . . . 773.3.4 Developing CDC Applications . . . . . . . . . . . . . . . . . . . . . . . . . 82

Contents xiii

3.4 Application Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 863.4.1 Wireless Messaging API: Sending SMS . . . . . . . . . . . . . . . . . . 873.4.2 Mobile Multimedia API: Audio Player . . . . . . . . . . . . . . . . . . 883.4.3 Communication: Downloading Documents with GCF . . . . . 903.4.4 XML Parsing: Parsing RSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

4 Symbian/C++Morten V. Pedersen, Frank H.P. Fitzek . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 954.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 954.2 Setting up the Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

4.2.1 Additional Installation Requirements . . . . . . . . . . . . . . . . . . . 974.2.2 Overview of the SDK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 974.2.3 Overview of the Carbide.c++ Express IDE 1.1 . . . . . . . . . . . 994.2.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

4.3 Symbian OS in a Nutshell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1084.3.1 Naming Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1094.3.2 Exception Handling and Resource Management . . . . . . . . . . 1124.3.3 Descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1174.3.4 Active Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1244.3.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130

4.4 Wireless Communication Technologies . . . . . . . . . . . . . . . . . . . . . . . . . 1314.4.1 Using TCP/IP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1314.4.2 Bluetooth OBEX, SMS, and Email . . . . . . . . . . . . . . . . . . . . . 135

4.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138

5 Open CEero Penttinen, Antti Saukko . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1395.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1395.2 What is Open C? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1405.3 Setting up the Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1425.4 Getting Started with Open C: Hello World . . . . . . . . . . . . . . . . . . . . . 1445.5 Open C and Symbian/S60 Interaction . . . . . . . . . . . . . . . . . . . . . . . . . 146

5.5.1 Open C DLLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1465.5.2 String/Descriptor Conversions . . . . . . . . . . . . . . . . . . . . . . . . . 1495.5.3 GLib . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

5.6 Guidance for Porting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1575.6.1 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1575.6.2 Configuring and Making the Source on Linux . . . . . . . . . . . . 1575.6.3 Modifying Configuration Files in the S60 Development

Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1575.6.4 Modifying the Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158

xiv Contents

6 Qtopia GreenphoneThomas Arildsen, Morten L. Jørgensen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1596.1 The Greenphone and Qtopia . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1596.2 Setting up the Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1616.3 FTP File Transfer Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1666.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174

7 Maemo LinuxMatti Sillanpaa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1757.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1757.2 Scratchbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176

7.2.1 Under the Hood . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1777.2.2 Getting Started with Scratchbox . . . . . . . . . . . . . . . . . . . . . . . 1807.2.3 Your First Cross-Developed Program . . . . . . . . . . . . . . . . . . . 182

7.3 The Nokia 770 Internet Tablet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1867.3.1 Maemo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1877.3.2 Installing Maemo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1897.3.3 Setting up the X Windowing Environment . . . . . . . . . . . . . . 194

7.4 Using Eclipse with Scratchbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1957.4.1 Setting up Eclipse with Scratchbox Support . . . . . . . . . . . . . 1967.4.2 Creating a Scratchbox Project . . . . . . . . . . . . . . . . . . . . . . . . . 1997.4.3 Debugging Inside Scratchbox . . . . . . . . . . . . . . . . . . . . . . . . . . 202

7.5 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204

8 Windows Mobile ProgrammingRico Wind, Christian S. Jensen, Kristian Torp . . . . . . . . . . . . . . . . . . . . . . 2078.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2078.2 .Net and C# in a Nutshell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2088.3 .Net Compact Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212

8.3.1 Using the Windows Mobile Emulator . . . . . . . . . . . . . . . . . . . 2138.3.2 Installing Programs on Mobile Devices . . . . . . . . . . . . . . . . . . 214

8.4 Using the Windows Mobile Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . 2158.4.1 Controls in the System.Windows.Forms Namespace . . . . . . . 2158.4.2 Controls Specific to Windows Mobile . . . . . . . . . . . . . . . . . . . 218

8.5 Network Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2248.5.1 Network Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225

8.6 Visual Studio IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2288.6.1 An Overview of Visual Studio . . . . . . . . . . . . . . . . . . . . . . . . . 2288.6.2 Using Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2308.6.3 Using Databases with ADO.Net . . . . . . . . . . . . . . . . . . . . . . . . 230

References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234

Contents xv

Part III Infrastructure-Based Communication

9 Service DiscoveryAndreas Haber . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2399.1 Service Discovery in Real Life . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239

9.1.1 Active and Passive Service Discovery . . . . . . . . . . . . . . . . . . . 2409.2 Service Discovery in Computer Networks . . . . . . . . . . . . . . . . . . . . . . . 240

9.2.1 Where to Send a Packet to? . . . . . . . . . . . . . . . . . . . . . . . . . . . 2409.2.2 Address Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2429.2.3 Basic Service Discovery in Computer Networks . . . . . . . . . . . 242

9.3 Universal Plug & Play . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2439.3.1 UPnP Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2439.3.2 UPnP Device Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2459.3.3 Libraries for UPnP Development . . . . . . . . . . . . . . . . . . . . . . . 254

References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254

Part IV Peer-to-Peer Communication

10 Digital Ownership for P2P NetworksMichael Stini, and Martin Mauve, Frank H.P. Fitzek . . . . . . . . . . . . . . . . . 25910.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25910.2 Digital Content and Its Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26010.3 Basic Elements of Digital Ownership . . . . . . . . . . . . . . . . . . . . . . . . . . 26210.4 Digital Ownership Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26310.5 Digital Ownership Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26510.6 First Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26610.7 An Example for DRM Usage: iTunes . . . . . . . . . . . . . . . . . . . . . . . . . . 26810.8 Conclusions and Outlook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270

11 SMARTEX: The SmartME ApplicationMorten V. Pedersen, Frank H.P. Fitzek . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27111.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27111.2 The Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27311.3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274

12 The Walkie Talkie ApplicationMorten V. Pedersen, Frank H.P. Fitzek . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27512.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27512.2 The Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276

12.2.1 UI Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27612.2.2 The Control/Push-To-Talk Protocol Layer . . . . . . . . . . . . . . 27712.2.3 Bluetooth and Audio Modules . . . . . . . . . . . . . . . . . . . . . . . . . 277

12.3 Bluetooth-IP Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278

xvi Contents

12.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279

Part V Cooperative Communication

13 Cooperative Wireless Networking: An IntroductoryOverview

Marcos D. Katz, Frank H.P. Fitzek . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28313.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28313.2 Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285

13.2.1 Increasing Demand of Energy/Power . . . . . . . . . . . . . . . . . . . 28613.2.2 Spectrum Scarcity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28713.2.3 Complexity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28813.2.4 Appealing Services and Applications . . . . . . . . . . . . . . . . . . . . 28813.2.5 Demanding Communicational Capabilities . . . . . . . . . . . . . . . 288

13.3 Cooperative Principles in Wireless Networks: An Introduction . . . . 28913.3.1 Communicational Cooperation . . . . . . . . . . . . . . . . . . . . . . . . . 28913.3.2 Operational Cooperation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29213.3.3 Social Cooperation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292

13.4 Cooperation in Heterogeneous Networks:The Emergence of a Novel Paradigm . . . . . . . . . . . . . . . . . . . . . . . . . . 293

13.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296

14 The Medium is the MessageAnders Grauballe, Ulrik Wilken Rasmussen, Mikkel Gade Jensen,Frank H.P. Fitzek . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29914.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29914.2 Identification of the Needed Functionality . . . . . . . . . . . . . . . . . . . . . . 301

14.2.1 Functionality Available in Python . . . . . . . . . . . . . . . . . . . . . . 30114.2.2 Adding Functionality to Python . . . . . . . . . . . . . . . . . . . . . . . . 301

14.3 Realization of the Idea with Python . . . . . . . . . . . . . . . . . . . . . . . . . . . 30514.4 Measurement Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30714.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310

15 Peer-to-Peer File Sharing for Mobile DevicesImre Kelenyi, Gergely Csucs, Bertalan Forstner, Hassan Charaf . . . . . . . 31115.1 Peer-to-Peer File Sharing in General . . . . . . . . . . . . . . . . . . . . . . . . . . 311

15.1.1 Gnutella . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31315.1.2 BitTorrent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315

15.2 Thoughts on the Mobile Implementation . . . . . . . . . . . . . . . . . . . . . . . 31615.2.1 Separating the User Interface from the Application

Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316

Contents xvii

15.2.2 Accessing the Mobile Nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . 31715.3 Symella . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31915.4 SymTorrent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320

15.4.1 The Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32115.4.2 Using the Class Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32215.4.3 The Tracker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323

15.5 Summary and Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324

16 Energy Saving Aspects and Servicesfor Cooperative Wireless NetworksLeonardo Militano, Gergely Csucs, Frank H.P. Fitzek . . . . . . . . . . . . . . . . . 32516.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32516.2 Test-bed Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32516.3 Description of the Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32716.4 Measurement Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33616.5 The BitTorrent Experiment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33616.6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339

Part VI Cross-Layer Communication

17 Cross-Layer Protocol Design for Wireless CommunicationThomas Arildsen, Frank H.P. Fitzek . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34317.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34317.2 Cross-Layer Protocol Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346

17.2.1 The Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34617.2.2 Communication Across Protocol Layers . . . . . . . . . . . . . . . . . 34817.2.3 State of the Art . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353

17.3 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360

18 Cross-Layer Example for Multimedia Servicesover BluetoothMorten V. Pedersen, Gian Paolo Perrucci, Thomas Arildsen, TatianaKozlova Madsen, Frank H.P. Fitzek . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36318.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36318.2 Adaptive Header Compression for Bluetooth . . . . . . . . . . . . . . . . . . . 36418.3 Groundwork for Cross-Layer Design . . . . . . . . . . . . . . . . . . . . . . . . . . . 365

18.3.1 Symbian Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36618.3.2 Packet Selection Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36918.3.3 Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369

18.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371

xviii Contents

Part VII Sensor Networks

19 Convergence of Mobile Devices and Wireless SensorNetworksFrank H.P. Fitzek, Stephan Rein . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37519.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37519.2 Classification of Different Convergence Forms . . . . . . . . . . . . . . . . . . . 37619.3 First Demonstrator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380

20 Using In-built RFID/NFC, Cameras, and 3DAccelerometers as Mobile Phone SensorsPaul Coulton, Will Bamford, Fadi Chehimi, Paul Gilberstson, OmerRashid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38120.1 Using RFID/NFC on Mobile Phones . . . . . . . . . . . . . . . . . . . . . . . . . . 381

20.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38120.1.2 Overview of JSR-257 (Contactless Communication) . . . . . . . 38220.1.3 Programming with Nokia NFC and RFID SDK . . . . . . . . . . 38520.1.4 Using Nokia NFC and RFID API . . . . . . . . . . . . . . . . . . . . . . 385

20.2 Using Cameras on Mobile Phones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38620.2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38620.2.2 Programming the Camera in J2ME . . . . . . . . . . . . . . . . . . . . . 38620.2.3 Programming the Camera in S60 . . . . . . . . . . . . . . . . . . . . . . . 389

20.3 Motion Interfaces using 3D Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . 39320.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39320.3.2 Programming 3D Motion Sensors in Symbian . . . . . . . . . . . . 394

20.4 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396

21 Sensor Networks for Distributed ComputingStephan Rein, Clemens Guhmann, Frank H.P. Fitzek . . . . . . . . . . . . . . . . . 39721.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39721.2 Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399

21.2.1 Processor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40021.2.2 Transceiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401

21.3 Software Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40321.3.1 Medium Access Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40321.3.2 Research in Signal Processing: the Problem . . . . . . . . . . . . . . 40521.3.3 The Stack: An Embedded Calculator . . . . . . . . . . . . . . . . . . . 406

21.4 Distributed Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40621.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409

Contents xix

22 Parking Assistant ApplicationJanne Dahl Rasmussen, Peter Østergaard, Jeppe Jensen, AndersGrauballe, Gian Paolo Perrucci, Ben Krøyer, Frank H.P. Fitzek . . . . . . . 41122.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41122.2 Mounting the Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41122.3 JAVA Realization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412

22.3.1 Install Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41222.3.2 Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41322.3.3 Exit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414

22.4 Python Realization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41422.5 Outlook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417

Part VIII Power Consumption in Mobile Devices

23 Energy Efficiency of Video Decoder ImplementationsOlli Silven, Tero Rintaluoma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42123.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42123.2 Mobile Video Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42423.3 Mobile Video Codec Implementations/Platforms . . . . . . . . . . . . . . . . 426

23.3.1 Software-based Decoders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42623.3.2 Hardware-based Decoders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429

23.4 Software Interfacing Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43223.4.1 Operating System Costs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43223.4.2 The Cost of a Multimedia Software Framework . . . . . . . . . . 43323.4.3 Internal Interface Overheads . . . . . . . . . . . . . . . . . . . . . . . . . . . 435

23.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43623.6 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437

24 External Energy Consumption Measurements on MobilePhonesFrank H.P. Fitzek . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44124.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44124.2 Measurement Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44324.3 Example of Energy Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447

25 Optimizing Mobile Software with Built-in Power ProfilingGerard Bosch Creus, Mika Kuulusa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44925.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44925.2 S60 Power Profiling Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45125.3 Carbide.c++ Power-Performance Profiling . . . . . . . . . . . . . . . . . . . . . 45625.4 Energy-Efficient Design Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45825.5 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471

List of Contributors

Anders GrauballeAalborg UniversityDepartment of Electronic SystemsNiels Jernes Vej 12DK-9220 Aalborg, [email protected]

Andreas HaberAgder University CollegeFaculty of Engineering and ScienceGrooseveien 36Servicebox 509N-4898 [email protected]

Antti SaukkoNokiaItamerenkatu 11–13FIN-00180 [email protected]

Bertalan ForstnerBudapest University of Technologyand EconomicsH-1111 Budapest, Goldmann Gyorgyter 3. [email protected]

Ben KrøyerAalborg UniversityDepartment of Electronic SystemsNiels Jernes Vej 12DK-9220 Aalborg, [email protected]

Christian S. JensenAalborg UniversityDepartment of Computer ScienceFredrik Bajers Vej 7EDK-9220 Aalborg Ø[email protected]

Clemens GuhmannTechnische Universitat BerlinEinsteinufer 1710587 Berlin, [email protected]

Eero PenttinenNokiaItamerenkatu 11–13FIN-00180 [email protected]

Fadi ChehimiInformaticsInfolab21Lancaster UniversityLancaster, LA1 4WA, [email protected]

xxii List of Contributors

Frank H.P. FitzekAalborg UniversityDepartment of Electronic SystemsNiels Jernes Vej 12DK-9220 Aalborg, [email protected]

Frank ReichertAgder University CollegeFaculty of Engineering and ScienceGrooseveien 36Servicebox 509N-4898 Grimstad, [email protected]

Gerard Bosch i CreusNokia Research CenterItamerenkatu 11–13FIN-00180 [email protected]

Gergely CsucsBudapest University of Technologyand EconomicsH-1111 Budapest, Goldmann Gyorgyter 3. [email protected]

Gian Paolo PerrucciAalborg UniversityDepartment of Electronic SystemsNiels Jernes Vej 12DK-9220 Aalborg, [email protected]

Hassan CharafBudapest University of Technologyand EconomicsH-1111 Budapest, Goldmann Gyorgyter 3. [email protected]

Imre KelenyiBudapest University of Technologyand EconomicsH-1111 Budapest, Goldmann Gyorgyter 3. [email protected]

Janne Dahl RasmussenAalborg UniversityDepartment of Electronic SystemsNiels Jernes Vej 12DK-9220 Aalborg, [email protected]

Jeppe JensenAalborg UniversityDepartment of Electronic SystemsNiels Jernes Vej 12DK-9220 Aalborg, [email protected]

Jurgen ScheibleUniversity of Art and DesignHelsinki Media LabHameentie 135CFI-00560 Helsinki, [email protected]

Kristian TorpAalborg UniversityDepartment of Computer ScienceFredrik Bajers Vej 7EDK-9220 Aalborg Ø[email protected]

Leonardo MilitanoUniversity Mediterranea of ReggioCalabriaFaculty of Engineering, DepartmentDIMETVia Graziella, Loc. Feo di Vito89100 Reggio Calabria, [email protected]

Marcos KatzVTTKaitovayla 1, OuluP.O.Box 1100FI-90571 OuluFINLAND

List of Contributors xxiii

Martin MauveHeinrich-Heine-UniversityUniversitatsstr. 1D-40225 Dusseldorf, [email protected]

Matti SillanpaaNokia Research CenterItamerenkatu 11–13FIN-00180 [email protected]

Michael StiniHeinrich-Heine-UniversityUniversitatsstr. 1D-40225 Dusseldorf, [email protected]

Mika KuulusaNokia Technology PlatformsItamerenkatu 11–13FIN-00180 [email protected]

Mikkel Gade JensenAalborg UniversityDepartment of Electronic SystemsNiels Jernes Vej 12DK-9220 Aalborg, [email protected]

Morten L. JørgensenAalborg UniversityDepartment of Electronic SystemsNiels Jernes Vej 12DK-9220 Aalborg, [email protected]

Morten V. PedersenAalborg UniversityDepartment of Electronic SystemsNiels Jernes Vej 12DK-9220 Aalborg, [email protected]

Olli SilvenDepartment of Electricaland Information EngineeringP.O.B. 4500FI-90014 University of Oulu, [email protected]

Omer RashidInformaticsInfolab21Lancaster UniversityLancaster, LA1 4WA, [email protected]

Paul CoultonInformaticsInfolab21Lancaster UniversityLancaster, LA1 4WA, [email protected]

Paul GilbertsonInformaticsInfolab21Lancaster UniversityLancaster, LA1 4WA, [email protected]

Peter ØstergaardAalborg UniversityDepartment of Electronic SystemsNiels Jernes Vej 12DK-9220 Aalborg, [email protected]

Rico WindAalborg UniversityDepartment of Computer ScienceFredrik Bajers Vej 7EDK-9220 Aalborg Ø[email protected]

Stephan ReinTechnische Universitat BerlinEinsteinufer 1710587 Berlin, [email protected]

xxiv List of Contributors

Tatiana Kozlova MadsenAalborg UniversityDepartment of Electronic SystemsNiels Jernes Vej 12DK-9220 Aalborg, [email protected]

Tero RintaluomaHantro Products OyKiviharjunlenkki 1FI-90220 Oulu, [email protected]

Thomas ArildsenAalborg UniversityDepartment of Electronic SystemsNiels Jernes Vej 12

DK-9220 Aalborg, [email protected]

Ulrik W. RasmussenAalborg UniversityDepartment of Electronic SystemsNiels Jernes Vej 12DK-9220 Aalborg, [email protected]

Will BamfordInformaticsInfolab21Lancaster UniversityLancaster, LA1 4WA, [email protected]

Part I

Introduction

1

Introduction to Mobile Phone Programming

Frank H.P. Fitzek1 and Frank Reichert2

1 Aalborg University [email protected] Agder University College [email protected]

1.1 Evolution of the Mobile Phones, Networks,and Services

1.1.1 Mobile Phone Family

Mobile phones got their name from their very first application, allowing peo-ple to make phone calls while being mobile. The communication architecturewas dominated by base stations communicating with the mobile phones. Basestations were needed to enter the existing telephone networks and therebyallowing to communicate with fixed line communication partners. Further-more, the base stations and the connected backbone allowed to communicatewith other mobile users in different cells. In the beginning, referred to asfirst generation (1G) of mobile networks, there was no need for additionalfunctionality, besides voice services, on top of the mobile phones. With thesecond generation (2G) , changing from analog mobile systems to digital ones,enhanced services were introduced such as the short message service (SMS)and data connections to the Internet. But another important change tookplace: the split of network and service providers such that we have four majorplayers in the mobile world as given in Figure 1.1. Before that, the networkprovider had the monopoly to decide which services (in this case it was onlythe voice service) are available on the phones. Most of the European networkproviders were still fighting their monopoly, while in Japan DoCoMo launchedtheir i-mode service. The idea was to maintain a platform where third-partyservice providers could offer their services to the mobile phone customersusing the DoCoMo network. The business case was based on a fixed-ratiosplit between the service and the network provider. In contrast to the WAPservices in Europe, which was a big financial disaster, the i-mode took off andwas very successful. From that time on the mobile market has been dividedinto four different players, namely the customer as the main target of thebusiness, the network providers enabling to convey bits toward the customer,the service provider, and the mobile phone manufacturer. These four entities

3

F.H.P. Fitzek and F. Reichert (eds.), Mobile Phone Programming and its Application toWireless Networking, 3–20.c© 2007 Springer.

4 F.H.P. Fitzek and F. Reichert

Figure 1.1. Interdependencies between the mobile phone customer, the networkprovider, the service provider, and the mobile phone manufacturer.

have some interdependencies. The most dominating one is the relationshipbetween network providers and mobile phone manufacturers. To attract cus-tomers, the network providers bundle their contracts with a mobile phone,both being renewed within a given period. This ensures the mobile phonemanufacturers sell a huge number of mobile phones. On the other side, thenetwork operators also pull strings as to which services and applications areavailable on the mobile phone. Furthermore the network operator also controlswhich services are going over their network and makes the service providerdependent on the network operators’ decision. This relationship should betaken into account making novel applications for mobile phones.

But the dominating position of the network provider is getting weaker asthe monopoly of the cellular communication link is destroyed by wireless tech-nologies such as wireless local area network (WLAN) and Bluetooth. Thesetypes of communication enable the creation of new type of services withouttight coupling with the network operator. Mobile phone manufacturers areforced by the operators to keep this new freedom under control. Third-partydevelopers seem to have a lot of freedom in the programming. But sometimeswhen it comes to the sensitive parts of the network operator, the mobile phoneis not that flexible anymore. As given in one of the following chapters, voice-over IP (VoIP) just between two mobile phones can only be enabled withhalf-duplex. Another example for a possible restriction is the strict couplingof the IP protocol with the GPRS module. IP over Bluetooth or WLAN iseither not supported or very difficult to use in some mobile phones. But theserestrictions should not stop us from making interesting services, they cost onlytime.

The third generation (3G) of mobile networks did not bring radical changesin respect to the 2G system. Nevertheless, there is one important lessonlearned so far with the new generation, i.e, that pure technology is not selling,

1 Introduction to Mobile Phone Programming 5

but customers will ask for services. The main changes from 2G to 3G withinprotocol layers were that they were hardly visible for the customer and there-fore 3G is not a selling keyword itself. Actually most of the network providersdo not advertise their 3G network anymore as they did before and claim itis an evolutionary step such as it was with GPRS and EDGE. The search ofnew services was dominated by the term killer application. Many panels andconferences were dominated by the question what is the next application thatwill significantly change the wireless community. But the answer is not easy tofind. DoCoMo tried to identify good services to start their i-mode service backin the 1990s by making public-opinion polls before the launch of i-mode. Com-paring the wish list of the customers before with the actual use statistics afterthe launch of i-mode showed that there was absolutely no correlation. Thuseven the customers do not know what they really want to have in advance.It is very difficult to design new applications and predict their success on themarket beforehand. Many applications were generated over the past decadesand only some of them were successful. To give the reader some designing rulesfor successful services, we distinguish between two sorts of services, namelythe personal and the community services as given in Figure 1.2.

Personal services encompass all services, which are used by the customer onthe phone with limited or no interaction with other customers. The communityservices are different in the interaction with other customers. These servicesare those made to interact with other people. Both, the personal and thecommunity services, are separated into services with and without wirelessnetwork support. The wireless network support is realized by standard GSMconnection, GPRS, EDGE, 3G data connections, Bluetooth, or WLAN. Theservices are colored in orange, for those existing on most phones already, inblue, for those that can be installed on the mobile phones, and in green, forthose advocated in this book to rule the future of mobile phone services.

The personal services without network support include services such ascalendars, cameras, downloading facilities to change the logo on the phone,and single-player games such as Tetris, pong, snake, etc. The logo servicesgave the network and service providers big revenues as they enabled people tocustomize their mobile phones. As customizing services were requested moreand more by the customers, the next step was to introduce ring tones. As thisservice is not only noticed by the user, but by all people in the vicinity ofthe mobile phones, it is part of the community services. Ring tones are theultimate way to customize the mobile phone and we refer to this as a wayto increase the coolness factor. So the lesson learned within this paragraphis to enable users to express their way of life by customizing mobile phones.Personal services with network support include Web services and downloadingtools (such as BitTorrent).

The most promising services are the community services with wireless net-work support. This relies on the fact that human beings are always interestedin the lives of others. To proof this statement, the most successful servicessuch as voice service and SMS services are within this group. But even new

6 F.H.P. Fitzek and F. Reichert

Figure 1.2. Classification of services into service and community services.

services, such as video services, friend finders, and multiplayer games will findtheir way to the market. Multiplayer games have already proven their poten-tial for the wired networks, but even for the wireless world multi player gamesare the future making a big portion of the revenue in the near future. Thus,the lesson learned in this section is that successful services should interconnectpeople. A fact that is addressed by Nokia’s sentence Connecting people! forthe speech services, but it may be true also for the next generation of mobileservices.

Paying attention to the two lessons learned in the last two sections, twonew service classes, namely the peer to peer services and the cooperative ser-vices are introduced. These two services form the future of the upcomingfourth generation (4G) of mobile communication systems. But the focus isnot restricted only to those services and we introduce sensor services, whichare realized by mobile phones working with sensors in the vicinity of themobile phone which may be introduced within the 4G or 5G systems.

1.1.2 The Flexible Mobile Phone

The mobile phone platform has become more and more flexible for third-party developers. The first programming language on the mobile phone wasJAVA and now there are several ways to implement an application on thephone.As given in Figure 1.3 the applications run in the application suite.The user interface framework host all functionality that let us operate themobile device. Qtopia is one example of that. The mobile phone manufacturer

1 Introduction to Mobile Phone Programming 7

Figure 1.3. General architecture of the programmable mobile phone.

offers access to their platforms (with some restriction) using their kernel andhardware drivers such as the Symbian OS to access the hardware platform. Sonearly anything that is in software can be changed on the mobile. The onlystatic part of the phone is the hardware platform. Here and there some APIscan be found to change some parameters for a given wireless technology, butwe are far from a composable or software-defined radio.

Beside the programming capabilities of the mobile phone, there is evenmore flexibility on the phone. As given in Figure 1.4 a mobile device hasmany different capabilities and functionalities. We have grouped those of amobile (smart) phone into three classes, namely user interfaces, communi-cation interfaces, and built-in resources. The user interfaces comprise typi-cally the speaker, microphone, camera, display, built-in sensors, and keyboardcapabilities. The built-in terminal resources include the battery, the centralprocessing unit, and the data storage. From our point of view we highlightparticularly the communication interfaces, which typically include cellular andshort–range capabilities.

Instead of having one mobile device hosting all functionalities with thebest possible quality, the concept presented later in our book considers usingand sharing cleverly the capabilities of several, in principle different, mobiledevices. Indeed, in such a heterogeneous scenario each terminal could fea-ture a particular specialization, from a simple mobile phone for voice calls toadvanced terminals with music and imaging devices. In the proposed wire-lessly scalable architecture, a wireless grid of terminals is formed where theconnecting links among cooperating terminals are implemented by the short-range air interfaces. In general terms, such a scalable concept is not totallynew as Bill Joy, the visionary figure behind Jini Technology and cofunder of

8 F.H.P. Fitzek and F. Reichert

Figure 1.4. A mobile device broken up into the several capabilities grouped intothe user interface, communication interface, and the built-in resources.

Sun Microsystems argued already in 1999 for cooperative software:

A cell phone has a microphone. It has a numeric keypad. It has a display.It has a transmitter and receiver. That is what it is. It has a battery witha certain lifetime. It has a processor and some memory. If it is a Europeanmodel it has a stored value card. It is a collection of things. It is some collec-tion. The fact that it is all one bundle, well, that is pretty artificial – Bill Joy

Inspired by this developers may start to see the mobile phone as a collec-tion of capabilities that can be reassembled on demand for a given purpose.Throughout the book we will give some examples for that.

But the flexibility of the mobile device is not limited to the combiningof hardware components. Even the software can be used in a flexible way.One of the first ideas, which we will present in Part VI, is cross-layer design.Cross-layer protocol design is the idea of changing layers according to needs.Examples are given within this book. Some protocol layers may be even leftout totally or grouped in a new way. The final step brings also flexibility tothe lower levels of the protocol stack. While flexibility on commercial mobiledevices is limited to multi-modality approaches, the future will be dominatedby software-defined radio approaches. While multi-modality is only choosingamong different available wireless technologies such as Bluetooth or WLAN,the software-defined radio can dynamically adjust the radio part toward theneeded functionality. At the extreme, it could also change from short-rangecommunication to cellular communication, exchanging the full protocol stack.

1 Introduction to Mobile Phone Programming 9

1.2 Wireless Technologies and Architectures

As advocated in the previous section the wireless network capabilities inmobile phones are the main enablers to invent new appealing applications. Inthis chapter different wireless technologies available on most mobile phonesand underlying communication architectures are introduced. The technolo-gies differ in the supported data rates, the communication protocols used, thecommunication coverage, and the energy consumption related to it. In generalwe distinguish between short-range and cellular communication systems. His-torically the most important communication form is the cellular one. The 1Gswere equipped only with this technology as the main service was voice drivenand a connection to the telephone operator network was the only neededwireless extension. Later on with the first GSM mobile phones short-rangecommunication was introduced by infrared (IRDA). Later on further tech-nologies such as Bluetooth and WLAN were also introduced into the device.Future short-range technologies are the ultra wide band and further evolutionof the IEEE WLAN technology. In the following we revise shortly some ofthe communication technologies without claiming completeness. It is more ashort revision focusing on the items we need in the later discussion of ourprogramming parts.

1.2.1 Cellular Communication Systems

In the beginning the main service on mobile phones was voice. The first log-ical move was to enable connections of mobile users with users connected tofixed terminals or to use the core network to extend virtually a connectionbetween two mobile users. As wireless radio communication is prone to pathloss, a direct communication of mobile users would only be possible within agiven range. But the cellular networks evolved from pure voice service supportto data service support. The communication architecture is dominated by apoint-to-point communication between a mobile phone and the so-called basestation. The latter one can be referred to as the bridge between the wirelessand the wired world. In the following, we introduce some examples and tech-nologies for the European communication system GSM and its successors. Toconvey digital data from the mobile phone toward the core network, CircuitSwitched Data (CSD), was introduced in the first 2G mobile phones, sup-porting a rate of 9.6 kbps. GSM is a time division multiple access (TDMA)system, where users get assigned one or a set of given time slots to commu-nicate. To achieve the CSD data rate a single TDMA time slot is used. Inthis case the same capacity as a normal voice call is used. To increase thedata rate the High Speed Circuit Switched Data (HSCSD) was introduced.In contrast to the CSD, different coding schemes were used. In case of a goodchannel condition where no error protection is used, a data rate of 14.4 kbpscan be achieved. In case of a more unreliable wireless channel the full errorcorrection is needed ending up in the same data rate as CSD. Furthermore

10 F.H.P. Fitzek and F. Reichert

Table 1.1. Data rates for GPRS [kbit/s].

CS type 1 2 3 4 5 6 7 8

CS1 9.05 18.10 27.15 36.20 45.25 54.30 63.35 72.20CS2 13.40 26.80 40.20 53.60 67.00 80.40 93.80 107.20CS3 15.60 31.20 46.80 62.40 78.00 93.60 109.20 124.80CS4 21.40 42.80 64.20 85.60 107.00 128.40 149.80 171.20

HSCSD allowed to bundle up to four of those time slots resulting in a max-imum data rate of 57.6 kbps or 38.4 kbps for an error-free or an error-pronechannel, respectively. General Packet Radio Service (GPRS) is an extension toCSD and HSCSD. GPRS as well as HSCSD is referred to as 2.5G technologyand can be seen as a first step toward 3G networks. As HSCSD, GPRS usesbundling techniques to increase the data rate, but for GPRS bundling up toeight channels is supported. For GPRS four different coding schemes (CS) areavailable. If up to eight time slots can be bundled and four different CS areavailable, 32 different data rates are available as given in Table 1.1.

By bundling the unused TDMA time slots in the GSM cell it providesrealistically data rates between 40 and 50 kbps (with a theoretical capacityof 171.2 kbps). GPRS is part of GSM since Release 97 and onwards. In con-trast to the CSD and HSCSD, which were circuit-switched, GPRS is alreadypacket-switched and allows the user to be always on. This means that GPRScan be, and is mostly, billed per data volume and not on a time basis as thecircuit switched technologies. The available GPRS bandwidth is shared amongall GPRS users in the cell, where voice services are prioritized, so no qualityof service (QoS) guarantees can be made. The main application of GPRS isthe support of email services and web browsing, which can end up in poorperformance in fully loaded cells. The data rate supported by each mobilephone depends on the class, i.e., the Nokia N70 supports class 10 resulting inan uplink rate of 8–12 kbps and and a downlink rate of 32–48 kbps. EnhancedData Rates for GSM Evolution (EDGE) or enhanced GPRS (EGPRS) willbring higher data rates, which can go up to 473.6 kbps in the very best case.The high data rate is achieved extending the four modes of Gaussian Min-imum Shift Keying (GMSK) modulation used in GPRS with five modes of8-phase shift keying (8-PSK) modulation. Moving to 3G networks the Uni-versal Mobile Telecommunications System (UMTS) is introduced. The 3Gtechnology is based on Wideband Code Division Multiple Access (W-CDMA)as the underlying standard. UMTS is standardized by 3GPP offering datarates of nearly 2 Mbps within one UMTS cell and 384 kbps per end user. Theevolution of the cellular technology is shown in Figure 1.5.

In other regions of the world the technology is named differently but theprovided services and data rates are mainly the same with respect to the gran-ularity we need to discuss for the purpose of this book. The industry is contin-uing to evolve 3G networks. Mobile network providers are already installingsystem upgrades for using 3G High-Speed Downlink Packet Access (HSDPA)