Information Technologies: Hao Zhang, Zhongkui Sun, He Li

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Information technologies

A Distributed Instant Messaging System Model

Hao Zhang, Zhongkui Sun, He Li


Qinggong College, North China University of Science and Technology,
Tangshan 063000, Hebei, China

Jianmin Li
Institutes of Electronics, Chinese Academy of Sciences,
Beijing 100000, China

Abstract
Most existing instant messaging system is built on "centralized server" mode, which is
designed by using C/S or P2P framework to require client must log on a remote server, or on
a centralized server farms. There is a problem about this instant messaging system: If the
LAN firewall or proxy server restrictions instant messaging services, or when outside the
LAN connection is disconnected, the user cannot even in the same local area network to
communicate with each other. To solve this problem, design a multi-server model of
distributed instant messaging system by using the C/S and P2P hybrid structure. When the
remote server with limited or disconnected from a network failure, the client can log on to
the server on the LAN, so you can ensure the same in a LAN client continue instant
messaging. This model not only can the user's important information for centralized and easy
to manage, but also to improve the quality and efficiency of communication between the
customers; also enables users on the same LAN without passing through the external network
can communicate with each other needs.
Key words: INSTANT MESSAGING; CLIENT/SERVER; PEER TO PEER

1. Introduction communicate in real-time text, voice, video,


IM (Instant Messaging) is a LAN-based or documents, etc.. For example, we are most familiar
real-time interactive Internet applications, instant Tencent QQ in China, QQ users to communicate
rapid development of communications are with the general pattern of use is as follows: First,
dramatically changing the way people the user must register a QQ account, communicate
communicate, collaborate and play [1]. More with friends, log on QQ client, and connect to the
simply, functional instant messaging system is the QQ server. Next, look at your friends are online; if
user real-time communication. Instant messaging friends are online, you and your friends to send or
system to organize the exchange of large virtual receive messages to each other; sometimes to find
communities, where users can find like-minded, online users, to choose one request add to friends,
have a common language, willing to share the instant communications; friends Offline can to a
Friends (Friends), for on-line (Online) friends can friend mail; a friend can transfer files to each other.

© Metallurgical and Mining Industry, 2015, No. 6 487


Information technologies
The used mode Tencent term used to describe (in weaken the role of the server, or even abolish the
order): on-line; Friends List; messaging; add server, any two computers to each other servers, but
friends; online; send the file. Communication it is also a client. The disadvantage is inconvenient
model for other instant messaging systems and to manage.
Tencent QQ is similar. Therefore, instant messaging system
In RFC2778, the instant messaging system research worldwide will accelerate the
is defined as: A presence and messaging system development of the emergence of a trend, but both
allows users to subscribe to each other and be centralized and easy to manage important
notified of changes between each user in state, and information about the user, and can effectively
for users to send each other short instant messages reduce server load and improve the quality and
[2, 3]. Popular speaking, instant messaging refers efficiency of customer communications among
to the communication both sides on the Internet, instant messaging system model is the direction of
very quickly sends and receive messages to each current research.
other's activities. Receivers send and receive 2. IM systems and communication
messages and information publisher information process model
delay is very small, almost at the same time meet 2.1 Centralized server mode and
the requirements of transfer. Online communication process
communication tools such as we often use: QQ, Now the communication mode most
MSN, Fetion mobile communications systems instant messaging system is primarily built on
tools [4, 5]. In July 1996, four young Israelis set up "centralized server." Between the user of this mode
a company Mirabilis, ICQ and released the initial of communication, must be first log on to a remote
version of the same year in November, as the server or a centralized server farms, establish a
world's first instant messaging software, quickly connection, communication is instantaneous. Its
swept the world, then instant messaging software network model shown in Figure 1:
abound. Currently the best-known instant Assuming a single-server IM is shown in
messaging system ICQ, MSN Messenger, Google figure 1 to establish a buddy relationship between
talk and Yahoo Messenger, the most popular the user A, B, C, and D. In a single-server mode
Tencent QQ, Netease bubble and flying letters. The communication process between users as follows:
instant messaging system provides real-time Initially assumed that users are offline, the user A
communication on the basis of the basic functions, logged into the local server, and informs its IM
which has its own characteristics. Flying letters can server online, the local server record online user
send free text messages to friends' mobile phones; A's. When between user A and user C under the
Google talk chats in the form of e-mail stored in same server need to communicate, IM server
Google mail mailboxes inside. advertised, IM buddy list server detected, notify the
It said instant messaging system based on user A, user C's current online status. In this case,
the "hub server" mode, using C/S or P2P mode if the user is offline C, IM, server feedback to the
design requires the client application must be user A, user C current offline, therefore, when the
logged in to the remote server, or on a centralized user A can only be in a wait state. If the user C
server farms. If C/S model, this model is divided already is online, then IM server notifies the user A
into formal logic, business logic, data logic and and user C both in-line and can communicate.
data storage from the structure, all the forms and When a user logs on the server, his IP
business logic reside on the client, and data storage address and port number of the report prepared for
logic and data reside on the server side. The the future communication to the IM server. When
advantage is that the user mode some important the new user logs on, the servers is responsible for
information can be centralized and easy to manage, the other user status notification new login user,
but with the number of users increases, the system and notify all their online friends of IP addresses
is running and when communication between and communication ports. Therefore, by each
customers, increase the burden on the server, other's IP addresses and communication ports to
reducing the quality and efficiency of establish P2P connection between friends, then you
communication among customers [6, 7]. In P2P can point to point between the two instant
communication mode, each node also has messaging. In the communication process, it is
information on most consumers’ information assumed between user A and user C can properly
providers and information and communication establish TCP / IP connections, instant messages
aspects of the function. The rights and obligations can be transmitted through ordinary Sockets
of P2P networks have each node are peers [8]. This interconnected between them. But if there is a
approach has powerful processing capability and firewall blocking or other reasons cannot establish
save bandwidth performance, P2P technology normal TCP / IP connection in both the

488 © Metallurgical and Mining Industry, 2015, No. 6


Information technologies
communication process, the instant messages area network users cannot communicate with each
between the two still need to be forwarded through other.
the server. 2.2 Distributed multi-server instant
messaging system mode and communication
process
In order to solve the "central" server mode
problems in a multi-server distributed instant
communication model. The system model with
IM Server three and four client terminal server, for example,
the system model shown in Figure 2:
In this model system, the local server is Ⅰ,
PC C users within the LAN A, B, etc. to provide services
PC A
Internet within the local server is Ⅱ, LAN users C, D, etc.
to provide services, the server Ⅲ remote server, a
multi-a LAN client terminal to provide services.
Assume that the user A has been in the
LAN and LAN Ⅰ Ⅱ C was established within the
PC B PC D user buddy relationship. In this communication
mode in the LAN Ⅰ, if the user A and user B
Figure 1. Model of centralized server IM communication, the communication process is
similar to the "central" server mode, no further
The advantage of this mode of explanation. If users in the LAN Ⅰ A to user C Ⅱ
communication is beneficial to the system server communication within the LAN and, following the
maintenance and upgrades. But its shortcomings communication process between them(Figure 1).
are obvious: a first, the network speed is not fast Initially assumed that all users are also
enough and widely distributed users, this model offline, when user A logs on the local server Ⅰ,
increased the burden on the server, it is difficult to notify the local server Ⅰ their online status. Ⅰ note
provide high quality service for all users. Second, of the local server on-line status of the user A, and
the "central" server system on the server hardware then check the buddy list of the user A, user C is
made very high demand, the cost of purchase and
not found in the user's local server Ⅰ. A local
construction of such servers tend to be very
expensive, and maintenance cost is also expensive. server user exits Ⅰ, re-log into the remote server,
In order to ease the pressure on the server, and report on their IP address and prepare for future
there are now "focus" IM server farms. This uses communications port number. Write down the
multiple servers to complete a single server remote server online user A and user C's
functions, and batch data for each user on multiple responsibility to inform the local server Ⅱ, asking
servers. This IM server farm to some extent reduces them to inform the user C, user A's on-line status.
the server load independent. But the "centralized" If user C is not online, due to the local server solely
type server model prevalent a problem: If the LAN responsible for recording the local user's online
firewall or proxy server restrictions instant status, so that the local server Ⅱ A discard message
messaging services, or when outside the LAN online status of users.
connection is broken, even within the same local

LANⅠ LANⅡ
PC B
PC C
Intranet Internet Intranet

PC D
PC A

Local Server I Remote Server Ⅲ Local Server Ⅱ

Figure 2. Model of distributed multi-server IM

© Metallurgical and Mining Industry, 2015, No. 6 489


Information technologies
When the user C on the line, it will notify systems, each server access to the Internet in
the local server Ⅱ their online status. Local server accordance with their own way and with their
Ⅱ check their friends list, find the user A is not a clients can establish an independent instant
local server users, C quit the Local login, login messaging system; therefore, the topology of the
remote server. Similarly, the remote server to entire system is the network structure. Which can
record the user A's online status, user C report their be established between any two nodes of the instant
IP address as well as preparing the future for instant messaging server, eliminating the forwarding
communication for listening TCP / UDP port process information, thereby improving the
number. As has been informed of the other's IP efficiency of instant communication, reducing the
address and TCP / UDP port numbers between user burden on the server; will not result in a server hang
A-line, so that users A and C, will be able to direct caused by impaired users communicate. System
the instant communication. structure shown in Figure 3:
When the user C on the line, it will notify When the users in a local area network
the local server Ⅱ their online status. Local server need for communication, they will send a request
to the local IM server. In some cases, the local
Ⅱ check their friends list, find the user A is not a
server gives a response. After the user and the local
local server users, C quit the Local login, login
server connection are successful, the local server
remote server. Similarly, the remote server to
creates a new thread for the user. Data processing
record the user A's online status, user C report their
between the user and the server is done by a thread.
IP address as well as preparing the future for instant
IM client and server-side data are to be
communication for listening TCP / UDP port
encapsulated by calling the information processor.
number. As has been informed of the other's IP
If the user needs to communicate between the
address and TCP / UDP port numbers between user
LAN, by the local server in the corresponding
A-line, so that users A and C, will be able to direct
thread request to the remote server. Given the
the instant communication.
appropriate remote server to establish a connection
3. Design on IM system model
with the remote server, and ultimately the
3.1 IM system architecture model
communication between the user LAN.
Due to the distributed multi-server IM

Request

PC A Thread Ⅰ
Response Request

Information Information Response


Processor Processor

Local IM Server Remote IM Server

Request
PC B Thread Ⅱ Request
Response

Response
Information
Information
Processor Processor

Figure 3. The system structure chart

3.2 Rules of the system user ID your own way registered user identification name.
In the current instant messaging system Both methods have their advantages and
user is mainly in two ways. In ICQ, QQ and other disadvantages: the digital way is not easy to
systems such as the number of employed is way, by remember, but network name duplication problems
assigning to each user a unique digital serial that may arise between different user registration
number of ways a user ID. In AOL and Yahoo solved; logins ways much freedom to the user, but
through instant messaging systems like you take the same name problems cannot be solved, only to

490 © Metallurgical and Mining Industry, 2015, No. 6


Information technologies
Tom1, Tom2 difference in such a manner. on. Server1 so you can transfer issue has logged on
In this design, IM system, the use of multi- to the customer Server2 under Jerry, Jerry know the
server architecture, the number of users on each source of the information upon receipt of reply to
server is reduced, and therefore, it is recommended an instant message to be received based on XML
to take away the user login name for user data.
identification. Meanwhile, in order to identify the 3.4 Web services model IM systems
client from which server, the system user Since the data transmission between the
identification reference Jabber system, similar to LAN instant messaging systems may need a
the Email address form to be realized. For example, firewall, but in the case of Internet connection is
user Tom has an account on the server Serverl.com: normal, there may not be to transfer data between
Tom, then the user ID can use "Tom @ networks. Web services for data transmission via
Serverl.com" to represent. HTTP protocol. Even with the presence of a
3.3 Instant Message Format of System firewall, HTTP protocol can be properly adopted.
Between the client and the server, data Therefore, the data transmission between servers in
transfer between clients and servers between XML two ways, first in the form of direct transfer of data
structure in accordance with certain. <present /> packets, the other one is, when not directly transmit
element is used to determine the user's status, data, send data to each other through a local server
<message /> element is used to transmit messages tries to call a remote Web server. That is when two
between the two clients, <iq /> element is different instant messaging network client ends
completed between the client and the server XML cannot communicate directly; it can be forwarded
queries and responses. via its Web services, data transmission.
Such as instant messaging data sent to Tom @ Implementation calls the Web service to
Serverl.com [email protected] as follows: pass data between the server programs, there are
<message two: one is the IM server that contains the Web
to = '[email protected] ' service. Such programs need to implement server
from = 'Tom @ Serverl.com ' type = ' chat '> at the same time, we must implement Web services.
< body>Where are you , Jerry?</body> Another is to set up separate IM server and Web
</message> services, which is conducive to system design
In the XML data stream, the identification division and different versions in the open unity of
information purposes, source, type, content and so the agreement, installation and implementation.
Figure 4 is a graph:

IM Client IM Server IM Server

Ht
tp
Pr
ox
y

IM Web Server IM Web Server

Web Client

Figure 4. Web service model of IM

Part of the figure when the case of instant client to call via the web access, you can
messaging system Web service is not open when communicate between clients. Server system
the dotted line above; part of Web Services case provides the following Web services:
opened under the dotted line. Web Services IM Login/Logout Service: It is responsible for
client can call communicate via HTTP proxy. In providing user login authentication;
addition Web service can also call the Web browser Register Service: It is responsible for providing

© Metallurgical and Mining Industry, 2015, No. 6 491


Information technologies
user login authentication; class," "Friends informational received", "send a
FriendList Service:After the user logs in charge message to a friend category," "send offline
of generating the user's buddy list; messages to the server category," "Send to a Friend
AddFriend Service:For the user to specify the receiving server IP address and TCP/UDP
user to the buddy list; communication port class "," server class. "As the
DelFriend Service:Provide a user deletes their "Friends of information received class" and
buddy list specified item; "Receive Server Info" is to receive information
classes, and receive information with a class
SendMessage Service:Implementing user sends a
common, allowing them to receive information
message to a specified friend;
class inherit the super class of common, similar due
Logout Service: Complete user logs off.
to the "send a message to a friend category "and"
These Web services, users can instantly
send a message to the server class "is a message
communicate through firewalls and other IM users.
class and common class having transmission
4. UML system modeling
information, you can also send a message classes
4.1 UML class diagram model
inherit the super class of common, class diagram
establishment
shown in Figure 5:
System main object class to "chat interface
Accept information class
-information
+acceptinformation(in information : string)

Chat interface
-font
Accept Server class -fontsize
1 1 -fontsytle 1 1 friend information class
1 Accept
-all-name : String -information
-fontcolor
-all-ip : String
* * -submit * * -acceptFriendinformation()
+accept() -sentdataframe
*
-acceptdataframe
* -renewFriend()
Server class 1
-storeinformation
* 1*
-storeInformation
-accept()
-sent() *
#storeInformation() 1 *
1 1
* Sent information to server class
-name : string(idl) Sent friend information class
n -ip : String
-imformation
* -sentNameandIP(in name : string, in ip : string)
* * -sentFriendinformation()

Sent information class


-information
+sentinformation(in information : string)

Figure 5. Class diagram

4.2 UML to build dynamic model information from.


Purpose is to write a script that lists the user 3) When the server detects when the user
and system interaction, writing scripts. requires a connection, the user's friends to send the
Normally script: user information.
1) A user opens a login screen, set the 4) The user knows the IP address of a friend
server network parameters, the connection to the and a communication port can communicate with
server was successful. your friends. Call the "send a message to a friend
2) User open a communication interface, category," will send out the information to be
the user invokes the "send a message to the server transmitted, and friends waiting to receive the reply
class." "Send a message to the server class" will message.
own IP address and communication port to send to Exceptions script:
the server, and the server waiting to receive the 1) A user opens a login screen, set the

492 © Metallurgical and Mining Industry, 2015, No. 6


Information technologies
server network parameters, and server connection 4) The user knows the IP address of a friend
errors. and a communication port can communicate with
2) "Send a message to the server class" your friends. But call the "send a message to a
does not own IP address and communications port friend category," information to be transmitted
to send to the server, waiting for information from cannot be sent out; we did not receive a reply
the connected server. message.
3) The server is not listening to user Based on the above analysis of the script,
requirements for connection, not the user's friends draw the following diagram describes the sequence
to send information to the user. of events for each interaction system.

Sent friend information Accept information Accept server Sent information server
Chat interface Server class
class class Information class class

renewFriend()

sendinformation(IP ,name)

sentAllFriend()

sentFriend(information)

acceptFriend(information)

Figure 6. Interaction events of all system

5. Conclusions systems, etc. Since the data transmission between


This paper has deeply studied the model of the LAN instant messaging systems may need the
a centralized server communication system firewall, the paper presents the system sends data
problem in a distributed multi-service instant to the other local server by calling a remote Web
messaging system model. Use of C/S and P2P server, data transfer functions. This paper designs a
mixed mode, a distributed instant messaging distributed multi-server instant messaging system,
system. System Login can select the server when which ensures the integrity of user information to
the server is disconnected, you can select the server users on multiple servers’ registration information
to log in again. To achieve the LAN behind a to be consistent.
firewall or proxy server restrictions instant Acknowledgements
messaging services, or when outside the LAN This work was supported by the Science
connection is disconnected, even if a user can also and Technology Department in Tangshan in China.
communicate with each other on the same LAN. (13110203b).
Distributed multi-service instant messaging system References
model is proposed in this paper that given the 1. Xie M.J. (2012) Secure instant messaging
specific design of the model. This is including: in enterprise-like networks, Computer
application structure model, instant messaging Networks, 56(1), p.p.448-461.
format system user identification rules and 2. Jorrit S. (2010) A Massively Scalable

© Metallurgical and Mining Industry, 2015, No. 6 493


Information technologies
Architecture for Instant Messaging & 6. Zhang W.L. (2009) Design and
Presence. Electronic Notes in Theoretical Implementation of P2P Enterprise Instant
Computer Science, 261(1), p.p.109-130. Messaging System. Applied Mechanics
3. Donal C. (2007) Building a secure instant and Materials, 687-691, (4), p.p. 2740-
messaging environment. Network Security, 2743.
2007 (1), p.p.18-20. 7. Zhou X. (2010) Understanding the Nature
4. Zhang H. (2013) A Method for Detecting of Social Mobile Instant Messaging in
and Blocking Instant Messaging Software. Cellular Networks. Communications
TELKOMNIKA, 11(10), p.p. 5684-5693. Letters, 18 (3), p.p.389-392.
5. Zhang H. (2010) Research on detection of 8. Elena V. (2012) A distributed system for
instant messaging software. International learning programming on-line. Computers
Symposium on Information and & Education, 58(1), p.p. 1-10.
Automation. 86(1), p.p.664-669..

494 © Metallurgical and Mining Industry, 2015, No. 6

You might also like