Appendices - Google Code

guitarchanceSoftware and s/w Development

Aug 15, 2012 (4 years and 10 months ago)

410 views


Event Delivery Gateway



1.0




Page
1

of
24





Event Delivery Gateway

by

Xiaobo Deng, Xiaoqi Lei, Yujie Song

Supervisor:
Selo Sulistyo

Project report for
IKT419

in
Spring

2
010



University of Agder

Faculty of Engineering
and Science

Grimstad,
15 March 2013

Status:
Final


Keywords:

Gateway, Event, UPnP, P2P
, Sun SPOT

Abstract:


The aim of this project is to design a gateway to deliver an ev
ent from one network to another
.
The system has to
prove that

it is possible that the gateway can resolve the problem that we are
facing.


We
have
to d
efine several use cases of UPnP

b慳a搠abBp Eai獴ri扵t敤
b
v敮t
-
B
慳a搠
p
y獴敭猩
慮搠im灬敭敮e 潮e of
t桥m
K

A
渠敶敮t w慳a桡灰敮敤

i渠潮攠湥tw潲o
I m潮it潲楮g 捯m
灯湥湴
fi湤
s

it 慮搠try t漠獥st it t漠t桥 gat敷慹I t桩猠g慴away will tr慮獭it t桥 敶敮
t

to
a

g慴敷慹 w桩捨c
扥l潮g猠t漠慮ot桥r 湥tw潲kK A湤 獯m攠r敡捴iv攠慣瑩a渠w潵l搠扥 tak敮 捯rr敳e潮d
i湧

to v慬略 潦o
t桥 獰s捩fic fi敬搠df t桥 ev敮tK

T桥 g慴敷慹 捡c r敳elv
攠 t桥 灲潢pem
s

in
d
i獴ri扵t敤 敶敮t
-
扡獥s 獹st敭e
K j慩湬y f潲 t桥
捯浭畮i捡ti潮
pr潢l敭e
扥tw敥渠nw漠湥ow潲os


te 慬獯s捡c 捯m灡re diff敲敮捥
s

扥tw敥渠
t敢 獥牶i捥

慮搠m㉐ t散en潬潧y w桩捨c慲攠扯th
捡c 扥 畳ud i渠t桥 im灬敭敮eati潮 of t桥 gat敷ayK



This work is licensed under the Creative Commons Attribution
-
ShareAlike License (http://creativecommons.org/licenses/by
-
sa/2.5/).


Event Delivery Gateway



1.0




Page
2

of
24


Version Control

Version
1

Status
2

Date
3

Change
4

Author
5

0.5

DRAFT

2
5

May

10

Introduction, theory, Implementation

Xiaobo Deng

0.6

DRAFT

28 May 10

Use case
,

Su
n
SPOT

Implementation

Xiaoqi Lei

0.7

DRAFT

28 May 10

Discussion, Conclusion
, Abstract,
Preface

Xiaobo Deng

0.9

DRAFT

28 May

Modify

Everyone

























1


Version

indicates the version number starting at 0.1 for the first draft and 1.0 for the first review version
.

2


Status

is DRAFT, REVIEW or FINAL

3


Date

is given in ISO format: yyyy
-
mm
-
dd

4


Change
describes the changes carried out since the previous version

5


Author

is the one who did the change


Event Delivery Gateway



1.0




Page
3

of
24


Preface

The project “Event Delivery Gateway” is part of IKT
-
419 course. It was proposed by Selo Sulistyo
and we
buil
t

up the group. We
ha
d

regular meeting
s

with our supervisor

to discuss about the
project. We also
ha
d

unofficial meeting with our su
pervisor when we encountered big problems.


We would like to thank Selo Sulistyo who proposed this project for providing the equipments for
us and for the support he provided during our
project. We also want to thank J
an Pettersen Nytun
who gave us good su
ggestion
s

about
the
presentation.



Grimstad

May 2010

Xiaobo Deng, Xiaoqi Lei, Yujie Song


Event Delivery Gateway



1.0




Page
4

of
24


Contents


1

Introduction

................................
................................
................................
...................
6

1.1

Problem statement

................................
................................
................................
...
6

1.2

Prob
lem solution

................................
................................
................................
......
6

1.3

Report outline

................................
................................
................................
...........
6

2

Theoreti
cal background

................................
................................
................................
7

2.1

Sun SPOT

................................
................................
................................
................
7

2.2

UPnP

................................
................................
................................
.......................
8

2.3

CyberLinkForJava

................................
................................
................................
....
9

2.4

P2P and
Web service

................................
................................
.............................

11

3

Solution

................................
................................
................................
......................

13

3.1

Requirements

................................
................................
................................
.........

13

3.2

Design S
pecification

................................
................................
...............................

13

3.3

Implementation

................................
................................
................................
......

15

3.4

Validation and Testing

................................
................................
............................

19

4

Discussion

................................
................................
................................
..................

21

5

Conclusion

................................
................................
................................
..................

22

Appendices

................................
................................
................................
..........................

24



Event Delivery Gateway



1.0




Page
5

of
24


Figure List


Figure 2.1
-
1 Sun SPOT devices

................................
................................
................................
..

7

Figure 2.3
-
1 Device class diagram

................................
................................
...............................

9

Figure 2.3
-
2 Control point class diagram

................................
................................
....................
10

Figure 2.4
-
1 Architecture of web service

................................
................................
.....................
11

Figure 3.2
-
1 function design specification

................................
................................
...................
13

Figure 3.2
-
2 Intel UPnP device

Device Spy and Network Light

................................
................
15

Figure 3.3
-
1 Sun SPOT java code of user_setup

................................
................................
........
15

Figure 3.3
-
2 Sun SPOT java code of sample

................................
................................
..............
16

Figure 3.3
-
3 Sun SPOT java code of starting application

................................
............................
16

Figure 3.3
-
4 device type variable in control point

................................
................................
........
17

Figure 3.3
-
5 java code

of eventNotifyReceived method

................................
..............................
17

Figure 3.3
-
6 java code of transfer a SSDP packet into a string

................................
...................
17

Figure 3.3
-
7 java code for starting a P2P application

................................
................................
..
18

Figure 3.3
-
8 java code for sending event

................................
................................
....................
18

Figure 3.3
-
9 java code for receiving event

................................
................................
..................
18

Figure 3.3
-
10 java code for invoking display() method

................................
................................
19

Figure 3.3
-
11 java code for sending event to UPnP devices

................................
.......................
19

Figure 3.3
-
12 java code for receiving the event

................................
................................
..........
19

Figure 3.4
-
1 test 1

gateway test

................................
................................
...............................
20

Figure 3.4
-
2 information which received by gatesway

................................
................................
.
20



Event Delivery Gateway



1.0




Page
6

of
24


1

Introduction

1.1

Problem statement


Event processing has become the paradigm of choice in

many monitoring and reactive
applications.

An event based system is software in which event cause reaction.
Mainly there are
three important parts in these event
-
based systems which are monitoring component,
transmitting component and reactive
reacti
ng

component. These event based system
s

are
devel
oped in many domains

[
1
]
.


An event was de
fi
ned by Chandy

as a signi
fi
cant change

in the state of the universe.

So any
state change in our
universe

can become the event

like temperature change, lighting
intensity

change and objects’ mov
e
ment

[
1
]
. WSN

(Wireless Sensor Network)

is a
typical technology

used
in the system as monitoring component

to collect these events
.


In most applications, the reaction part is not in the same network with the monitoring component.
So it is necessary to connect them together.


There are more and more devices appearing in modern life. In order to share the resources on
different types of

devices, UPnP techno
logy

is created
. The basic idea of UPnP technology is to
let the device
coordinate

with other devices which are in the same network.


UPnP device will send different messages and events to other devices and control points.

So

a
n

UPnP

device can inform
other UPnP devices about
what it capable of, the control point also can
send control action to device.

When more and more devices join into the network, lots of
message
s

and event
s

will
be
transmit
ted

on the network.
It may cause t
he
netw
ork overloaded.

At the same time, it is possible that
different

UPnP network
s have the

need
s

of

communicat
ing

with each other to exchange information.


1.2

Problem solution

The situation
mentioned

above

request
s

a
gateway

system

to control the events.

Through

configuration
,

gateway determines the events
which

would be sent out.

A

gateway is a
n

UPnP
controller receive
s

event
s from UPnP device
and delivers

events

as well
.


The g
ateway

also takes

the
responsibility

to communicate with the gateway which belongs to
another
network
.

It shares the information with other network
s
.
With the help of the gateway,
UPnP network can send and receive specific event
s
.



1.3

Report outline

Chapter

1 is the introduction about problem
statement and the solution for it. Then
C
hapter
2
illustrate
s

the theories that would be used in this project. Chapter 3 is the implementation details
of the system

which includes requirements and design specification
.

Then
Chapter 4
is the
discussion about this system.
The final chapter

is

the conclusion for this project.



Event Delivery Gateway



1.0




Page
7

of
24


2

Theoretical b
ackground

2.1

Sun

SPOT

Sun SPOT(Sun Small Programmable Object
Technology
)

is a wireless sensor network mote
development by Sun Microsystems

[
2
]
.

The basic unit includes
some sensors and inputs and
outputs.


The development

tool

provides
two spot device and base station.

We can see the device in


Figure
2.1
-
1
.


Figure
2.1
-
1

Sun SPOT devices

There are three sensors on SUN SPOT device: temperature sensor, light sensor and accelerator
sensor.

Temperat
ure sensor can detect the environment temperature value and return it back as
Centigrade or as
Fahrenheit.

Light sensor return the light tense from 0 to ***[Need to be done to
specification]. The accelerator detects
movement of

three dimensions.

This

information can be sent
by wireless connection

to base station
.

Developer can program on base station to get this data and
sent it to the application on devices like computer with USB interface.


Developer can program on Sun SPOT by using the Sun SPOT API
. Sun SPOT API is based on
Java and integrates virtual components corresponding to real device
. The
developer can
implement

their
own systems by these resources.


Sun Microsystems provides Sun SPOT Manager Tool to help developer to develop their own
system

based on Sun SPOT. Sun SPOT Manager Tool integrates mainly 5 tools.


1.

T
utori
al in the tools introduces
the structure of the device and shows the functionalities of
each part. You can find the detail explanations for typical sample code. It also gives the
d
eveloper the steps of creating a application.

2.

Sun SPOT upgrades the firmware of the Sun SPOT device. The device’s information can
be check here.

3.

You can install SDK in SDKs part. All the relevant documents can be found here including
SolariumUserGuide and
SunSPOT
-
Ownermanual. And you can find tutorials for all
sample code.


Before you install the manage tool, you have to install JDK/JRE on your computer first. So the
program depends on Java can be executed.


Event Delivery Gateway



1.0




Page
8

of
24


When you install the manager, it recommends you t
o install ANT. ANT is a build and deploy tool
to help the developers to organize their work. And developer can use
ant

var

to deploy code to
the Sun SPOT device.


In addition, Sun SPOT Netbean
s modules

can enable programmer to program under

Netbeans
and
deploy

the program to Sun SPOT device directly.


2.2

UPnP

UPnP™ technology defines
architecture

for pervasive peer
-
to
-
peer network connectivity of
i
ntelligent appliances, wireless
devices, and PCs of all form factors. It is designed to bring easy
-
to
-
use,
flexible, standards
-
based connectivity to ad
-
hoc or
unmanaged networks whether in the
home, in a small business, public spaces, or attached t
o the Internet. UPnP technology
provides
a distributed, open networking architecture that leverages TCP/IP and Web
technologi
es to
enable seamless proximity
networking in addition to control and data transfer among networked
devices

[
3
]
.


Unlike most devices these days that need installing driver before it can be us
ed, an UPnP based
device can join a network, get the IP address, discover other device and inform its capabilities,
get and execute control action from control points. And this device can remove from the network
dynamically.


In order to make the dynamical plug and play,
six important procedure of UPnP device

have to
be paid attention

which are: addressing, discovery, description, control, event notification,
presentation.


Addressing

IP addressing is the foundation of UPnP. Ea
ch device need to search and find out a DHCP
server to request an IP address. If the
DHCP server doesn’t exist, this network is unmanaged
and the device must assigned itself an address. This procedure that the UPnP device assigns
itself an IP address is kn
own as AutoIP.


Discovery

When a new device joins to the network, it will advertise its device and service information to the
control points on the network. Similarly, when a control points is add to network, discovery
protocol enable the control point to
search the interest device.


The SSDP (Simple Service Discovery Protocol) is used in this procedure. The device (includes
device and control points) could send SSDP packet to network. In the packet, there are many
parameters to indicate the device informat
ion. USN is the unique identifier of the device and
NTS indicate the state of
SSDP

service and so on.


Description

Discovery enables control points to find the device while there is not enough information in SSDP
packet.
So description makes control point

learn more about the device

and the service
.
The
control point

will find the
device’s capabilities

by the UUID which existed in SSDP packet.


Control

A control point
get the service of
UPnP

device can provides by description step and it can invoke
the act
ions and receive response from the device. Control
point posts an action to the device,
and waits

for the executed result or error message.



Event Delivery Gateway



1.0




Page
9

of
24


Event notification

A description file is consisted of list of actions and list of service.
The service
publishes

state
updates when the
value of states changes
.

T
his updates will be sent as event message and the
subscriber receive and process it.

The message contains one or more state variable and the new
value of the state.


Presentation

Presentation exposes an HTM
L
-
based user interface for controlling and/or viewing device status

[
3
]
.


A control point can retrieve the device’s information and service and display them on the HTML
page according to the
URL which
gets

by precious step.


2.3

Cyber
LinkForJava

CyberLinkForJava is
open source
framework which
is
used to develop
UPnP applications. It
provides virtual device and control points as well as many listeners to help developer.


Cyb
erLinkForJava uses KXML and
X
erces
as its XML parser, so you have to import the library to
your project before you implement you own system.


It provides two kinds of device which
are

Control Point and Device
.


Divice


Figure
2.3
-
1

Devi
ce class diagram

When you want to create your own UPnP device you have to make description file. In the
description file for device, the uuid should be assigned and URL for service description file ha
s

to
be marked
, the presentation URL is optional.
And ne
w device is create by this description file like
this:

String descriptionFile = “description/description.xml”;

Device upnpDevice = new Device(descriptionFile);


And you have to start the device by the code:

upnpDevice.start();


The

device begins

t
o sen
d

notify packet to network.


Event Delivery Gateway



1.0




Page
10

of
24



In the
service description file, actions are seals in actions. The state variable in this file is used to
post an
event.


You can get you service by the code:

ServiceList serviceList = upnpDev.getServiceList;

For(
int index=0;
index<serviceList.size(); index++
){

Service service = serviceList.getService(index);

ActionList actionList = service.getActionList();

//get action by interator

……

}


To receive the control point from control point, upnp device have to implement ActionListe
ner
interface as well as actionControlReceived() method.

When device want to sent its state to the
subscriber, it has to get the stateVariable first and set the value to it, then this event would be
updated to the control point.


Control Points

Figure ***
is the class diagram for cyberLink UPnP control point.


Figure
2.3
-
2

Control point class diagram


One

of difference between control
point and device is that there is no description file for control
point,
you can create control point like this:

ControlPoint ctrlPoint = new ControlPoint();


And start it by

ctrlPoint.start();


To receive notify event from device, control point
implement NotifyListener interface and
implement deviceNotifyReceived() method.
So all information in the packet can be get by :

String uuid = ssdpPacket.getUSN();

String target = ssdpPacket.getNT();

String location = ssdpPacket.getLocation();



Event Delivery Gateway



1.0




Page
11

of
24


Control point knows the new device and removed device by adding DeviceChangeListener. The
m
ethod deviceAdded(Device dev) is for a new device notify and deviceRemoved() method is for
the removed device sending byebye message.

2.4

P2P
and
Web service

P2P techbology

A peer
-
to
-
peer, commonly abbreviated to P2P, is any distributed network architecture co
mposed
of participants that make a portion of their resources (such as processing power, disk storage or
network bandwidth) directly available to other network participants, without the need for central
coordination instances (such

as servers or stable hos
ts)

[
4
]
.


In the P2P network, there is no typical server and client

but
coordinate

peer node
s
.

Each
participant
shares

its

resources.

As a new node join in the network, the capacity of the network
increase. While in the traditional server
-
client architecture, a new client means asking for more
resources from the server.

P2P technology is used to
distribute

calculating
. The big task wil
l split
into small ones by distributed algorithm and hand out to the peer nodes. Each node take the task
and return the result.


P2P application can get through the firewall of the network and so it can be a communication tool
between two networks.


Web
service

WebSerivce is a technology that enables the client access the service from remote endpoint.
Service
provider publishes

API (
Application Program Interface)
.


Basically there are 3 role
s

in
Web service

architecture which shown in Figure ***
. Service

provider creates some services and registers

these services on register server. When service
requester sent service request to the register server, server will return the WSDL (Web Service
Description Language) to identify the location of the service. The

WSDL are always shown as a
HTTP link. Service requester can send parameters according to this URL. Service provider
process the request and return result to this requester.


Figure
2.4
-
1

Architecture of web

service


We can use JAX framework to implement
web service

application with Eclipse. And we can
create a
web service

client to test the service.


In our system, we need to transmit the event immediately when the event arrives. The problem is
we have to s
tart the web service separately
. More importantly, there are many limits for the

Event Delivery Gateway



1.0




Page
12

of
24


service which would be published, while P2P technology does have those limits. And that is the
reason why we choose P2P technology rather than
web service
.





Event Delivery Gateway



1.0




Page
13

of
24


3

Solution

3.1

Requirements

Functional requirement
:


1.

Get environment information and sent it to UPnP device

by Sun SPOT device
.

2.

Create UPnP device which can

receive specific data
s
.

3.

Create
a
gateway which can

receive the event and transmit

it

to the other gateway.

4.

Create a gateway which can receive the data and
encapsulate the data to an packet
.

5.

Create a control device which can send control action.

6.

Create a
n

UPnP device which can receive control action.


Non
-

functional requirement (assumption
s
)

1.

There is only one g
ateway in a network and this gateway does not take the responsibility
of managing this network.

2.

There are only two gateways in this system and the data transmission is just between
these two gateways.

3.2

Design
Specification

3.2.1

Functionality
Design

As

shown

in
Figure
3.2
-
1
.

T
here are mainly three part
s:

network 1, network
2
and transmission
part.


In
network one, Sun SPOT collect information like temperature and sent it to
the UPnP device
that we create. The UPnP device will encapsulate this information into SSDP Packet and send it
out.

The event listener of gateway will get the relevant information. Gateway will sent them out by
P2P technology.
Gateway2 will get the packet
and control UPnP device according to the packet.


Figure
3.2
-
1

function design specification

3.2.2

Use cases

Before we implement the gateway application, we
define

some

event based

use cases.


Baby Take Care
System

The Baby Take Care System consists of a set of sensors, a control system, and some end
point
devices. It will be needed when the parents are not in the same room with the baby.


Event Delivery Gateway



1.0




Page
14

of
24


There will be a sound sensors monitoring if the baby is crying and a
n

ac
celerometer sensor
monitoring if the baby is sleeping in peace. Once it monitored the baby
doesn’t sleep

very well, it
generates

events via the control system to notice parents in another room by alarming. And it
could play some music and turn on the light

in the baby's room as well.


Auto Switching TV System

The Auto Switching TV System will automatically switch the playing TV set to the room where the
house owner stands. There should be some TV in different rooms,
controlled

by the controller.
And there should be some radio receivers in each room receive the signal of the micro
radio
transmitter

brought by the user to
monitor

the position of the user.


Once the user moved from room A to room B, a switching event will be gener
ated from the room
A and send to the TV controller in room B to open the TV in the same channel. Once the TV in
room B is opened
successfully
, another event will be generated in room B, and notice the TV in
room A to shut down.


Remote B
urglar
-
P
roof

& Alar
ming System

The
Remote B
urglar
-
P
roof

& Alarming System

consists of some sensors, cameras, some
terminal devices and
an

event based system, to protect your home from burglars.


Once the user's house door is opened by others, an alarm will be to the
user's

m
obile device
wherever

he is. And if he
wants
, he can watch the
real
-
time

video through the camera to judge if
the door is opened by strangers. If it is, the user can choose to turn on the speakers in his home
to persuade the strangers to leave, or he can r
eport to the police.



3.2.3

Discuss the software tools that are to be used during the implementation

E
clipse/Netbeans

Eclips
e and Netbeans both can be used. While Sun SPOT Manage tool provides corresponding
develop modular which enable Netbeans
to deploy the
programme to the Sun SPOT device
directly.

So it seems better to choose Netbeans, but that’s not so critical in our project.


Developer Tools for UPnP™ Technology

The Developer Tools for UPnP™ Technologies is a set of development and reference tools for
creating software that is compatible with the UPnP specifications. These tools includes generic
devices and control points, stack generation tools and UPnP AV debug and reference
tools.
[

http:/
/opentools.homeip.net/dev
-
tools
-
for
-
upnp
]


In this tool kit, there are many tools like AV Media Renderer, AV Media Server, Device Spy and
Network Light.


Device Spy can find UPnP devices which are in the same network. The devices services are
displayed an
d can be invoke to control the device. As shown in

Figure
3.2
-
2
, the network light
has been started, so the Network Light can be found in the
Device S
py. There are two

different
services on this light: Dimming service and Switch Power service. Dimming service can be used
to adju
s
t the tense of the light while switch power service can be use to turn on the light or turn
off it.



Event Delivery Gateway



1.0




Page
15

of
24



Figure
3.2
-
2

Intel

UPnP device

Device Spy and Network Light

So when you click the invoke button and set the variable value, and control event will send out.
The state of the light would be changed.

3.3

Implementation

3.3.1

Monitoring component

The
application to drive SunSPOT device consists of 2 parts: on SunSPOT and on host.

There is
an event based framework inside the SunSPOT sensor network.
T
he SunSPOT
device
generates and sends

events to the host through the base

station by radio. And once the
events
are received by host, they are extracted and processed in advance.


The
application implemented on the SunSPOT has

2 important classes: Sensor and MIDlet. The
MIDlet class is the entrance of the application running on SunSPOT, and it
accesses

the se
nsor
through the class Sensor.


In our case, the Sensor class is extended to EDemoBoard class, the
user_setup()
method is
used to access the sensor and store the value.
A
nd the
sample()

method is used to
encapsulate

and send the data.


Figure
3.3
-
1

Sun SPOT java code of user_setup


Event Delivery Gateway



1.0




Page
16

of
24



Figure
3.3
-
2

Sun SPOT java code of sample


And the MIDlet class is extended to
StartApplication

class. The startApp method will be
automatically called
by the VM to start the application.

In the startApp method, we monitor the
connection to the host and the command from the host, and routinely generate events with the
information provided from the E
DemoBoard class.


Figure
3.3
-
3

Sun SPOT java code of start
ing

appl
i
cation


In the host application, we use
SensorFramework.getInstance().registerNodeEventListener(
)
method to register a class as the event li
stener, and then we can extract the information and
process the data.


3.3.2

Transmit component

We use P2P technology to transmit data from one gateway to another. The reason we choose
P2P technology but not
Web service

is that P2P technology is more suitable fo
r this application.


When WSebService is developed by My
E
clipse, the
service has

to be started running separately
as a service.
And there are some limits in
Web service

which are become the barrier we integrate
the service. P2P technology is better to use and
flexible.


Step 1
:

Receive the event.


In order to receive the event sent by UPnP device, gateway has to implement

some

Listeners
such as NotifyListener, EventListe
ner and SearchresponseListener.



Event Delivery Gateway



1.0




Page
17

of
24



Figure
3.3
-
4

device type variable in control point


Also we have to implement
eventNotifyReceived
()

method to get the data. As shown in Figure *
**,
we can get uuid, sequenc
e number,

variable name and the value.
The service can be got by uuid
which is the Universal Unique Identification for the service. And we can get the device by the
service. The SSDP Packet sent by the device can be
got

by the device. We need to transmit t
his
packet to anther gateway.


As
P2P technology can sent string type and do
cument type but not SSDP packet, so we have to
find another way to transmit it.


Figure
3.3
-
5

java code of eventNotifyReceived method


Finally, we

find that we can transfer the packet into a string and then repacked it. We know that
the transferred string is the data part of the packet

from the code below, which means we can put
this string into t
he data part of new SSSP packet on the other side.


Figure
3.3
-
6

java code of transfer a SSDP packet into a string



Step 2
: Establish service pipe

First, we need to create network manager
.
//Get the details
of P2P .


Event Delivery Gateway



1.0




Page
18

of
24



Figure
3.3
-
7

java code for starting a P2P application


Step 3 Send event


Figure
3.3
-
8

java code for sending event


Step 4 Receive the event





Figure
3.3
-
9

java code for receiving event


Event Delivery Gateway



1.0




Page
19

of
24


3.3.3

Reactive component

Reactive component is the third partial of the system. In the domain, the gateway will broadcast
event to the UPnP network
. All devices in this n
etwork will receive the event and only the display
equipment will process the event.



So first we need to get the event information. In order to extract the string out, we use commas to
divide the message. Method sendEvent(String str) can make it happen a
nd set each parameter
into an array.


Figure
3.3
-
10

java code for invoking display() method


In the gateway we create new device called gatewayDev to sen
d
the state variable.



Figure
3.3
-
11

java code for sending event to UPnP devices


In DisplayDevice, the code shown in Figure ** implement
the eventNotifyReceived() method.

So the DisplayDevice can get the message which would be shown on the display.



Figure

3.3
-
12

java code for receiving the event

3.4

Validation and Testing

TEST 1
: Test the gateway works

At this step, we use I
ntel network device to send event. First we need to start the two gateways.
When
we run th
e light, a

new device notify was sent out. In this message, UUID is unique

identification of the service and the extra data “
-
5” is to identify the each message. And the status
is the variable
name and “0” is the value of the variable.



Event Delivery Gateway



1.0




Page
20

of
24




We can find the
network
light in Device Spy, and invoke the Set Target method. The state
of
Network

Light would be changed.



Figure
3.4
-
1

test 1

gateway test


The event will be receive by the gateway and sent it to another

gateway. Figure *** shows the
data of the SSDP Packet. The gateway receives this data as a string and will set it into a new
SSDP packet.


We also can see the uuid and value at the end of the message, and the value will be pick out
from it.


Figure
3.4
-
2

information which received by gatesway




Event Delivery Gateway



1.0




Page
21

of
24


4

Discussion

Basically, there are two parts in our proje
ct which have to be implemented:

1.

Design a gateway which can use to delivery event between two networks

2.

Choose a
pplication to test the gateway.


First we need to choose the technology for the gateway.
We can choose P2P or
Web service
.
Sun Micorsystems create JXTA framework for P2P application, it has proved that JXTA is a well
-
design and easy to use technology. And
that is the reason why we choose it. The advantage of
Web service

is that
client can access the service by HTTP link. So it is easy to
implement the
client while it increases the complexity on the server side.

And we encountered an unkn
own error
when we cr
eate a

web service for this application.
It is hard for us to integrate the
web service

into our system.


CyberLinkForJava is the framework we chose for UPnP network. This framework provides APIs
to help us to create our own device. The only problem is the event cannot be sent out
by the
device even though we follow the instruction on the specification. After
that, we check the source
code about this function and find
the service use a HTTP request to send the value. We cannot
figure it out why the event send procedure doesn’t work. In order to continue our work, we
choose Intel UPnP device an alternative.
It p
roved that the gateway works. And the same thing
happened on the other network, so we cannot finish the use case.


In the final system, we can prove that the gateway is ready, but we cannot run the
application
completely because of the problem we cannot fix.





Event Delivery Gateway



1.0




Page
22

of
24


5

Conclusion

In this project, we need the design and implement a gateway. This gateway will transmit an event
from one network to another.

In order to emulate the function of gateway, we create

two UPnP
networks. Because we encountered a problem that we cannot resolved so we choose Inter UPnP
device as an alternative. And it is proved that the gateway works.


This project is only a simple

emulation of event delivery gateway. There are still a lo
t of problem
s

that need to be resolved.

1.

W

kind of strategy to divide UPnP device into different network

in a real application?

2.

How to
coordinate many gateways to let them work more efficient?

3.

How to make the gateway more flexible and
reliable?




Event Delivery Gateway



1.0




Page
23

of
24


Referenc
es

Follow the IEEE guidelines for references

see:
http://www.ece.uiuc.edu/pubs/ref_guides/ieee.html


[1]

H
iA, Bruk av kilder i skriftlige arbeider ved Høgskolen i Agder, August 2006,
http://www.hia.no/stud/eksam/kilder.htm


[2]

Peter J. Denning, Douglas E. Comer, David Gries, Michael C. Mulder, Allen Tucker, A. Joe
Turner, and Paul R. Young, Computing as a Discipline, Communications of the ACM,
Volume 32, Number 1, 1989


[3]

Check
http://www.ntnu.no/viko/
, which is very useful when writing reports.



Event Delivery Gateway



1.0




Page
24

of
24


Appendices


Appendix A


Glossary and Abbreviat
i
ons




Appendix
B (Detailed) Specifications (optional)


You may want to include
more (sets of) specifications than in the report body. You may have
Functional requirements in the body and Non
-
functional (not directly related to the user interface)
in the appendix.

Appendix C Design Documentation
(optional)

This
appendix may include documentation like program listings, schematic diagrams, drawings
etc


Appendix
D

Project Management (optional)


Include here a description of the project and how you organised it.

Answer the following questions
:



What is the project title, and who was the problem owner (external company)?



Who were the project participants?



How did you organize the project as a team, was there a project leader, did you have
separate roles in the project? How did you distribute the

work internally in the project: who
did what?

Did you cooperate with other teams?



Which milestones did you have? What dates?



If you have a cost budget, present it.



Is your project part of a larger project? What is the relation between the two?


Appendix
E Another Appendix


This is just to show you can have as many appendices as you like, but try to restrain yourself. Do
not include more details than necessary.


Finally, please note, that appendices are traditionally numbered by letters A, B, C and
so
on. Some newer templates use numericals, but academic tradition prefers letters.