An Implementation for Accessing Twitter Across Challenged Networks

cuttlefishblueData Management

Dec 16, 2012 (4 years and 6 months ago)


An Implementation for Accessing Twitter Across
hallenged Networks
Nathan Thai
University of Texas at Austin
Kyle Zaragoza
Stanford University
Terrance Christensen
New Jersey Institute of Tech
We describe the challenges,design decisions,and imple-
mentation details behind a proof-of-concept application that
uses social networking to demonstrate the feasibility behind
Delay-Tolerant Networking (DTN) principles.For the main
platform,we use DTN2,an implementation of DTN proto-
cols designed for experimentation,production,and deploy-
ment.Although this application is specific to Twitter,it is
easily modifiable to adapt to other social networks.
Categories and Subject Descriptors
H.4.3 [Information Systems Applications]:Communi-
cations Applications
General Terms
DTN,application,development,social networking,Twitter
While some believe that networking infrastructure in the
modern world is sufficiently pervasive to make the benefts of
innovations in the field of Delay-Tolerant Networks (DTNs)
questionable,we argue that there exist many useful appli-
cations for them.One prominent example of a ”challenged
network” [1] occurred during the 2011 T¯ohoku earthquake
and tsunami in Japan,which damaged undersea cables and
caused Internet outages across Asia.A working application
of DTN could have provided an alternative means of com-
munication in the absence of a working network.
In this paper,we describe the challenges,design decisions,
and implementation details behind a proof-of-concept appli-
cation that uses social networking to demonstrate the feasi-
bility behind DTN principles.We chose social networking as
a platform to demonstrate DTNs because of its speed and
reliability as a means of communication in disaster areas
[2] and its increasing importance in the world at large.Fur-
thermore,we specifically chose to use Twitter as the primary
development tool because of its intuitive API.
Copyright is held by the author/owner(s).
CHANTS’11,September 23,2011,Las Vegas,Nevada,USA.
2.1 OAuth
OAuth is an open source protocol that allows for API au-
thentication without an application seeing or storing user-
name and password.According to the Twitter API OAuth
documentation [3],users grant an application privileges us-
ing tokens comprised of a public and secret key.The user
retrieves a URL and a request token fromthe Twitter server
via the application.The user authenticates directly with
Twitter using the URL and receives a PIN to return to the
application,allowing the application permission to access
the account.The application uses the PIN along with the
request token to retrieve a user’s access token from Twitter.
This method never reveals username and password to the
application,only to Twitter.Instead,the application uses
two tokens,consumer and access,to access a user’s account.
Twitter provides the application a unique consumer token
and,upon request,access tokens unique to each user.Ac-
cording to OAuth guidelines,secret keys should never be
transmitted except to the Twitter authentication server.
2.2 Bundles
The DTN Bundle Security Protocol (BSP) [4] ensures se-
cure and proper delivery from source to destination.The
BSPdefines several security blocks which prevent DTNtrans-
actions from becoming compromised.The Bundle Authen-
tication Block (BAB) protects a bundle by verifying source
and destination,while the Payload Integrity Block (PIB)
and the Payload Confidentiality Block (PCB) prevent a bun-
dle’s payload from being tampered with in transit.
Twitter utilizes the OAuth platform for authentication
but the registration process requires a significant amount of
time-sensitive,two-way communication,which is a problem
for challenged networks.Registration requires a direct Inter-
net connection,and assumes the latency during registration
is less than the lifetime of all bundles.
The high latency inherent to challenged networks can mean
a delay between error occurrence and user notification.TCP
packets require acknowledgement to ensure proper delivery
whereas DTN does not.Although DTN allows for delivery
confirmation,a user may not receive any information con-
cerning a sent bundle for a lengthy period of time.Addi-
tionally,the DTN return receipt option confirms only proper
delivery not successful posting.As a result,a DTN may be
unable to quickly notify users to correct their errors.
Furthermore,social networking on challenged networks
sing the Bundle Protocol is a relatively new idea with little
standardization.We considered methods of processing bun-
dles containing tweets and metadata,such as geolocation
and retweet data.We also needed to determine whether
data should be classified as metadata or extensions.
4.1 Design
We chose Python for our implementation language be-
cause of its flexibility,extensive code base,and Twitter API
compatibility.We chose the DTN2 [5] implementation be-
cause of its open source availability and features.Because
DTN2 is open source we could directly modify the DTN2
functions before using a Python wrapper with the Twitter
API.We also used the BSP implemented in DTN2 to ensure
proper transfer of bundles.
￿￿￿￿ ￿￿￿￿￿￿￿
DTN’s unique characteristics require the application to be
ivided into two parts:the client,which runs on the user’s
DTN-enabled device,and the gateway,which has a connec-
tion to Twitter.The client application abstracts the DTN
process while the gateway decomposes bundles and either
posts to the proper feed based on established credentials
or pulls search or user timeline tweets.Once a user regis-
ters and begins tweeting,the client application packages the
tweet content into bundles and sends them to the gateway
where they are used to authenticate the user.The process
for receiving tweets is similar:multiple searches and timeline
requests can be packaged into a bundle,though only private
user searches and the user’s timeline require authentication.
4.2 Process
The Twitter OAuth implementation requires users to ini-
tially register on a low-latency network since the URL and
PIN are time-sensitive.To use the application,users must
allow access to their accounts as they would with a standard
Twitter application using OAuth before transitioning to an
exclusively Delay-Tolerant Network.Since the application
is split,the client acts as a mediator between the user and
the gateway,which authenticates with Twitter on behalf of
the user.The gateway generates the URL and sends it to
the client which prompts the user to access the URL and
return the PIN for the gateway,which uses it to generate
the user’s unique access token.The gateway also generates
a unique identifier (UID),sends the UID and public access
key (PAK) to the user,and deletes the PAK.The client ap-
plication stores the PAK and UID for future use,while the
remaining data on the gateway is then stored in a database.
The gateway uses a PostgreSQL [6] database to maintain
persistent state.PostgreSQL offers security and scalability
for storing multiple users’ information.The gateway does
not store complete tokens.When tweeting,the client passes
a user’s public key,UID,and tweet information.The gate-
way uses the UID to locate the secret access key,hashes it
with the public key,and compares the hash to verify the
user.Once the user has been verified the gateway uses ac-
cess token to post the tweet and then deletes the PAK.These
actions are performed,in addition to the security block pro-
cessing proscribed by the BSP,to secure user information
and ensure legitimate transactions.When pulling tweets,
the client passes the search command and,if needed,the
PAK and UID.
Upon failure to complete an API call to Twitter,our ap-
plication stores the message and corresponding error file.It
will then attempt to send the error messages back to the
user.However,given the nature of DTN,the error may not
reach the user in a set amount of time.This provides a best-
effort error handling system for informing users when their
tweets are not posted,or search calls fail.
Bundles are handled by the application as JavaScript Ob-
ject Notation (JSON) [7] formatted files.We modified the
DTN2 dtnrecv function to output bundles in the JSON for-
mat.JSON is highly portable and the standard of commu-
nication for the Twitter API.Additionally,Python provides
many libraries including ones for parsing JSON files,ex-
tracting metadata/payloads,authenticating via OAuth,and
reading search results.
A complete DTN application is under development.We
plan to allow users to register,subscribe to feeds,and access
other social networks over DTN.Additionally,the gateway
will also push updates to clients.
Our demonstration will include a DTN-enabled endpoint
with a connection to Twitter,which will serve as the gate-
way,and a collection of DTN-enabled mobile devices,ini-
tially connected to Twitter,which will serve as the clients.
After initial registration,the clients will disconnect from
Twitter and users will send and receive tweets via DTN.
Tweets will arrive on the gateway and be posted to Twitter.
This research was funded in part by the US Department
of Defense.The views expressed are those of the authors,
and do not necessarily reflect the views of the sponsoring
[1] K.Fall.A Delay-Tolerant Network Architecture for
Challenged Internets.In ACM SIGCOMM,Aug.2003.
[2] H.Wallop.Japan earthquake:how Twitter and
Facebook helped.
[3] Twitter OAuth Documentation.
[4] S.Symington et al.Bundle Security Protocol
Specification,Internet RFC6257.May 2011.
[5] Delay Tolerant Networking Research Group.
[6] PostgreSQL.
[7] Introducting JSON.