Professional Documents
Culture Documents
ON
WEBRTC (CHATB)
&
SMS GATEWAY
By
Samish Bedi
(2012B3A7735P)
AT
A REPORT
ON
WEBRTC (CHATB)
&
SMS GATEWAY
By
Samish Bedi
2012B3A7735P
AT
ACKNOWLEDGEMENT
In todays world, any academic pursuit of a team requires contribution from various individuals.
We would like to thank our PS division at BITS-Pilani for providing us with the opportunity to
extend our horizons of knowledge by working for an organization of such stature.
I would also like to thank Prof. Jayashree Ramadas, the Director of HBCSE,TIFR for giving us the
opportunity to work in the organization, without her permission we would never have been able to
get the experience of such a great technical and office culture.
I am really thankful to my Supervisor, Dr. Nagarjuna G., for his invaluable guidance and
assistance, without which the progress of the task would have been impossible. I also thank him
for giving this opportunity to explore the programming and computer science world and realize
the sheer scope of open source softwares not only in Metastudio but as a viable alternative to
proprietary paid softwares.
My heart-felt thanks also go to my PS instructor, Dr. Bibhas R. Sarkar, whose continued support
and enthusiasm always kept my spirits up and kept me calm.
I would also like to thank Akshay Rao Hoshing, Student Co-Instructor, for motivating me to
pursue the knowledge contained within the premises of HBCSE with an open mind and giving me
impetus to look for it in the right places.
In the present report I have talked about the skills used, present progress and future scope of
development of the projects Integration of Chatb and Development of SMS gateway for
development of Metastudio being carried out in the gnowledge lab of HBCSE,TIFR.
I am also thankful to the Mentors and Research assistants especially Sunny Sir, Avadoot Sir Kedar
Sir and Johnson Chetty Sir working in gnowledge lab on development of various features of
metastudio, for welcoming me in the lab and for providing necessary clarifications whenever I was
in doubt.
In the end, I am also indebted to my friends in PS; Hemant Arora, my senior from Hyderabad
Campus and my project partner Ram Karnani, who shared their valuable thoughts and ideas with
me.
1|Page
2012B3A7735P |
SAMISH BEDI |
M.Sc (Hons.) Economics and B.E.(Hons.) Computer
Science
Dr. Nagarjuna G.
Developer gnowsys, glab incharge,HBCSE
Ph.D. in Philosophy of Science, IIT Kanpur.
M.Sc. in Biology, Delhi University
M.A. in Philosophy, Delhi University
Key Words:
Project Areas:
Entire project is based on open source technologies. Project is based on the metastudio
environment. The areas of the project are as follows:
Website development
Frontend:
HTML, CSS, Javascript, AJAX, jQuery
Backend:
Django, Python
Database Handling
Django-mongokit, Mongokit, MongoDB
Gateway Backend
Kannel backend with RapidSMS framework
2|Page
Abstract:
Metastudio as a result of the co-ordinated operation of numerous applications and
features is being developed on various specific aspects to facilitate open source and free
access to online education. Thus, a proper mechanism is needed to deal with the
development various softwares and technologies. This is what the Gnowledge lab of
HBCSE works for. The underlying principle of the metastudio website is semantic
computing. It aims at forging a knowledge graph with the help of the users themselves.
This graph in its most developed stage would be self sufficient to be used as a self-teaching
tool by a user.
This report gives a basic overview of the projects-Integration of Chatb with metastudio
and development of SMS gateway for metastuido, and the various technologies that work
behind the scenes. The project is divided in two phases. The former phase dealt with
Integrating Chatb with Metastudio .This part of the project has been successfully
implemented. It included running Chatb and designing a backend and front end interface
for users to have private as well as group meetings. We have implemented the features to
conduct on the spt as well as scheduled meetings. Second phase is developing and
integrating a reliable and efficient SMS gateway to facilitate metastudio users the access to
portal through mobile phones. This is a big ongoing project. Till now a major portion of
basic backend of SMS gateway for metastudio has been developed with many features
still in progress.
Samish Bedi
Signature of student
Signature of PS Faculty
Date: 17/07/2014
Date: 17/07/2014
3|Page
TABLE OF CONTENTS
ACKOWLEDGMENTS -----------------------------------------------------1
ABSTRACT ----------------------------------------------------------------- 3
1.Introduction ------------------------------------------------------------------------------7
1.1 Motivation-------------------------------------------------------------------------------7
1.2 Homi Bhabha Centre for Science Education----------------------------------------7
1.3 Metastudio(gstudio)--------------------------------------------------------------------8
2. Projects------------------------------------------------------------------------------------9
2.1 Integration of WebRTC(Chatb) with Metastudio ------------------------------9
2.2 Developing an SMS gateway---------------------------------------------------------9
2.3 Objectives--------------------------------------------------------------------------------9
3. Prerequisites-------------------------------------------------------------------------------11
3.1 Python-------------------------------------------------------------------------------11
3.2 Django-----------------------------------------------------------------------------------11
3.3 GStudio----------------------------------------------------------------------------------11
3.4 HTML5----------------------------------------------------------------------------------11
3.5 Ubuntu-----------------------------------------------------------------------------------11
3.6 Mongodb--------------------------------------------------------------------------------12
3.7 RapidSMS-------------------------------------------------------------------------------12
3.8 Kannel Backend------------------------------------------------------------------------12
4. Integration of Chatb with Metastudio--------------------------------------------------13
4.1 Design of WebRTC--------------------------------------------------------------------13
4.2 Project Outline-------------------------------------------------------------------------14
4.3 User Interface--------------------------------------------------------------------------22
4.4 Scope of the project-----------------------------------------------------------------27
5. Development of SMS Gateway---------------------------------------------------------28
5.1 Functioning of the SMS gateway----------------------------------------------------29
5.2 RapidSMS at glance-------------------------------------------------------------------30
5.3 Installing RapidSMS-------------------------------------------------------------------31
5.4 Starting RapidSMS with gstudio environment---------------------------------31
5.5 Application Structure------------------------------------------------------------------32
5.6 Message Processing---------------------------------------------------------------------32
5.7 RapidSMS Backends--------------------------------------------------------------34
5.8 Kannel Backend-------------------------------------------------------------------34
4|Page
5|Page
TABLE OF FIGURES
Figure 1: Node types supported by gstudio-------------------------------------------8
Figure 2: Metastudio view after inclusion of Meeting app----------------------22
Figure 3:Meeting app interface--------------------------------------------------------23
Figure 4: New Meeting form view---------------------------------------------------24
Figure 5: Meeting details--------------------------------------------------------------25
Figure 6 : Meeting app view after scheduling a meet------------------------------25
Figure 7 : Tab view for instantaneous meet----------------------------------------26
Figure 8 : Basic model of a gateway------------------------------------------------28
Figure 9 : Basic prototype of SMS gateway----------------------------------------29
Figure 10 : RapidSMS gateway------------------------------------------------------30
6|Page
1. INTRODUCTION
The report starts with the brief description of the organization i.e. my P.S. station and
then proceeds by giving by deciding about the framework on which Metastudio works
and further the main concepts relating to project would be discussed.
1.1
Motivation
The main motive of our Chatb project is to enable quick, efficient and user friendly
communication between members of a group within metastudio. The major source of
inspiration for our project is Textb project done by our seniors, Hemant Arora and
Ruppesh Nalway last year. Nagarjuna Sir wanted a platform to conduct important
meets with fellow colleagues and students in distant places with ease and without the
use of proprietary softwares such as hangouts. Moreover the process had to be
integrated with gStudio framework and Metastudio user-interface. So with the help of
chatb and gstudio framework we introduced chatting and video conferencing features
into Metastudio.
The major motive for development of the SMS gateway is to provide potential users
access to metastudio especially to the undergraduate students who are taking the
digital literacy course and have never created mail accounts but have cell phones.
The earliest feature we ought to introduce is to make a user register at gstudio
(metastudio) without an email account by enabling him/her to fill in registration form
with his mobile number instead of email or both simultaneously, then a confirmation
code will reach the user through SMS or email depending on the option enabling
him/her to register using the code.
Thus, our project is motivated by the aim to provide an ease of access to
communicate and introduction of social networking platform on Metastudio.
1.2
7|Page
1.3
Metastudio(gStudio)
8|Page
2. PROJECTS:
2.1
2.2
The second project we have undertaken is the development of an SMS gateway for
metastudio.
SMS gateway allows a computer to send or receive Short Message Service (SMS)
transmissions to or from a telecommunications network. It typically sits between the
end user who needs to send/receive SMS and a mobile network's SMSC. We have
used the basic framework of RapidSMS for the SMS services. RapidSMS is a free
and open-source framework for rapidly building mobile services for scale. It is built
with Python and Django and is designed for building robust, highly customized
mobile services with web-based dashboards. It also provides a flexible platform and
modular components for large-scale data collection, managing complex workflows,
and automating data analysis.
2.3 Objectives
The major objectives of the work are:
1. Integration of Chatb portal with metastudio as an APP for metastudio members to
conduct P2P private as well as group meetings. It includes running Chatb on our
local servers and designing a backend and front end interface for users to have
private as well as group meetings.
2. A platform to conduct important meets with fellow colleagues and students in
distant places with ease and without the use of proprietary softwares such as
hangouts. Moreover the process is integrated with gStudio framework and
Metastudio user-interface.
9|Page
10 | P a g e
3. PREREQUISITES:
The requirements for the project include knowledge and technical know-how of
following:
3.1
Python
3.2
Django
Django is a free and open source web application framework, written in Python,
which follows the modelviewcontroller architectural pattern. It is maintained by the
Django Software Foundation (DSF), an independent organization established as a
501(c) non-profit.
Django's primary goal is to ease the creation of complex, database-driven websites.
Django emphasizes reusability and "pluggability" of components, rapid development,
and the principle of don't repeat yourself. Python is used throughout, even for
settings, files, and data models. Django also provides an optional administrative
create, read, update and delete interface that is generated dynamically through
introspection and configured via admin models.
3.3
GStudio
3.4
HTML5
HTML5 is a core technology markup language of the Internet used for structuring and
presenting content for the World Wide Web. HTML5 is a core technology markup
language of the Internet used for structuring and presenting content for the World
Wide Web.
3.5
Ubuntu:
Ubuntu is a Debian-based Linux operating system, with Unity as its default desktop
environment (GNOME was the previous desktop environment). It is based on free
software and named after the Southern African philosophy of ubuntu (literally,
"human-ness"), which often is translated as "humanity towards others" or "the belief
in a universal bond of sharing that connects all humanity. Ubuntu is composed of
many software packages, the majority of which are free software. Free software gives
11 | P a g e
users the freedom to study, adapt/modify, and distribute it. Ubuntu can also run
proprietary software. Ubuntu Desktop is built around Unity, a graphical desktop
environment. According to some metrics, Ubuntu is the most popular desktop Linux
distribution
3.6
Mongodb:
MongoDB is a cross-platform document-oriented database. Classified as a NoSQL
database, MongoDB eschews the traditional table-based relational database structure
in favor of JSON-like documents with dynamic schemas (MongoDB calls the format
BSON), making the integration of data in certain types of applications easier and
faster. MongoDB is free and open-source software. MongoDB is the most popular
NoSQL database system.
3.7
RapidSMS:
RapidSMS is a web framework based on the Django web framework which extends
the logic and capabilities of Django to communicate with SMS messages. Initial
development was done by UNICEF's Innovation Unit for use in mobile data
collection and polls. A side effect of the work was pygsm, a Python library for
interacting with GSM modems, including cell phones which handle the Hayes
command set.
3.8
Kannel Backend:
Kannel is a free and open source SMS gateway that can be configured for use with
RapidSMS. It is possible to configure Kannel to connect directly to USB or serial
GSM modems as well as third party HTTP or SMPP gateways. Kannel is also an
open source WAP gateway. It attempts to provide this essential part of the WAP
infrastructure freely to everyone so that the market potential for WAP services, both
from wireless operators and specialized service providers, will be realized as
efficiently as possible.
Kannel works as an SMS gateway for GSM networks. Almost all GSM phones can
send and receive SMS messages, so this is a way to serve many more clients than just
those using a new WAP phone.In addition, it also operates as Push Proxy Gateway ,
or PPG, making possible for content servers to send data to the phones.
12 | P a g e
4.1
Design of WebRTC
getUserMedia,
which allows a web browser to access the camera and microphone and to capture
media. Prompts the user for permission to use a media device such as a camera or
microphone. If the user provides permission, the successCallback is invoked on
the calling application with a LocalMediaStream object as its argument.
RTCPeerConnection,
which sets up audio/video calls. Basic RTCPeerConnection usage involves
negotiating a connection between your local machine and a remote one by
generating Session Description Protocol to exchange between the two. i.e. The
caller sends an offer. The callee responds with an answer. Both parties, the caller
and the callee, need to set up their own PeerConnection objects initially.
RTCDataChannels,
which allow browsers to share data via peer-to-peer. The Basic code for Data
Channels is:
var pc = new RTCPeerConnection();
var dc = pc.createDataChannel("my channel");
dc.onmessage = function (event) {
console.log("received: " + event.data);
};
dc.onopen = function () {
console.log("datachannel open");
};
dc.onclose = function (
console.log("datachannel close");};
13 | P a g e
4.2
Project Outline
This section of the report includes the various necessary procedures followed and
features introduced during the course of the project work:
I.
We have created a Meeting App Node of the GSystemType by using djangoframework in GStudio. In the terminal, following commands were used by to
create this GSystemType.
o
o
o
o
o
o
o
II.
We have also integrated video and text chat features on Metastudio using chatb
servers. We have used an iframe to connect to chatb servers and disply the video
and text chat options.
A card is created which contains the Start Meeting button on the click of which
chatb server is connected and video and text chat facility provided by the chatb is
displayed in the iframe.
The code for above mentioned operation is:
<div class="content" id="panel2-2">
<br/>
<br/>
<div class="create card">
<div class="chat">
<br/>
c
<a class="button medium"
href="https://chatb.org/#{{meetingid}}" target="Chatb">
<span class="start"> Start Meeting</span>
</a>
</div>
</div>
And the code for creating thr iframe is:
<iframe src="" name="Chatb" style="position:relative"
id="ifrm"
c
height="450em" width="100%" frameborder="1"> </iframe>
14 | P a g e
III.
if (Number(aa[i].status) ==1) {
str += "<tr><td>" + aa[i].user.username + "</td><td><img
src='/static/ndf/images/dot.jpg'
width=30em></td><td><input
type='checkbox' name='invite' id='"+ aa[i].user.username +
15 | P a g e
"'value='invite'>Invite</td></tr>";
var nam = "#" + aa[i].user.username;
prev.push($(nam).prop('checked'));
}
}
str += "</table>"
$("#res").html(str)
for (i=0;i<k;i++){
var nam = "#" + aa[i].user.username;
if (prev[i]==true){
$(nam).prop('checked',true);
}
}
}
});
}, delay);
});
Now the following code checks the Boolean value of the checkbox besides the
list of online users table and send invites to them using the function
invite_meeting in meeting.py file.
var aa ={{online_users|safe}}
k=aa.length
for (i=0;i<k;i++){
var usr = aa[i].user.username;
var nam1 = "#" + usr;
$(nam1).click(function(){
aaa = nam1;
$.ajax({
url:"{% url 'invite_meeting' group_sid meetingid
%}",
dataType:'json',
data : { "usr": usr},
success: function(data){
}
});
});
}
$("#node_search_form").parent().hide();
16 | P a g e
IV.
{% endif %}
<ul class="small-block-grid-1 medium-block-grid-2 large-block-grid-4">
{% autopaginate MEETING_inst 23 %}
{% for node in MEETING_inst %}
{% get_version_of_module node.pk as version %}
<li class="card">
<div class="course">
<header>
<div class="label-list">
{% for tag in node.tags|slice:":3" %}
<a href="{% url 'tag_info' groupid tag %}"><span
class="label">{{tag}}</span></a>
{% endfor %}
</div>
<div class="th"><img src="/static/ndf/scss/metastudio/logo.svg"></div>
<h4>{{ node.name|truncatechars:20 }} <font color =
"red"><b>Ver.</b>{{version}}</font></h4>
<div>
<small class="subheader">{{ node.member_of_names_list|join:', ' }}
created {{node.created_at|timesince}} ago
<br/>
by <span href="#" class="user" datagnow="">{{node.user_details_dict.created_by}}</span>
</small>
</div>
</header>
<p>{{ node.html_content|default_if_none:"Add some
description."|safe|striptags|truncatechars:75 }}</p>
<a class="small button expand" href="{% url 'meeting_details'
group_name_tag node %}">Detail</a>
18 | P a g e
VI.
We have introduced the feature of e-mail based notification in which the chat url
generated by the OBJECTID() of the meeting coordinator would be passed on to
the other online/scheduled meeting users through an e-mail.
The code in the meeting.py file helps us to send this notification. The
notification app has been used for this purpose. The key function included in the
meeting.py file for using this app is set_notif_val.The code looks like this:
def invite_meeting(request, group_id, meetingid):
try:
colg=col_Group.Group.one({'_id':ObjectId(group_id)})
groupname=colg.name
recipient = request.GET.get("usr","")
recipient = unicodedata.normalize('NFKD',
recipient).encode('ascii','ignore')
sender=request.user
sending_user=User.objects.get(username=sender).id
activ="invitation to join in meeting"
url_of_meeting = "http://" + str(sitename) + "/" + group_id + "/meeting/"
+ meetingid
msg="'This is to inform you that " + str(sender) + " has invited you to the
meeting of " +str(groupname)+" . Please click here " + url_of_meeting +"'"
ret=""
bx=User.objects.get(username=recipient)
ret = set_notif_val(request,group_id,msg,activ,bx)
if bx.id not in colg.author_set:
colg.author_set.append(bx.id)
colg.save()
if ret :
return HttpResponse("success")
else:
return HttpResponse("failure")
except Exception as e:
print str(e)
return HttpResponse(str(e))
20 | P a g e
VII.
We have also created HTML templates for Meeting App using gstudio source
code. This template includes the following essential parts :
The tab class has been included in the code which provides the user an
option to choose between the 2 tabs namely All Meeting-which displays the
list of all the meetings scheduled by the user with an option to look for the
details regarding the a specific meeting and delete the data regarding that
particular meeting. The second tab Start Meeting provides user with an
option to have instantaneous meeting with personnel of the group by sending
them invites using the notification app containing the details to join the meet.
The code for this tab class looks as specified below:
<header class="row">
<dl class="tabs" data-tab>
<dd class="active"><a href="#panel2-1"><i class="fi-eye"></i> All
Meeting {% if MEETING_inst.count %}({{ MEETING_inst.count }}){% endif
%}</a></dd>
<dd class=""><a href="#panel2-2"><i class="fi-eye"></i> Start
Meeting</a></dd>
</dl>
</header>
Another class namely active has been included in the template which tells
us which specific tab out of the two is active at a particular point of time. We
have set the default active tab as the All Meeting tab to display the user his
scheduled meetings.
This class has been explained in the above mentioned code.
A script has been included to resize the size of iframe in accordance with the
users screen size and resolution. This script gets the height of the window and
makes the iframe height as the (0.9*height) of the screen.
<script>
$(document).ready(function(){
var size = $(window).height();
$("#ifrm").css("height",0.9*size);
});
$(window).resize(function(){
var size = $(window).height();
// alert(size);
$("#ifrm").css("height",0.9*size);
});
</script>
21 | P a g e
4.3
Also, one javascript have been included to check the Boolean value of the
checkbox included in the Start Meeting tab, if the value is true-it signifies
that this particular user have been sent the invitation to join the meeting and
this script helps us retain its Boolean value even after the ajax call but if the
value is false, this means that the user have not been invited for the meeting
and new false Boolean value is assigned to this checkbox after each ajax call.
User Interface
i) The basic outlook of the the metastudio portal after the inclusion of Meeting
app looks like this:
22 | P a g e
ii) The click on the Meeting app displays the meeting.html page which contains
the two tabs as shown in the figure. The default tab have been set to All
Meeting which contain the list of scheduled meetings of the user but since we
have not entered any data yet, it is not displaying any meeting. It also includes a
card New Meeting on whose click the user can schedule a meeting. The
interface looks like this:
23 | P a g e
iv) Final click on the save button stores the data regarding the meeting in the
mongodb database and the final page displaying the details of that particular
meeting appears as shown below.
24 | P a g e
vi) This tab shows the coordinator of the meeting with the list of online members,
checkbox to send them invites and a card Start Meeting to start the meeting.
from the mongodb database, append this id to customize the url for the meeting
and directs the user to chatb.org servers.
26 | P a g e
4.4
1) Use of WebRTC:
We have used the concept of WebRTC to develop this application.
Our project would enable the users of metastudio to interact with each other through
audio and video chat..
This real time communication mechanism have a vast scope in future as it promotes
peer-to-peer communication/sharing on a single browser click.
2) Option of Desktop Sharing:
We have added the features for having a scheduled meeting or on-the-spot meeting.
Currently, we are using the webcam for video transfer. In future, an option for screen
sharing/desktop sharing can be added in this application.
The option of desktop sharing would promote effective and efficient learning
mechanism between teachers and students.
It would eliminate the current problem of maintaining synchronization between the
two ends while teaching or delivering a lecture, for instance, the problem of
transferring the slides for delivering a lecture.
3) Running the App on our servers:
Currently, we are using the chatb.org servers for organizing our meetings but in
future, our own subdomain can be developed and control can be passed onto our
servers for organizing this meetings.
27 | P a g e
An SMS text messaging application connects to SMSCs through an SMS gateway and
the basic prototype would be:
5.1
29 | P a g e
The gateway would parse the content of the received SMS, identify the metastudio
field it belongs to and post the SMS content in the respective field.
If the user is not registered, the gateway would reply the sender prompting him/her to
register.
Our first task on hand is to allow to make a user register at gstudio (metastudio) without
an email account by enabling him/her to fill in registration form with his mobile number
instead of email or both simultaneously, then a confirmation code will reach the user
through a mobile or email depending on the option enabling him/her to register using the
code. We are using RapidSMS as gateway and framework integrated with gstudio for
development of the SMS gateway and backend we are using as of now is Kannel.
5.2
RapidSMS at glance:
RapidSMS is a free and open-source framework for dynamic data collection, logistics
coordination and communication, leveraging basic short message service (SMS) mobile
phone technology. RapidSMS is easily customized to meet the specific needs of the
project and is scalable at an enterprise level. It is currently being utilized by large
multilateral organizations (such as the United Nations), development professionals (such
as the Earth Institute at Columbia University), and small NGOs and CBOs (such as
Tostan).
RapidSMS is written in Python and Django and is a framework for building highly
customized applications.
Applications
RapidSMS applications, or apps, perform one or more of the following
functions:
o Performs the business logic
o Handles and responds to messages
o Extends the data model
o Creates a web interface with Django views and templates
For example, a registration application may provide a messaging protocol for
users to register themselves into the system.
5.3
Backends
Backends receive messages from external sources and deliver messages from
applications to external sources. We will talk about backends used shortly. We
will mostly use Kannel backend with the Gnowledge labs GSM modem for the
project. However for testing purposes we are using our android phones as GSM
modem.
Router
The router is the message processing component of RapidSMS. It provides the
infrastructure to receive incoming, send outgoing messages, and gluing together
our applications and backends.
Installing RapidSMS:
The recommended way to install RapidSMS is with Pip, since RapidSMS is available on
PyPI. In the terminal type the following command,
pip install rapidsms
Before starting a new RapidSMS project, the RapidSMS project template is used. The
project template needs the latest version of Django installed:
pip install Django
5.4
31 | P a g e
5.5
Application Structure:
We have created a RapidSMS app called csms in gstudio framework. Each application
defines a class that extends from rapidsms.apps.base.AppBase, kept in the app.py
submodule of the Django app.
The router maintains a collection of associated applications through which to route
incoming and outgoing messages. Application discovery is managed through the
BaseRouter.add_app method. The default router, BlockingRouter, loads applications
upon initialization by calling BaseRouter.add_app on each app listed in the optional apps
argument or in INSTALLED_APPS.
While the router provides the foundation for messaging processing, applications and
backends actually perform the message processing:
5.6
Message Processing:
The Messaging API defines send and receive to route messages through the router. Messages
are processed via a series of phases, depending on direction. These phases are outlined
below.
1) Incoming Message Processing
Incoming messages are processed in five phases. Each application provides code for
executing the phases. The router method defines hooks which allow an application to
filter out a message, skip phases, or stop further processing.
a) Filter - Optionally abort further processing of the incoming message. The filter phase
is executed before any other processing or modification of the incoming message. If
32 | P a g e
b)
c)
d)
e)
an application returns True from this phase, the message is filtered out and no further
processing will be done by any application (not even cleanup).
Parse - Modify message in a way that is globally useful. This phase is used to modify
the incoming message in a way that could be useful to other applications. All
messages that arent filtered go through the parse phase of every application. No
INSERTs or UPDATEs should be done during this phase. Example: An application
adds metadata about phone number registration to each message.
Handle - Respond to the incoming message. The router passes incoming messages
through the handle phase of each application until one of them returns True. All
subsequent apps will not handle the message.
Default - Execute a default action if no application returns True during the handle
phase. For example, an application might want to provide additional help text or a
generic response if no other application has handled the message. The application can
return True from this method in order to prevent the remaining applications from
executing their default stage.
Cleanup - Clean up work from previous phases.
The order in which the router chooses applications to process messages is extremely
important, because each application will have the opportunity to block subsequent
applications from processing a message. receive_incoming processes messages in the
order they are listed in INSTALLED_APPS.
2) Outgoing Message Processing
The router receives each outgoing message through its outgoing method. Messages are
processed in a manner similar to incoming messages, except only one phase, outgoing, is
defined. In BaseRouter.send_outgoing, the message is processed sequentially by the routers
associated applications. However, the applications are called in reverse order with respect to
the order they are called in BaseRouter.receive_incoming, so the first application called to
process an incoming message is the last application that is called to process an outgoing
message. If any application returns False during the outgoing phase, all further processing of
the message will be aborted.
The logic for the outgoing phase is defined in a method of the same name in the AppBase
class. By default, no action is taken during this phase. Each subclass may choose to override
the default method to use custom logic on outgoing messages.
33 | P a g e
5.7
RapidSMS Backends:
Backends define how RapidSMS integrated with gstudio communicates with the outside
world. The router uses backends to send and receive messages and all text messages will
eventually pass through a backend. They handle a two-way messaging protocol:
Incoming messages: Messages received by RapidSMS from an external source linked
with gstudio. All incoming messages are received over HTTP and processed by a
Django view. Once received, backends will pass messages to the router for
processing.
Outgoing messages: Messages sent by RapidSMS linked with gstudio to an external
source. The router will pass messages to backends once processed. RapidSMS sends
messages over HTTP.
RapidSMS includes following backends in core for you to use:
Kannel backend
Vumi backend
HTTP backend
Database backend
Since we are going to work with Kannel Backend mostly we will not focus on other
backends in this report whereas Kannel Backend is discussed in next section of the report.
5.8
Kannel Backend:
Kannel is a free and open source SMS gateway configured for use with RapidSMS. We
used Kannel as it is possible to configure Kannel to connect directly to USB or serial
GSM modems as well as third party HTTP or SMPP gateways.
5.8.1
Installing Kannel
http://www.kannel.org/arch.shtml
The README and various other text files in the source tree.
34 | P a g e
By default in Ubuntu, Kannel starts a WAP gateway but does not start the SMS
gateway. To change this behavior, we first have to stop Kannel:
sudo service kannel stop
Now, /etc/default/kannel is edited and the line starting with START_SMSBOX is
uncommented. To do so the following command is written in terminal window:
sudo gedit /etc/default/kannel
Finally, we start the Kannel again:
sudo service kannel start
5.8.2 Setting up the fake SMSC for testing
Kannel includes support for a Fake SMSC which can be useful during setup for
testing both Kannel and RapidSMS. The relevant utility is included in the kannelextras package:
sudo apt-get install kannel-extras
To make things simpler, we first setup Kannel and RapidSMS to work with a
Fake SMSC, and then attempt to connect it to a USB modem.
5.8.3
The configuration file can be divided into three parts: bearerbox configurations,
smsbox configurations and wapbox configurations. Bearerbox part has one 'core'
group and any used SMS center groups, while wapbox part has only one wapbox
group. In smsbox part there is one smsbox group and then number of sms-service
and sendsms-user groups. Configurations involving wapbox part wont be used in
our project.
To set up a SMS Kannel, the 'core' group in the configuration file has to be edited,
and 'smsbox' group plus one or more 'sms-service' groups, plus possibly one or
more 'sendsms-user' groups are defined.
For the 'core' group, we must set the following variable: smsbox-port. A sample
configuration file smskannel.conf is supplied with the standard distribution.
The easiest way to get Kannel working with RapidSMS is to start with a sample
Kannel configuration. To get started, copy and paste the following into
/etc/kannel/kannel.conf, replacing everything currently in the file:
35 | P a g e
smsc = fake
smsc-id = FAKE
port = 10000
connect-allow-ip = 127.0.0.1
#--------------------------------------------# SMSBOX SETUP
#
# Smsbox(es) do higher-level SMS handling after they have been received
from
# SMS centers by bearerbox, or before they are given to bearerbox for
delivery
group = smsbox
bearerbox-host = 127.0.0.1
sendsms-port = 13013
sendsms-chars = "0123456789 +-"
log-file = "/var/log/kannel/smsbox.log"
log-level = 0
access-log = "/var/log/kannel/smsbox-access.log"
reply-couldnotfetch = "We message could not be processed at this time.
Please try again later. (err=couldnotfetch)"
reply-requestfailed = "Ourr message could not be processed at this time.
Please try again later. (err=requestfailed)"
reply-couldnotrepresent = "Our message could not be processed at this
time. Please try again later. (err=couldnotrepresent)"
http-request-retry = 3
http-queue-delay = 10
# SEND-SMS USERS
#
# These users are used when Kannel smsbox sendsms interface is used to
# send PUSH sms messages, i.e. calling URL like
# http://kannel.machine:13013/cgibin/sendsms?username=tester&password=foobar...
# This is the username and password that RapidSMS uses to deliver
SMSes to
# Kannel. It must also set the 'smsc' variable in the query string, so that
# Kannel knows which SMSC to use to route the message.
group = sendsms-user
username = rapidsms
password = CHANGE-ME
user-deny-ip = "*.*.*.*"
user-allow-ip = "127.0.0.1;"
37 | P a g e
#--------------------------------------------# SERVICES
#
# These are 'responses' to sms PULL messages, i.e. messages arriving
from
# handsets. The response is based on message content. Only one smsservice is
# applied, using the first one to match.
# The 'ping-kannel' service let's you check to see if Kannel is running,
# even if RapidSMS is offline for some reason.
group = sms-service
keyword = ping-kannel
text = "Kannel is online and responding to messages."
# There should be always a 'default' service. This service is used when no
# other 'sms-service' is applied. These relay incoming messages from any
# configured SMSCs to the appropriate HTTP backend URLs in
RapidSMS.
# By setting 'accepted-smsc', we are assured that messages are routed to
# the appropriate backend in RapidSMS.
group = sms-service
keyword = default
catch-all = yes
accepted-smsc = FAKE
# don't send a reply here (it'll come through sendsms):
max-messages = 0
get-url = http://127.0.0.1:8000/backend/kannel-fakesmsc/?id=%p&text=%a&charset=%C&coding=%c
A file called modems.conf is then copied from where Ubuntu installed
it as follows:
sudo cp /usr/share/doc/kannel/examples/modems.conf /etc/kannel/
Next, restart Kannel to reload the new configuration:
sudo service kannel restart
5.8.4
Now that Kannel is installed and configured correctly, adding support for the
Kannel backend to our existing RapidSMS project is not difficult. To begin,
simply add the following to the existing INSTALLED_BACKENDS
configuration in settings.py file:
38 | P a g e
INSTALLED_BACKENDS = {
# ...
# other backends, if any
"kannel-fake-smsc" : {
"ENGINE": "rapidsms.backends.kannel.KannelBackend",
"sendsms_url": "http://127.0.0.1:13013/cgi-bin/sendsms",
"sendsms_params": {"smsc": "FAKE",
"from": "123", # not set automatically by SMSC
"username": "rapidsms",
"password": "CHANGE-ME"}, # or set in
localsettings.py
"coding": 0,
"charset": "ascii",
"encode_errors": "ignore", # strip out unknown (unicode) characters
},
}
"host" and "port" should no longer be included in the backend configuration.
Next, we need to add an endpoint to our urls.py for the newly created backend.
We can do this like so:
from django.conf.urls.defaults import *
from rapidsms.backends.kannel.views import KannelBackendView
urlpatterns = patterns('',
# ...
url(r"^backend/kannel-fake-smsc/$",
KannelBackendView.as_view(backend_name="kannel-fake-smsc")),
)
Now, we are able to start RapidSMS like so:
./manage.py runserver
And test connection using the echo app in RapidSMS (if installed in our project):
/usr/lib/kannel/test/fakesmsc -m 1 "123 789 text echo hi"
A message is seen get echoed back on the last line:
INFO: Got message 1: <123 123 text hi>
39 | P a g e
5.8.5
Using the base configuration given above, we add the following to the section
titled SMSC CONNECTIONS in /etc/kannel/kannel.conf, changing the device
= /dev/ttyUSB0 line so that it points to the right device:
group = smsc
smsc = airtel
smsc-id = usb0-modem
my-number = +919660578188
modemtype = auto
device = /dev/ttyUSB0
Next, we add the following sms-service at the end of the file, which will send
incoming messages from the modem to RapidSMS via HTTP:
group = sms-service
keyword = default
catch-all = yes
accepted-smsc = usb0-modem
# don't send a reply here (it'll come through sendsms):
max-messages = 0
get-url = http://127.0.0.1:8000/backend/kannel-usb0smsc/?id=%p&text=%a&charset=%C&coding=%c
Make sure to restart Kannel to reload the configuration:
sudo service kannel restart
5.8.6
Finally, we add a second Kannel backend to our settings.py which will setup the
necessary router infrastructure to send and receive messages via the USB modem
you configured above in Kannel:
INSTALLED_BACKENDS = {
# ...
"kannel-usb0-smsc" : {
"ENGINE": "rapidsms.backends.kannel.KannelBackend",
"sendsms_url": "http://127.0.0.1:13013/cgi-bin/sendsms",
"sendsms_params": {"smsc": "usb0-modem",
"from": "+SIMphonenumber", # not set automatically by
SMSC
"username": "rapidsms",
40 | P a g e
Delivery Report
5.9
In future, the features can be enhanced in terms of sending and receiving the texts.
In terms of outgoing SMS, various features can be developed in terms of notifying the
users about his activities on metastudio. We can develop the features corresponding
to each and every email based notification.
In terms of receiving the SMS at metastudio, we can develop various handlers to
parse the content of the messages received. This handlers would use the various
methods and respond according to the text received whether in terms of sending an
SMS back or identifying the field to which the text belongs and posting it to
respective field.
42 | P a g e
6. CONCLUSION
After completion of the projects, there will be two new features with which Metastudio will be
endowed with:
1. Chatb Integration with Metastudio:
An App to let users/members interact with each other and have real time P2P
communication using their browsers.
This nodal app would enable quick, efficient and user friendly communication
between members of a group within Metastudio.
2. Developing an SMS gateway:
Providing people access to Metastudio portal using simple wireless carrier i.e. using
an SMS.
The project would ease the accessibility to communicate and would introduce social
networking platform on Metastudio.
43 | P a g e
7. REFERENCES
i.
Bengtsson, P. (2014, June 4). How and why to use django-mongokit(a.k.a Django to
MongoDB). . Retrieved from http://www.peterbe.com/plog/how-and-why-to-use-djangomongokit
ii.
iii.
iv.
v.
vi.
vii.
viii.
ix.
Bengtsson, P. (2014, June 4). How and why to use django-mongokit(a.k.a Django to
MongoDB). . Retrieved from http://www.peterbe.com/plog/how-and-why-to-use-djangomongokit
x.
xi.
xii.
xiii.
xiv.
xv.
44 | P a g e
xvi.
xvii.
xviii.
xix.
Nielson, M. (2014, June 9). Write your first MapReduce program in 20 minutes.
xx.
xxi.
xxii.
xxiii.
xxiv.
45 | P a g e
8. GLOSSARY
1. SMTP: Simple Mail Transfer Protocol (SMTP) is an Internet standard for electronic mail
(e-mail) transmission. While electronic mail servers and other mail transfer agents use
SMTP to send and receive mail messages, user-level client mail applications typically use
SMTP only for sending messages to a mail server for relaying. For receiving messages,
client applications usually use either POP3 or IMAP.
2. HTTP: The Hypertext Transfer Protocol (HTTP) is an application protocol for
distributed, collaborative, hypermedia information systems.[1]HTTP is the foundation of
data communication for the World Wide Web. Hypertext is structured text that uses
logical links (hyperlinks) between nodes containing text. HTTP is the protocol to
exchange or transfer hypertext. HTTP functions as a request-response protocol in the
client-server computing model. HTTP is designed to permit intermediate network
elements to improve or enable communications between clients and servers.
3. Metastudio:It is a collaborative workspace for shaping up education and research. We
can discuss, design and construct various educational initiatives collaboratively and
create a social network with members of a community by (a) campaigning about the
educational initiatives and (b) broadcast the work to the world through blogs, articles,
share resources and seek responses.We can do this by involving any citizen to join a
research project or by designing a project that provides concrete learning experiences to
participants.
4. Node: In communication networks, a node (Latin nodus, knot) is either a connection
point, a redistribution point or a communication endpoint (some terminal equipment).
The definition of a node depends on the network and protocol layer referred to. A
physical network node is an active electronic device that is attached to a network, and is
capable of sending, receiving, or forwarding information over a communications channel.
A passive distribution point such as a distribution frame or patch panel is consequently
not a node.
5. SMS: Short Message Service (SMS) is a text messaging service component of phone,
Web, or mobile communication systems. It uses standardized communications protocols
to allow fixed line or mobile phone devices to exchange short text messages. The term
"SMS" is used for both the user activity and all types of short text messaging in many
parts of the world. SMS is also employed in direct marketing, known as SMS marketing.
6. pyGSM: pyGSM is a Python module which uses pySerial to provide a nifty interface to
send and receive SMS via a GSM Modem. It was ported from RubyGSM, and provides
(almost) all of the same features.
7. AJAX: It is a group of interrelated Web development techniques used on the client-side
to createasynchronous Web applications. With Ajax, Web applications can send data to,
and retrieve data from, a server asynchronously (in the background) without interfering
with the display and behavior of the existing page. Data can be retrieved using the
46 | P a g e
XMLHttpRequest object. Despite the name, the use of XML is not required; JSON is
often used instead (see AJAJ), and the requests do not need to be asynchronous.
8. Iframe: An iframe is used to display a web page within a web page. The height and
width attributes are used to specify the height and width of the iframe.The attribute
values are specified in pixels by default, but they can also be in percent (like "80%").
9. SMSC: A short message service center (SMSC) is a network element in the mobile
telephone network. Its purpose is to store, forward, convert and deliver SMS messages.
The full designation of an SMSC according to 3GPP is Short Message Service - Service
Center (SMS-SC) Basic Trajectories of SMS are
a. From Mobile to another Mobile, this trajectory is referred as MO-MT (Mobile
Originated - Mobile Terminated).
b. From Mobile to a content provider (also called as Large Account / ESME), this
trajectory is referred as MO-AT (Mobile Originated - Application Terminated).
c. From Application to a Mobile, this trajectory is referred as AO-MT (Application
Originated - Mobile Terminated).
10. WAP: Wireless Application Protocol (WAP) is a technical standard for accessing
information over a mobile wireless network. A WAP browser is a web browser for
mobile devices such as mobile phones that uses the protocol. WAP Push was
incorporated into the specification to allow WAP content to be pushed to the mobile
handset with minimum user intervention. A WAP Push is basically a specially encoded
message which includes a link to a WAP address. WAP Push was specified on top of
WAP Datagram Protocol (WDP); as such, it can be delivered over any WDP-supported
bearer, such as GPRS or SMS.Most GSM networks have a wide range of modified
processors, but GPRS activation from the network is not generally supported, so WAP
Push messages have to be delivered on top of the SMS bearer.
11. CIMD: Computer Interface to Message Distribution (CIMD) is a proprietary short
message service centre protocol developed by Nokia for their SMSC .
12. Modem: A modem (modulator-demodulator) is a device that modulates an analog carrier
signal to encode digital information and demodulates the signal to decode the transmitted
information. The goal is to produce a signal that can be transmitted easily and decoded to
reproduce the original digital data. Modems can be used with any means of transmitting
analog signals, from light emitting diodes to radio.
47 | P a g e