Stateful Publish-Subscribe for Mobile Environments

Introduction

Download

Publications




Introduction



Publish-subscribe is now a well-known paradigm for building robust, large-scale distributed systems. In this architecture, the components interact via publishing messages and subscribing to classes of messages through a centralized component (the server). The set of conditions imposed by a subscriber define the subscriber’s policy. A common characteristic of these architectures is that the server does not maintain any state about the subscribers. The server keeps only the address of the subscriber (usually an IP address) and the associated policy. The policy is usually specified in a language based on first-order predicates and decides whether the message is sent to the particular subscriber only based on the content of the message.

Publish-subscribe promises to be a very good paradigm for developing applications for mobile environments due to the loose coupling of the components that are involved. However, the limited and highly dynamic resources of the mobile devices (such as network connection, energy supply) impose major challenges on the way the subscribers should specify their policies. The proliferation of Wi-Fi wireless LANs makes this situation even worse, since the clients need to be able to make a smooth transition from the hotspots to areas with normal or poor coverage. The main question we address in this paper is: What type of policies do the subscribers need to specify in order to be able to receive the right information in such environments?

There has been a considerable body of research in the last years on supporting publish-subscribe in mobile environments. The main focus was to improve the performance of the overall system in the presence of sporadic connectivity, using different algorithms for finding the best path to the mobile subscriber or support for offline work. In this paper we argue that we need novel mechanisms for the deployment of the policies themselves in order to support publish-subscribe in mobile environments.

A wide range of applications use the publish-subscribe paradigm, from simple stock quotes to civil disaster recovery or customized enterprise applications. To illustrate the generality of the problems that are faced in mobile environments we will give short examples in each category.

Suppose that in a stock market application, a client wants to receive information about the companies DELL or IBM when the stock quote drops under $30. The information about the company may contain additional data, like company name, percentage change and the number of shares that were transacted in a given period. In a mobile environment, the client would like to specify how the conditions change depending on information like the quality of the connection or battery power left. For example, the client may be interested in getting the stock quotes of IBM, DELL and Microsoft if it has a good connection and a lot of battery power left, but only in IBM if the price goes under $20 and less than 30% battery power is available. Also, if the client has a bad connection, it might be interested in getting only the actual quote for the stock price with no additional information like percentage change and the number of shares that were transacted.

Consider now a civil disaster recovery scenario, where agents in the field are equipped with mobile devices and are searching in a specified region. They can receive periodical updates from different data sources about any activity that was discovered in the area. The information can be a complex map or just some simple map indications. It should be possible for the agent to define its policy based on the current state it is in, depending on the network connectivity, remaining power, etc.

Finally, let us consider a large hospital with an Intensive Care Unit. The patients are monitored continuously using specialized devices. Ideally, the doctor would like to receive all of the data for the patients he is responsible for, if he has a good network connection and the battery of his PDA is charged. However, if the network connection deteriorates, he would like to be sure that he receives the most important data (such as the pulse) and maybe compressed versions of the least important data, even with loss of information such as the electrocardiogram. Moreover, if the battery power is very low, he would like only a summary of the state of the patients, at a regular interval of time.

We believe that the main characteristics that make the publish-subscribe paradigm suitable for mobile systems are the following:

  • Stateful subscribers
  • The server must maintain a state associated with each subscriber. The state is an abstract concept and can be composed of any number of variables that describe the properties of a particular client.

  • Rich language for expressing the conditions
  • A first-order predicate-based language which allows only interaction with the content of the message is no longer suitable for mobile systems. The language in which the conditions are written should be able to allow the interaction with the content of the message and with the state of the subscriber. It should also be able to modify the message content that is actually sent to the client according to the policy.

    The SUBLIM system supports publish-subscribe for mobile systems and meets the above requirements. Our approach can be used in conjunction with current systems, where the server maintains states only for some of the subscribers facilitating an incremental deployment. In our system, the servers are running on the access points of the wireless environments, ensuring a good scalability by supporting a potentially large number of subscribers with minimal overhead.

    The architecture for the SUBLIM system is based on a distributed network of servers in order to support a large number of subscribers. We assume that the subscribers are using wireless devices (such as PDAs). The servers are running on the access points of the wireless network, so that each server will be responsible for the subscribers connected to that access point. In Figure 1 we present the global architecture for our system, where WS stands for Wireless Subscriber. The solid lines represent wired network connection, while the dashed ones represent wireless connections. As we can notice, SUBLIM servers are running on the base stations, with wireless devices as subscribers. Publishers are also connecting to a SUBLIM Publish server that has as subscribers the servers running on the base stations. In the current implementation, the Publish Server is a simple router that forwards all of the messages to the SUBLIM Servers running on the base stations.

    We will now present the abstract model used for building stateful publish-subscribe systems. The subscribers compose a community, or more specifically a S-community, where S is the SUBLIM server. To differentiate between specific subscribers, the server maintains some state for each member of the community. More formally, a S-Community is a tuple {S,C, ST, P, M}, where S is the server of the community, C is the set of subscribers, ST is a mutable set {STx, x in C} of subscribers state, (one per each subscriber in C), P is the set of policies, (one for each subscriber in C) and M is the set of messages that can be received by the subscribers. The state is a tuple-space and can be composed of any number of variables, describing the subscriber properties. Each variable is uniquely identified by its name. The variables can be automatic, in the sense that their values are maintained by the SUBLIM system, or manual, maintained by the policy itself.

    The SUBLIM client is a component that runs on each subscriber. The SUBLIM client is responsible for maintaining the automatic variables

    When a message arrives, the arrived() event is triggered and the policy specifies the operations that have to be performed. In our current implementation the operations are specified in a C++-like syntax. In addition to all the operations supported by C++, the policy can invoke a number of system operations that are implemented by the server. The currently supported grammar is presented in Figure 3. There are three operations associated with the handling of the properties maintained in the subscriber state (getProperty, setProperty and removeProperty). The automatic properties are read only, so the setProperty and removeProperty operations will do nothing. The policy can also specify how to create a message, using the createMessage operation, and how to manipulate the content of a message. A detailed example of such a policy is given in Section 5.

    Server Architecture

    The architecture of the server is presented in Figure 1. The subscriber creates the policy and sends it to the server using a setPolicy() command (Step 1 in Figure 1). The server generates an agent, which will be associated with this subscriber. Each time a message arrives at the server from a publisher, an arrived event is triggered at every connected participant.

    The main difference in the design of the SUBLIM server compared with other publish-subscribe servers is the way the policies are written and interpreted by SUBLIM. The policy is translated into C++ and then linked together with the needed SUBLIM libraries in a dynamic link library (DLL). The server attaches the DLL and then uses the function provided by the DLL in order to make the decision. Thus, the server is very flexible and able to handle any number of heterogeneous policies in an efficient manner.

    When a message m arrives (Step 2), it is processed by the Message Dispatcher, then the Subscriber Agent checks the message (Step 3) and decides if the message m1 (which can be m or a modified version of m) should be sent to the subscriber or not, according to its policy (Step 4).

    Text Box:  Figure 1: The architecture of the SUBLIM Server.

    CASE STUDY: INTENSIVE CARE UNIT IN A LARGE HOSPITAL

    Consider for example a large hospital with an Intensive Care Unit. The patients are monitored continuously using specialized devices. For simplicity, we assume that the monitoring devices generate, for each patient, the following types of data: patient ID, pulse (P) and electrocardiogram (E).

    Each doctor is responsible for a certain number of patients, identified by the patient IDs. The doctor wants to receive the messages according to the following policy, denoted by PICU-Stateless:

  • The doctor is interested in receiving all of the data (P and E )for the patients he is responsible for.
  • If the Pulse of a patient goes beyond a certain threshold, he is interested in getting all of the information for that patient, even if the patient is not his responsibility.
  • This policy will work very well in a wired environment, where the issues of low quality network connection, display size or energy supply do not exist. It is the thesis of this paper that, in a wireless environment, the current publish-subscribe paradigm will not be able to handle the dynamic changes in the quality of connection or energy supply. Intuitively, if many packets are sent to a client with a low bandwidth network connection, it might happen that, due to the congestion of the network, the client will not receive the most important information, (the pulse in this case) because the packets are dropped or delayed long enough to make the information irrelevant. The same argument can be made for the battery utilization. Receiving large amounts of data when the battery is low will reduce dramatically the availability of the service in real-life conditions.

    Ideally, the doctor would like to receive all of the data for the patients he is responsible for, if he has a good network connection and the battery is charged. However, if the network connection deteriorates, he would like to be sure that he receives the most important data (such as the pulse) and maybe compressed versions of the least important data, even with loss of information such as the E. The same thing applies for the battery utilization. Similarly, the doctor will want to receive as much information as possible when the battery is charged, but only the most important data when the battery is low. Moreover, if the battery is very low, he would like only a summary of the state of the patients, at a regular interval of time. This leads to the following formulation (in an informal manner) of the policy PICU, suitable for mobile systems:

    R1: The doctor is interested in receiving all data (P and E) for the patients he is responsible for if the network connection is good and the battery is charged. The electrocardiogram should not be bigger than the display size of the device used by the doctor.

    R2: If the battery utilization goes beyond 75%, the doctor is interested in obtaining P and compressed versions of the electrocardiogram (E), with the compression ratio dependent on the battery utilization. When the battery goes beyond 25%, the doctor is only interested in the pulse (P) every five minutes.

    R3: If the network connection deteriorates, the doctor is interested in getting the pulse P and compressed versions for the electrocardiogram (E).

    R4: If the pulse of the patient goes beyond a certain threshold (let us say 50), the doctor is interested in getting information about that patient according to rules R1-R3.

    The state for this policy has three automatic variables: Battery, NetworkConnection and DisplaySize. We will detail in Section 6 how the system maintains the values for these variables; for now we can assume that the values are accurate.

    An implementation for PICU is presented in Figure 2. Each of the rules is followed by comments (in italic) that, together with the following discussion, should provide enough understanding of the nature of our policies.

    The first three lines of the policy deal with getting the current values for the automatic variables. We then create a new message and obtain the data associated with the received messages (Rules 4-5). If the doctor is not responsible for this patient and the pulse is good, the message is just discarded by returning a NULL message (again, details on how the policy determines if the patient is within the responsibility of the doctor are given in Section 6), as shown in Rules 8-9.

    If the battery is very low (below 25%), only a part of the message (the pulse) will be send to the subscriber every five minutes. This is done by using a manual variable, Timestamp, as shown in Rules 12-24.

    Otherwise, the content of the message is changed based on the current values of the battery, network connection and display size. In the current implementation, the SUBLIM server provides the compress method, but customized methods can also be implemented in the subscribers policies.

    Text Box: arrived(Message m, State s) :-
/* First get the values for the automatic variables */
1.	battery=s.getProperty(“Battery”);
2. networkConnection=s.getProperty(“NetworkConnection”);
3.	displaySize=s.getProperty(“DisplaySize”);
/* Create a new message and obtain the data associated with the received message */
4.		Message newMessage=createMessage();
5.	pulse=m.getPulse;
6.	patientID=m.getPatientID;
7.	if (pulse > 50 and !isResponsable(patientID))
/* The doctor is not responsible for this patient and the pulse is bigger than 50. Just ignore the message*/
8.		return NULL;
9.	endif
/* If the battery is very low, send only the pulse every five minutes */
10.	if (battery<0.25)
11.		currentTime=getTime();
12.		oldTime=s.getProperty(“Timestamp”);
13.		if (oldTime==NULL)
/* The variable does not exist. Initialize it now */
14.			s.setProperty(“Timestamp”,currentTime);
15.			return NULL;
16.		endif
17.		if (currentTime-oldTime>5*60)
18.		s.setProperty(“Timestamp”,currentTime);
19.			newMessage.setPulse(pulse);
20.			return newMessage;
21.		else
22.			return NULL;
23.		endif			
24.	endif
25.	newMessage= compress(m,battery,displaySize,networkConnection);
26.	return newMessage;

Figure 4: The implementation of PICU.



    Download



    The SUBLIM software is available for download as an open-source project. It currently runs on Windows and Linux.

    Requirements


  • Linux: No special requierements for the server and publisher (the jpeg library has to be installed on Linux. If not, you can use the one from the package and compile it by yourself). For the subscriber, the kernel has to be compiled with APM support. To support other power management systems, just modify the function GetBatteryPercent from the SublimClient class (in Subscriber/SublimClient directory).


  • Windows: To compile the server and the publisher, you need the Borland BC55. You can download it for free from Borland (You have to select the free command line tools). If this is unavailable, you can download it from here . Please use this link only as a backup, since it is not stable. For the Subscriber you need the Embedded Visual C++ from Microsoft. You can download it for free from Microsoft . The software was tested with the version 3.0, the current version is 4.0. If the download from Microsoft does not work, you can try from here . Additionally, you need the imgdecmp library (for showing the jpeg files). Maybe because of a bug in the distribution of the Visual C++, the header file was not included. Please take it from here and copy it to the include directory (C:\Windows CE Tools\wce300\MS Pocket PC\include on my computer).
  • Download the Software


    Download it in a Windows style zip file sublim.zip

    Download it in a Linux style tar file sublim.tar.gz

    Being free does not mean it is not maintained. Please e-mail me if you have any questions, found any bugs, etc.

    Publications



  • Mihail Ionescu and Ivan Marsic, Stateful Publish-Subscribe for Mobile Environments,   In Proceedings of the ACM WMASH 2004, Philadelphia, PA, October 1, 2004.