Mobile App Development and IP Overview
Mobile App Development and IP Overview
Mobile Applications
and Mobile IP
LEARNING OBJECTIVES
After studying this chapter, you should be able to:
• Discuss some of the key characteristics of mobile application platforms.
• Provide an overview of the Android system architecture.
• Describe the reasons for needing Mobile IP.
• Define the various roles of devices within Mobile IP.
• Demonstrate the operation of Mobile IP.
Several of the major developments in wireless networking have come not just in
wireless communication, networks, or systems themselves, but also in the applica-
tions (or “apps” as they are simply called) supported on wireless devices. A vari-
ety of platforms and free or low-cost apps have captured the attention of potential
consumers of wireless services. These apps have made mobile computing on small
devices very easy to accomplish. Mobile device hardware designers have also
included many types of sensors such as location, temperature, light, acceleration,
magnetic field, and so on that are used in innovative ways.
This chapter first looks at two of the leading mobile device operating systems:
Android and iOS. It describes the platforms for application development, and then
shows the processes for app development and deployment. Then the remainder of
the chapter considers an important Internet Protocol (IP) standard that provides
application-level support for wireless networking: Mobile IP.
Operating systems for mobile platforms are fundamentally quite similar to those
for traditional desktop environments, with the addition of lower level drivers and
middleware to talk to hardware components, such as audio I/O and cameras. Mobile
platforms require the same core systems facilities as desktops: memory management,
process scheduling, device drivers, and security. Because of this, many operating
systems used on today’s modern mobile systems (such as Android) actually derive
common source and systems principles from previous systems (such as Linux).
While mobile environments share core systems facilities, their environment
and use cases dictate very different needs. For example, mobile platforms will typi-
cally have limited computing power and do not run batch programs same as a server
would. Mobile platforms also have very different interaction styles. Rather than
a graphical user interface (GUI) based on a mouse and window system, mobile
devices typically include a touchscreen guided by touch or voice command, and user
interfaces (UIs) are typically vastly different. Because of this, most mobile platforms
pair a traditional OS for operating hardware abstractions (such as memory, devices,
and the network) and provide additional abstractions to tailor to the special needs
of mobile platforms.
Today, mobile platforms typically run a core system (such as Android or iOS)
and allow third parties to extend the platform with applications that run on top of
the framework (sometimes simply called “apps”). Systems typically provide many
494 CHAPTER 15 / Mobile Applications and Mobile IP
mechanisms, which separate the apps from core functionality to make programming
easier (e.g., so that the app does not have to manually read location from a driver),
to ensure a unified user interface (e.g., by providing a single set of GUI elements),
and to maintain security guarantees that might not have been present in previous
systems (e.g., Android’s permissions system).
Resource Constraints
A modern desktop computer or server will have a large amount of RAM and a pow-
erful processor, operating while connected to a large power supply. By contrast,
mobile platforms have limited resources. Specifically, mobile systems are powered
almost exclusively by batteries and have a much smaller amount of RAM and inter-
nal memory, with limited computing power for graphics and computation. As such,
many mobile platforms provide mainly user interfaces to applications that interface to
remote cloud services. As an example, consider many popular apps, such as social net-
working, banking, or chat platforms. All of these applications are front ends to appli-
cations that are run on remote servers in the cloud, where heavy computation runs.
As an example, an application might use the location sensors on the platform
to determine the user’s location, and then forward it to a remote service, which
does the computation (a database query, perhaps) to determine which restaurants
are near the user, and display the results that are most likely to appeal to the user.
Expensive computation (such as looking up nearby restaurants and correlating it
to the user’s preferences) is done on the server, which has much higher amounts of
computing power. After the computation is executed, the results are relayed back
to the mobile device, and the application displays the results to the user, providing a
user interface that allows the user to visualize the results in a helpful way.
for mobile platforms typically happens in the same languages as for desktops (e.g.,
Java for Android, Objective C for iOS). This allows programmers to work with
familiar toolsets. To access the m
obile-specific features, mobile platforms also pro-
vide application frameworks: application programming interfaces (APIs) that allow
programmers to access features unique to mobile devices. These frameworks typi-
cally allow the programmer to access
• GUI interaction with the user
• Sensor data available (GPS, acceleration, etc.)
• Authentication and account access
• Interaction with remote servers
The rich amount of input available to the programmer (such as location and
social media account access) enables applications on mobile platforms to be highly
context aware. For example, an application might suggest restaurants nearby the
user, tailored to their preferences retrieved from a social media account. The use
of this c ontext-specific information not only provides a unique interaction style and
allows the design of applications, which present rich interaction mechanisms, but
it also provides its own set of challenges (such as security and privacy concerns).
The degree of input also differentiates mobile applications from Web services, and
explains why many Web sites also provide applications to access their services: the
range of application functionality (such as data persistence, sensory input) provided
by the framework usually offers more flexibility than a Web-based implementation
of the same technology.
Mobile platforms typically use different hardware than traditional desktop
computers. In the early days of mobile computing, this meant that applications
for mobile platforms were very customized and specific. To write applications for
a mobile device, the programmer would have to learn the specific APIs provided
by the manufacturer and typically program in a hardware-dependent way. As a
consequence, it was difficult for a programmer to write applications for a specific
device: they would have to learn many low-level details such as internals of the
processor or cater their application to a foreign operating system. As the mobile
landscape has evolved, modern platforms utilize high-level languages (such as
Objective C and Java) and provide access to system utilities via libraries. This is
making mobile application development much more accessible to programmers
familiar with traditional desktop or W eb-based settings, as they can take their
knowledge about these languages and use it to guide their design of applications
for mobile platforms.
Many mobile platforms use familiar languages, but provide custom toolchains
to run code on the device. As an example, the Android system allows programmers
to write in Java, but the Java bytecode (emitted by the Java compiler) is translated to
Dalvik virtual machine (DVM) bytecode. Dalvik is a virtual machine for Android,
which is similar to the Java virtual machine. The virtual machine is implemented
to optimize for the mobile platforms on which Android applications run by han-
dling resources in a way tailored to mobile platforms. Similarly, on iOS, the LLVM
cross compiler compiles Objective C code to compile to native code that runs on the
device’s processor.
15.2 / Mobile App Development 497
Development Environments
Developing applications for mobile platforms means managing potentially large
source projects. Projects are not simply limited to application code, but include GUI
layouts, device configurations (specifying the requirements for the application), and
documentation. To develop and maintain large applications, programmers typically
use Interactive Development Environments (IDEs). This allows a programmer to
organize projects, write code, and debug applications in a unified environment. Just
as programmers would use an IDE for desktop or Web applications, mobile plat-
forms provide custom versions of IDEs for developing mobile applications.
Android development allows for a number of development environments.
Google supports Android Studio and Eclipse, both IDEs tailored to J ava-based
development that include custom extensions tailored to Android development.
Both IDEs include support for testing and debugging code on an emulator, allow-
ing programmers to interactively design GUI layouts, and manage build systems
and source control. While developers are encouraged to use one of these tools, the
Android ecosystem also supports using custom builds via traditional java build sys-
tems (via ant or gradle, both of which are used by the aforementioned IDEs) and
code managed by any other editor (such as Emacs).
iOS applications are written using XCode, an IDE for developing applications
in Apple frameworks that includes support for designing for iOS devices. XCode
provides similar functionality to Eclipse, but for Objective C projects that target iOS
devices. XCode also provides facilities for app distribution.
Binder IPC
Power
AudioFlinger MediaPlayer Window
manager
service manager
service
Camera Activity
Other media
service manager Other services
services
Android runtime/Dalvik
Linux kernel
Audio driver
Camera driver Display drivers
(ALSA, OSS, etc) Other drivers
services code. This basically allows high-level framework APIs to interact with
Android’s system services.
Most of the functionality exposed through the application framework APIs
invokes Android system services that in turn access the underlying hardware and
kernel functions. Services are codes that run in the background, not attached to a
user. Services can be seen as being organized in two groups. Media services deal
with playing and recording media. System services deal with system functions visible
to the application. The latter include:
• Activity Manager: Manages the lifecycle of applications. It is responsible for
starting, stopping, and resuming the various applications. This is discussed fur-
ther subsequently.
• Window Manager: Java abstraction of the underlying Surface Manager. The
Surface Manager handles the frame buffer interaction and low-level drawing,
whereas the Window Manager provides a layer on top of it, to allow applica-
tions to declare their client area, and use features like the status bar.
15.2 / Mobile App Development 499
• Content Providers: These functions encapsulate application data that need to
be shared between applications, such as contacts. A content provider is an
extensible interface that allows other applications to access resources in a
clearly defined way (similar to a database).
• View System: Provides the user interface primitives, such as buttons, list boxes,
date pickers, and other controls, as well as UI events (such as touch and gestures).
• Notification Manager: Manages events, such as arriving messages and
appointments.
• Power Manager: Provides an interface to features added to the Linux kernel
to enhance the ability to perform power management.
The Android Runtime/Dalvik layer provides two components. The Android
Runtime component includes a set of core libraries that provides most of the func-
tionality available in the core libraries of the Java programming language. Every
Android application runs in its own process, with its own instance of the Dalvik
virtual machine.
The Hardware Abstraction Layer (HAL) provides a standard interface to
kernel-layer device drivers, so that upper-layer code need not be concerned with the
details of the implementation of specific drivers and hardware. The HAL is virtually
unchanged from that in a standard Linux distribution.
The Linux kernel for Android is similar to, but not identical with, the stan-
dard Linux kernel distribution. One noteworthy change is that the Android kernel
lacks drivers not applicable in mobile environments, making the kernel smaller. In
addition, Android enhances the Linux kernel with features that are tailored to the
mobile environment and generally not as useful or applicable on a desktop or laptop
platform.
Android relies on its Linux kernel for core system services such as security,
memory management, process management, network stack, and driver model. The
kernel also acts as an abstraction layer between the hardware and the rest of the
software stack and enables Android to use the wide range of hardware drivers that
Linux supports.
application metadata, such as the name, icon to be used, set of permissions the appli-
cation requires, and the main activity (which will be the entry screen to the app).
Unlike many desktop applications, there is not a clear notion of application closing.
Many traditional batch applications process some input, produce an output, and
then close. By contrast, Android applications live in memory, so the user can go
back to them at any point. The Android system retains a stack of activities within an
application, so the user retains a notion of where they are in the application.
Android applications run in separate OS processes to isolate components and
enforce security properties of the system. Because of this isolation, applications must
frequently communicate across processes to perform actions (e.g., an application
will call into the location provider process to access location information). Android
provides a fast remote procedure call (RPC) mechanism based on the Binder sys-
tem, which acts as a conduit for fast message passing and communication between
processes. A large portion of the functionality in the Android framework is built on
top of this lightweight but fast interprocess communication mechanism.
The Activity Lifecycle Each component in the Android system structures its
behavior around a state machine called a lifecycle (Figure 15.3). Activities form the
part of Android applications that interact with the user. Activities are implemented
by extending the Activity class of the Android API. While an application comprises
multiple activities, only one is on screen (active) at any time. Navigating between
activities happens by the user performing actions (such as clicking the “back” but-
ton on the device) and the application sending requests (e.g., to start a new activity)
via Intents (messages sent to the Android system that trigger certain action). The
Dedicated Process
Broadcast Content
Receiver Provider
Application
Activity Service
Dedicated
virtual machine
Activity
launched
onCreate()
Entire
lifetime
onStart() onRestart()
User navigates
to the activity Visible
lifetime
onResume()
App process
killed Foreground
lifetime User returns
to the activity
Resumed
Apps with higher
priority need memory
onPause()
Paused
User navigates
to the activity
onStop()
Stopped
onDestroy()
Activity
shut down
ctivity class has methods (such as onCreate(), which is called when the activity is
A
first created) that the developer extends to implement the desired application logic
(such as displaying buttons on the screen).
GUI Input Interacting with the user happens via Android activities. Unlike many
desktop applications, Android applications occupy the entire screen of the device.
Each activity specifies the GUI layout for what the user sees on the screen. An ap-
plication may comprise many activities. As an example, in our streaming app, we may
have a main screen that presents the list of streams that can be played, a screen to
add a new stream to the database, and a screen to set preferences (e.g., quality of the
music, volume controls, etc.). In Android, screen navigation follows a stack: when the
15.3 / Mobile Application Deployment 503
user goes to a new activity (taking over the screen), they can press the back button,
and move back to their previous activity.
To interact with the Android operating system, an application developer will
send various messages to the system. These messages are called Intents, and allow
the programmer to change the currently active activity, start a new service, query a
content provider, and more.
Security By default, applications cannot perform any operations other than display-
ing graphical interfaces to the user. To access user data (such as their contacts and text
message history) and perform privileged operations (such as sending text messages
and writing on the Internet), the user must explicitly grant access to the application.
In Android, this happens via permissions. Each privileged operation or API will
be guarded by a permission declared in the manifest (e.g., READ_CONTACTS
or INTERNET). When the application is installed, the user is presented with a list
of these permissions, and decides whether to install the app. Application developers
should only request access to resources explicitly needed by the application (e.g., the
application should never request for contact information if it isn’t necessary to the
application’s performance).
While the permission-based security architecture works for access control, it
still has flaws, and application developers must be careful to ensure that data does
not leak the application in an inappropriate way. As an example, many ad services
require the user’s location to provide targeted ads to the user based on stores nearby
their geographic location. The developer must carefully think about what informa-
tion is leaking to what parties, and inform the user when information is being used.
Play (for Android), and Apple’s App Store. Third-party markets (such as Amazon
Appstore) also exist and offer different options for users and developers (such as
different selections of apps, ways apps are marketed, payment processes, and devel-
oper submission procedure).
Deployment to Markets
Each market has a procedure through which developers identify themselves and
apply to have their apps available for purchase (or for free). Developers must first
register (sometimes paying a fee) and submit various identifying information (such
as tax information or encryption keys). Developer accounts act as a point of contact
if users report that an app is behaving incorrectly, and having to pay a registra-
tion fee can help avoid developers submitting malicious apps that will quickly be
revoked from the market (because, e.g., they break the user’s privacy).
After a developer registers with a market, there is typically a process to upload
their application, typically signed with a cryptographic key that ties the application
to the developer that registered on the market (to prevent a malicious app distribu-
tor from masquerading as the developer). Next, the market will typically review the
app, scan it for viruses, and make sure that it performs the intended function and
does not violate any terms of service. As an example, many markets require that
purchase in applications happen through the market rather than a third-party ser-
vice and that an application does perform malicious operations on the user’s behalf.
After an application passes this phase, it is released on the market and users may
install it on their device.
Quality Control
App developers must take care to ensure that once their app is deployed, they con-
tinue to be responsive to user needs. Developers can help to improve their ratings
by responding in a timely manner to bug reports and feature requests, along with
informing users of updates to applications and making sure that their application
is up-to-date with respect to new system features. Because platforms continually
become more powerful, frameworks add new features and applications using old
layouts or themes will appear aged. Developers must keep in mind to update their
applications to account for current themes of popular applications.
15.4 / Mobile Ip 505
Testing an application can never identify all of the bugs potentially pres-
ent. Because of this, there will always be errors in deployed apps. As a developer,
employing defensive strategies such as unit and regression testing can help to iden-
tify bugs early, but there are many factors that developers cannot always plan for.
For example, a new device may ship with a unique screen configuration for which
the application developer may not have accounted. It is important that when bugs
do crop up in applications, developers can reproduce and isolate them in a system-
atic way, and release an update to users in a timely fashion.
One tool for doing this on Android is Automated Crash Reporting for Android
(ACRA). This tool allows developers to detect and isolate errors, and gives detailed
reports as to which errors are most important to allow developers to triage bugs.
Similar crash reporting systems exist for other systems, and developers should have
a strategy for assessing the sources of bugs and determining which can be easily
reproduced and fixed in subsequent application versions.
15.4 MOBILE IP
Operation of Mobile IP
As was described in Chapter 4, routers make use of the IP address in an IP datagram
to perform routing. In particular, routers use the network portion of an IP address
(Figure 4.11) to move a datagram from the source computer to the network to which
the target computer is attached. Then the final router on the path, which is attached
to the same network as the target computer, uses the host portion of the IP address
to deliver the IP datagram to the destination. Further, this IP address is known to
the next higher layer in the protocol architecture (Figure 4.1). In particular, most
applications over the Internet are supported by TCP connections. When a TCP
506 CHAPTER 15 / Mobile Applications and Mobile IP
connection is set up, the TCP entity on each side of the connection knows the IP
address of the correspondent host. When a TCP segment is handed down to the IP
layer for delivery, TCP provides the IP address, and IP creates an IP datagram with
that IP address in the IP header and sends the datagram out for routing and delivery.
However, with a mobile host, the IP address may change while one or more TCP
connections are active.
Two approaches can be used to handle the problem of dynamic addresses.
The mobile node can manage the process using a client-based approach, or the
network can manage the changes in IP addresses using a network-based approach.
In a network-
based approach, such as Mobile IPv6 standardized in Internet
Engineering Task Force Request for Comments RFC 5213, many of the same pro-
cedures are followed as the c lient-based approach, except that different actors
are involved and procedures are largely hidden to the mobile node. We focus our
discussion on the c lient-based approach, but again the procedures are similar for
both.
Figure 15.4 shows in general terms how Mobile IP deals with the problem of
dynamic IP addresses. A mobile node is assigned to a particular network, known
as its home network. Its IP address on that network, known as its home address, is
static. When the mobile node moves its attachment point to another network, that
network is considered a foreign network for this host. Once the mobile node is reat-
tached, it makes its presence known by registering with a network node, typically
a router, on the foreign network known as a foreign agent. The mobile node then
Mobile
node A
3
Home
network 4 Foreign
Home
for A network
agent
2
Foreign
agent
Internet or other
topology of routers
and links 5
1
Server
X
Figure 15.4 Mobile IP Scenario
15.4 / Mobile Ip 507
communicates with a similar agent on the user’s home network, known as a home
agent, giving the home agent the care-of address of the mobile node; the c are-of
address identifies the foreign agent’s location. Typically, one or more routers on a
network will implement the roles of both home and foreign agents.
When IP datagrams are exchanged over a connection between the mobile
node and another host (a server in Figure 15.4), the following operations occur:
1. Server X transmits an IP datagram destined for mobile node A, with A’s home
address in the IP header. The IP datagram is routed to A’s home network.
2. At the home network, the home agent intercepts the incoming IP datagram.
The home agent encapsulates the entire datagram inside a new IP datagram
that has A’s care-of address in the header, and retransmits the datagram. The
use of an outer IP datagram with a different destination IP address is known as
tunneling. This IP datagram is routed to the foreign agent.
3. The foreign agent strips off the outer IP header, encapsulates the original IP
datagram in a network-level PDU (e.g., a LAN LLC frame), and delivers the
original datagram to A across the foreign network.
4. When A sends IP traffic to X, it uses X’s IP address. In our example, this is a
fixed address; that is, X is not a mobile node. Each IP datagram is sent by A to
a router on the foreign network for routing to X. Typically, this router is also
the foreign agent.
5. The IP datagram from A to X travels directly across the Internet to X, using
X’s IP address.
To support the operations illustrated in Figure 15.4, Mobile IP includes three
basic capabilities:
• Discovery: A mobile node uses a discovery procedure to identify prospective
home agents and foreign agents.
• Registration: A mobile node uses an authenticated registration procedure to
inform its home agent of its care-of address.
• Tunneling: Tunneling is used to forward IP datagrams from a home address to
a care-of address.
Figure 15.5 indicates the underlying protocol support for the Mobile IP capa-
bility. The registration protocol communicates between an application on the
mobile node and an application in the home agent and hence uses a transport-level
protocol. Because registration is a simple r equest-response transaction, the over-
head of the connection-oriented TCP is not required, and therefore UDP is used
as the transport protocol. Discovery makes use of the existing Internet Control
Message Protocol (ICMP) by adding the appropriate extensions to the ICMP
header. ICMP, which is described in Appendix 15A, is a connectionless protocol
well suited for the discovery operation. Finally, tunneling is performed at the IP
level.
Mobile IP is specified in a number of RFCs. The basic defining document is
RFC 5944 for IPv4. Table 15.1 lists some useful terminology from RFC 5944. Mobile
IPv6 is described in RFCs 5213 and 6275.
508 CHAPTER 15 / Mobile Applications and Mobile IP
Discovery
The discovery process in Mobile IP is very similar to the router advertisement pro-
cess defined in ICMP (see Appendix 15A). Accordingly, agent discovery makes use
of ICMP router advertisement messages, with one or more extensions specific to
Mobile IP.
The mobile node is responsible for an ongoing discovery process. It must deter-
mine if it is attached to its home network, in which case IP datagrams may be received
without forwarding, or if it is attached to a foreign network. Because handoff from
one network to another occurs at the physical layer, a transition from the home net-
work to a foreign network can occur at any time without notification to the network
layer (i.e., the IP layer). Thus, discovery for a mobile node is a continuous process.
For the purpose of discovery, a router or other network node that can act as an
agent periodically issues a router advertisement ICMP message (see Figure 15.9d in
Appendix 15A) with an advertisement extension. The router advertisement portion
of the message includes the IP address of the router. The advertisement extension
includes additional information about the router’s role as an agent, as discussed sub-
sequently. A mobile node listens for these agent advertisement messages. Because
a foreign agent could be on the mobile node’s home network (set up to serve visit-
ing mobile nodes), the arrival of an agent advertisement does not necessarily tell
the mobile node that it is on a foreign network. The mobile node must compare
the network portion of the router’s IP address with the network portion of its own
home address. If these network portions do not match, then the mobile node is on
a foreign network.
The agent advertisement extension follows the ICMP router advertisement
fields. The extension includes the following 1-bit flags:
• R: Registration with this foreign agent is required (or another foreign agent on
this network). Even those mobile nodes that have already acquired a c are-of
address from this foreign agent must reregister.
• B: Busy. The foreign agent will not accept registrations from additional mobile
nodes.
• H: This agent offers services as a home agent on this network.
• F: This agent offers services as a foreign agent on this network.
• M: This agent can receive tunneled IP datagrams that use minimal encapsula-
tion, explained subsequently.
• G: This agent can receive tunneled IP datagrams that use generic routing
encapsulation (GRE) encapsulation, explained subsequently.
• r: reserved.
• T: Foreign agent supports reverse tunneling.
In addition, the extension includes zero or more care-of addresses supported
by this agent on this network. There must be at least one such address if the F bit is
set. There may be multiple addresses.
issue an ICMP router solicitation message (see Figure 15.9e in Appendix 15A). Any
agent receiving this message will then issue an agent advertisement.
Move Detection As was mentioned, a mobile node may move from one network
to another due to some handoff mechanism, without the IP level being aware of it.
The agent discovery process is intended to enable the agent to detect such a move.
The agent may use one of two algorithms for this purpose:
• Use of lifetime field: When a mobile node receives an agent advertisement from
a foreign agent that it is currently using or that it is now going to register with, it
records the lifetime field as a timer. If the timer expires before the mobile node
receives another agent advertisement from the agent, then the node assumes
that it has lost contact with that agent. If, in the meantime, the mobile node
has received an agent advertisement from another agent and that advertise-
ment has not yet expired, the mobile node can register with this new agent.
Otherwise, the mobile node should use agent solicitation to find an agent.
• Use of network prefix: The mobile node checks whether any newly received
agent advertisement is on the same network as the node’s current care-of
address. If it is not, the mobile node assumes that it has moved and may reg-
ister with the agent whose advertisement the mobile node has just received.
Co-Located Addresses The discussion so far has involved the use of a care-
of address associated with a foreign agent; that is, the care-of address is an IP ad-
dress for the foreign agent. This foreign agent will receive datagrams at this c are-of
address, intended for the mobile node, and then forward them across the foreign
network to the mobile node. However, in some cases a mobile node may move to
a network that has no foreign agents or on which all foreign agents are busy. As an
alternative, the mobile node may act as its own foreign agent by using a c o-located
care-of address. A c o-located care-of address is an IP address obtained by the mobile
node that is associated with the mobile node’s current interface to a network.
The means by which a mobile node acquires a c o-located address is beyond the
scope of Mobile IP. One means is to dynamically acquire a temporary IP address
through an Internet service such as Dynamic Host Configuration Protocol (DHCP).
Another alternative is that the co-located address may be owned by the mobile node
as a long-term address for use only while visiting a given foreign network.
Registration
Once a mobile node has recognized that it is on a foreign network and has acquired a
care-of address, it needs to alert a home agent on its home network and request that
the home agent forward its IP traffic. The registration process involves four steps:
1. The mobile node requests the forwarding service by sending a registration
request to the foreign agent that the mobile node wants to use.
2. The foreign agent relays this request to the mobile node’s home agent.
3. The home agent either accepts or denies the request and sends a registration
reply to the foreign agent.
4. The foreign agent relays this reply to the mobile node.
15.4 / Mobile Ip 511
If the mobile node is using a co-located care-of address, then it registers
directly with its home agent, rather than going through a foreign agent.
The registration operation uses two types of messages, carried in UDP seg-
ments (Figure 15.6). The registration request message consists of the following fields:
• Type: 1, indicates that this is a registration request.
• S: Simultaneous bindings. The mobile node is requesting that the home agent
retain its prior mobility bindings. When simultaneous bindings are in effect,
the home agent will forward multiple copies of the IP datagram, one to each
care-of address currently registered for this mobile node. Multiple simultane-
ous bindings can be useful in wireless handoff situations, to improve reliability.
• B: Broadcast datagrams. Indicates that the mobile node would like to receive
copies of broadcast datagrams that it would have received if it were attached
to its home network.
• D: Decapsulation by mobile node. The mobile node is using a c o-located care-
of address and will decapsulate its own tunneled IP datagrams.
• M: Indicates that the home agent should use minimal encapsulation, explained
subsequently.
Bit: 0 8 16 31
Home address
24 octets
Home agent
Care-of address
Identification
Extensions
Bit: 0 8 16 31
Home address
20 octets
Home agent
Identification
Extensions
• G: Indicates that the home agent should use GRE encapsulation, explained
subsequently.
• r: Reserved.
• T: Reverse tunneling requested.
• x: Reserved.
• Lifetime: The number of seconds before the registration is considered expired.
A value of zero is a request for de-registration.
• Home Address: The home IP address of the mobile node. The home agent
can expect to receive IP datagrams with this as a destination address, and must
forward those to the care-of address.
• Home Agent: The IP address of the mobile node’s home agent. This informs
the foreign agent of the address to which this request should be relayed.
• Care-of Address: The IP address at this end of the tunnel. The home agent
should forward IP datagrams that it receives with mobile node’s home address
to this destination address.
• Identification: A 64-bit number generated by the mobile node, used for match-
ing registration requests to registration replies and for security purposes, as
explained subsequently.
• Extensions: The only extension so far defined is the authentication extension,
explained subsequently.
The registration reply message consists of the following fields:
• Type: 3, indicates that this is a registration reply.
• Code: Indicates result of the registration request (see Table 15.2).
• Lifetime: If the code field indicates that the registration was accepted, the
number of seconds before the registration is considered expired. A value of
zero indicates that the mobile node has been de-registered.
• Home Address: The home IP address of the mobile node.
• Home Agent: The IP address of the mobile node’s home agent.
• Identification: A 64-bit number used for matching registration requests to reg-
istration replies.
• Extensions: The only extension so far defined is the authentication extension,
explained subsequently.
134 Poorly formed request 75 Reverse tunnel is mandatory and ‘t’ bit not set
135 Too many simultaneous mobility bindings 76 Mobile node too distant
138 Reverse tunnel is mandatory and ‘t’ bit 79 Delivery style not supported
not set 80 Home network unreachable (icmp error received)
139 Requested encapsulation unavailable 81 Home agent host unreachable (icmp error received)
82 Home agent port unreachable (icmp error received)
88 Home agent unreachable (other icmp error received)
1
For the complete list, see [Link]
Tunneling
Once a mobile node is registered with a home agent, the home agent must be able to
intercept IP datagrams sent to the mobile node’s home address so that these data-
grams can be forwarded via tunneling. The standard does not mandate a specific
technique for this purpose but references Address Resolution Protocol (ARP) as
a possible mechanism. The home agent needs to inform other nodes on the same
network (the home network) that IP datagrams with a destination address of the
mobile node in question should be delivered (at the link level) to this agent. In
effect, the home agent steals the identity of the mobile node in order to capture
packets destined for that node that are transmitted across the home network.
For example, suppose that R3 in Figure 15.7 is acting as the home agent for a
mobile node that is attached to a foreign network elsewhere on the Internet. That
is, there is a host H whose home network is LAN Z that is now attached to some
foreign network. If host D has traffic for H, it will generate an IP datagram with H’s
home address in the IP destination address field. The IP module in D recognizes that
this destination address is on LAN Z and so passes the datagram down to the link
layer with instructions to deliver it to a particular MAC-level address on Z. Prior
to this time, R3 has informed the IP layer at D that datagrams destined for that
particular address should be sent to R3. Thus, D inserts the MAC address of R3 in
the destination MAC address field of the outgoing MAC frame. Similarly, if an IP
datagram with the mobile node’s home address arrives at router R2, it recognizes
that the destination address is on LAN Z and will attempt to deliver the datagram to
a MAC-level address on Z. Again, R2 has previously been informed that the M AC-
level address it needs corresponds to R3.
For traffic that is routed across the Internet and arrives at R3 from the Internet,
R3 must simply recognize that for this destination address, the datagram is to be
captured and forwarded.
15.4 / Mobile Ip 515
LAN X
B
A
R1
Internet
LAN Y
C
R3
R2
LAN Z
To forward an IP datagram to a care-of address, the home agent puts the entire
IP datagram into an outer IP datagram. This is a form of encapsulation, just as plac-
ing an IP header in front of a TCP segment encapsulates the TCP segment in an IP
datagram. Three options for encapsulation are allowed for Mobile IP:
• IP-within-IP encapsulation: This is the simplest approach, defined in RFC
2003.
• Minimal encapsulation: This approach involves fewer fields, defined in RFC
2004.
• Generic routing encapsulation: This is a generic encapsulation procedure that
was developed prior to the development of Mobile IP, defined in RFC 1701.
We review the first two of these methods.
Version Version
IHL Type of service Total length IHL Type of service Total length
=4 =4
New IP header
IP header
Modified
Time to live Protocol = 4 Header checksum Time to live Protocol = 55 Header checksum
Source address (home agent address) Source address (home agent address)
forwarding
=4
Minimal
header
Old IP header
Time to live Protocol Header checksum Source address (original sender; may not be present)
Example 15.1 Consider an IP datagram that originates at server X in Figure 15.4 and
that is intended for mobile node A. The original IP datagram has a source address equal
to the IP address of X and a destination address equal to the IP home address of A. The
network portion of A’s home address refers to A’s home network, and so the datagram
is routed through the Internet to A’s home network, where it is intercepted by the home
agent. The home agent encapsulates the incoming datagram with an outer IP header,
which includes a source address equal to the IP address of the home agent and a destina-
tion address equal to the IP address of the foreign agent on the foreign network to which
A is currently attached. When this new datagram reaches the foreign agent, it strips off
the outer IP header and delivers the original datagram to A.
15.5 / Recommended Reading 517
A variety of references on Android and iOS development are provided on this book’s Web
site at [Link]. RFC 5213 describes Mobile IPv6 and [ALI09] provides a dis-
cussion of Mobile IP and the interaction with the LTE Evolved Packet Core.
518 CHAPTER 15 / Mobile Applications and Mobile IP
ALI09 Ali, I; Casati, A; Chowdhury, K.; Nishida, K.; Parsons, E.; Schmid, S.; and Vaid-
ya, R. “Network-based mobility management in the evolved 3GPP core network,”
Communications Magazine, IEEE, vol. 47, no. 2, pp. 58, 66, February 2009.
Key Terms
Review Questions
15.1 List some commonalities between mobile platform OSs and traditional desktop/
laptop OSs.
15.2 What features unique to mobile devices are typically accessible via APIs by
programmers?
15.3 List and briefly define the architecture layers of Android.
15.4 List and briefly define some of the key Android system services.
15.5 What is Dalvik?
15.6 Describe the Android activity lifecycle.
15.7 Explain the distinction between a mobile user and a nomadic user.
15.8 What is tunneling?
15.9 List and briefly define the capabilities provided by Mobile IP.
15.10 What is the relationship between Mobile IP discovery and ICMP?
15.11 What are the two different types of destination addresses that can be assigned to a
mobile node while it is attached to a foreign network?
15.12 Under what circumstances would a mobile node choose to use each of the types of
address referred to in Question 15.11?
Problems
15.1 This problem refers to Figure 15.7. Suppose that LAN Z is the home network for host
E and that D sends a block of data to E via IP.
a. Show the PDU structure, including the fields of the IP header and the l ower-level
headers (MAC, LLC) with the contents of address fields indicated for the case in
which E is on its home network.
b. Repeat part a for the case in which E is on a foreign network reachable via the
Internet through R3. Show formats for the MAC frame leaving D and the IP data-
gram leaving R3. Assume that IP-to-IP encapsulation is used.
APPENDIX 15A INTERNET CONTROL MESSAGE PROTOCOL 519
c. Repeat part b for the IP datagram leaving R3, but now assume that minimal
encapsulation is used.
15.2 Again referring to Figure 15.7, assume that A is a mobile node and that LAN X is a
foreign network for A. Assume that an IP datagram arrives at R1 from the Internet to
be delivered to A. Show the format of the IP datagram arriving at R1 and the MAC
frame leaving R1 (include the IP header or headers) for the following cases:
a. IP-to-IP encapsulation is used and R1 is the care-of address.
b. Minimal encapsulation is used and R1 is the care-of address.
c. IP-to-IP encapsulation is used and A is the care-of address.
d. Minimal encapsulation is used and A is the care-of address.
15.3 In a typical Mobile IP implementation in a home agent, the agent maintains a mobility-
binding table to map a mobile node’s home address to its care-of address for packet
forwarding. What entries are essential for each row of the table?
15.4 In a typical Mobile IP implementation in a foreign agent, the agent maintains a visitor
table that contains information about the mobile nodes currently visiting this net-
work. What entries are essential for each row of the table?
The IP standard specifies that a compliant implementation must also implement ICMP (RFC
792, RFC 950, RFC 1256). ICMP provides a means for transferring messages from routers
and other hosts to a host. In essence, ICMP provides feedback about problems in the commu-
nication environment. Examples of its use are when a datagram cannot reach its destination,
when the router does not have the buffering capacity to forward a datagram, and when the
router can direct the station to send traffic on a shorter route. In most cases, an ICMP mes-
sage is sent in response to a datagram, either by a router along the datagram’s path or by the
intended destination host.
ICMP is a user of IP. An ICMP message is constructed and then passed down to IP,
which encapsulates the message with an IP header and then transmits the resulting datagram
in the usual fashion. Because ICMP messages are transmitted in IP datagrams, their delivery
is not guaranteed and their use cannot be considered reliable.
Figure 15.9 shows the format of the various ICMP message types. An ICMP message
starts with a 64-bit header consisting of the following:
• Type (8 bits): Specifies the type of ICMP message.
• Code (8 bits): Used to specify parameters of the message that can be encoded in one
or a few bits.
• Checksum (16 bits): Checksum of the entire ICMP message. This is the same checksum
algorithm used for IP.
• Parameters (32 bits): Used to specify more lengthy parameters.
For some message types, these fields are followed by additional information fields that
further specify the content of the message.
In those cases in which the ICMP message refers to a prior datagram, the informa-
tion field includes the entire IP header plus the first 64 bits of the data field of the original
datagram. This enables the source host to match the incoming ICMP message with the prior
datagram. The reason for including the first 64 bits of the data field is that this will enable the
IP module in the host to determine which upper-level protocol or protocols were involved. In
particular, the first 64 bits would include a portion of the TCP header or other t ransport-level
header.
520 CHAPTER 15 / Mobile Applications and Mobile IP
Router Discovery
A router discovery capability was added to ICMP with RFC 1256. The objective of the router
discovery capability is to automate the process by which a host determines a router address.
In order for a host to send an IP datagram beyond the network to which it is attached, the host
must have the address of at least one router attached to that network. These router addresses
can be preconfigured in the host, but this approach has limitations. In particular, for newly
attached hosts, including mobile hosts, such configuration files may not be available. RFC
1256 provides a way by which hosts may discover router addresses. It is applicable on net-
works that provide a multicast and/or broadcast capability.1
1
A multicast address is an address that designates a group of entities within a domain (e.g., network,
Internet). A broadcast address is an address that designates all entities within a domain. Multicast
and broadcast are easily done on a local area network, because all stations share the same transmis-
sion medium. Multicast and broadcast are also available on a number of wireless and switched network
technologies.
522 CHAPTER 15 / Mobile Applications and Mobile IP
RFC 1256 defines two new ICMP message types: router advertisement and router so-
licitation. Periodically, each router that conforms to RFC 1256 issues a router advertisement
message. The message includes the following fields:
• Num Addrs: The number of router addresses advertised in this message.
• Addr Entry Size: The number of 32-bit words per each router address; the value must
be 2.
• Lifetime: The maximum number of seconds that the router advertisement may be con-
sidered valid; the default value is 1800 (30 minutes).
• Router Address i, for 1 ≤ i ≤ Num Addrs: The sending router’s IP address(es) on the
interface from which the message was sent.
• Preference Level i, for 1 ≤ i ≤ Num Addrs: The preferability of each router address
i as a default router address, relative to other router addresses on this network. This
is a signed value in twos complement representation; a higher value indicates more
preferable.
Typically, a router will have a single IP address on a network, but multiple IP addresses
are allowed. There will be multiple IP addresses for a router if the router has multiple phys-
ical connections (interfaces) to the network. Multiple IP addresses may also be assigned to a
single interface to serve multiple subnets; this latter use need not concern us here. The pref-
erence level is used by a host to determine a default router to use when the host does not
have sufficient routing information to determine which router is best for a given destination
address. For example, in Figure 12.6, an IP datagram from host D addressed to host C is best
sent through router R2, whereas a datagram addressed to a remote host elsewhere in the
network should be sent through R3. But initially, if D has no information about which router
to use, it needs to send the datagram to a default router. In this example, if the network ad-
ministrator determines that most Internet traffic from LAN Z is local (to other LANs at this
location), then R2 should be assigned a higher preference level; and if most of the traffic is
remote, then R3 should be assigned a higher preference level.
As a default, routers should issue router advertisement messages once every 7 to 10
minutes. If all hosts on this network support the IP multicast feature, then the messages should
be sent on the a ll-systems multicast address of [Link]. Otherwise the broadcast address of
[Link] must be used.
If a host is just becoming active on a network, it can solicit router advertisements from
all attached routers by issuing a router solicitation message. Note from Figure 15.9e that this
message contains no information other than identifying the type of message. Its purpose is
simply to stimulate all routers to issue advertisements; hence no additional information is
needed. If all routers on this network support the IP multicast feature, then the messages
should be sent on the all-routers multicast address of [Link]. Otherwise the broadcast ad-
dress of [Link] must be used.
One of the requirements for the Mobile IP registration protocol is message authentication.
This appendix provides a brief overview. For more detail, see [STAL14].
A message, file, document, or other collection of data is said to be authentic when it is
genuine and comes from its alleged source. Message authentication is a procedure that allows
communicating parties to verify that received messages are authentic. The two important as-
pects are to verify that the contents of the message have not been altered and that the source
APPENDIX 15B MESSAGE AUTHENTICATION 523
is authentic. We may also wish to verify a message’s timeliness (it has not been artificially
delayed and replayed) and sequence relative to other messages flowing between two parties.
A common technique used for message authentication is based on a keyed o ne-way
hash function.
2
|| denotes concatenation.
524 CHAPTER 15 / Mobile Applications and Mobile IP
Secret key
Message
Message
Message
H
Compare
H
Hash code
The keyed hash code approach depends on the hash function being one way. If the
hash function is not one way, an attacker can easily discover the secret value: If the at-
tacker can observe or intercept a transmission, the attacker obtains the message M and
the hash code MDM = H(SAB M). The attacker then inverts the hash function to obtain
SAB M = H-1(MDM). Because the attacker now has both M and SAB M, it is a trivial mat-
ter to recover SAB.