0% found this document useful (0 votes)
139 views

UDP Based Chat Application

This document discusses building a UDP-based chat application that enables features like acknowledgments, multicasting, and file sharing. It begins by introducing UDP as a connectionless protocol and describing how it is useful for applications with many clients that require small, frequent responses from servers. The document then discusses using socket programming to implement network communication and build a chat application with client and server components. It proposes a method for a UDP-based chat room that enables acknowledgments after each message is sent.

Uploaded by

Juan Gonzalez
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views

UDP Based Chat Application

This document discusses building a UDP-based chat application that enables features like acknowledgments, multicasting, and file sharing. It begins by introducing UDP as a connectionless protocol and describing how it is useful for applications with many clients that require small, frequent responses from servers. The document then discusses using socket programming to implement network communication and build a chat application with client and server components. It proposes a method for a UDP-based chat room that enables acknowledgments after each message is sent.

Uploaded by

Juan Gonzalez
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

UDP Based Chat Application

Akshit Malhotra Vaibhav Sharma Prateek Gandhi Dr. Neetesh Purohit


Information Technology Information Technology Information Technology Information Technology
IIIT Allahabad IIIT Allahabad IIIT Allahabad IIIT Allahabad
Allahabad, India Allahabad, India Allahabad, India Allahabad, India
[email protected] [email protected] [email protected] [email protected]

Abstract—UDP is a connectionless oriented transport layer TCP is connection Oriented protocol while UDP is
protocol. Since TCP doesn't provide the feature of connectionless protocol [6]. UDP protocol is a simple
Multicasting UDP is a widely used protocol to implement it. connectionless protocol that can be used to transfer datagram
UDP's stateless nature is useful for servers that answer small packets between sender and receiver in both the direction i.e.
queries for large number of clients. Socket network
programming is one of the most popular technologies used to
client and server can send and receive datagram packets to
build a chat application and establishing network each other. User Datagram Protocol transports the data
communication between systems. Socket programming helps to between the computers in the form of data packets, but it
implement the bottom level of network communication, using does not track the data and never shows the confirmation
Application Programming Interface (API). In this paper we report as shown in Fig 1. Many of the streaming applications
propose a method to make a chat room using socket based on run using UDP, but they have built-in acknowledgments and
User Datagram Protocol (UDP) which enables the feature of retransmissions into the application in order reduce packet
acknowledgments after every message sent. It is equivalent to loss. And file sharing through UDP also alleviates the
a dedicated chat server having a Server and n number of problems occurring in TCP. UDP [7] has a very basic and
Clients. After client and server set up to connect, you can
achieve many machines to communicate through peer to peer
simplified header which has only 8 bytes of overhead as
communication, multicasting and File sending. During compared to 20 bytes in TCP (in order to guarantee
communication taking place there might be different system reliability).
and network failures occurring , which we have discussed and UDP is considered to be very useful in some
proposed a convenient solution for that. This system designed circumstances, especially in speed and network management.
with Java achieves a satisfying and efficient communication The fact that UDP lacks built-in reliability mechanisms can
between the users by experimental verification. be considered as an advantage from the application
designer's point of view. That is, communication between
Keywords-Chat Application, File sending, Multicasting, application processes can be achieved reliably without being
Transport Layer, UDP.
constrained by the transmission rate constraints imposed by
TCP's congestion control mechanism. UDP has a lower
I. INTRODUCTION latency as compared to TCP because it doesn’t wait for any
Open system interconnection (OSI) [1, 2] model is a lost packets whereas TCP waits for the lost packets until the
concept that describes how the data communication takes in transmission timeout occurs as shown in Fig 2. The most
a network. It consists of seven layers each performing some important feature regarding UDP is that it supports
set of functions regarding how a process gets completed in Multicasting and Broadcasting which can’t be implemented
the Network. OSI layer’s consist of physical, data link, in TCP protocol. Now in further paper we will look at the
Network, Transport, Session, Application and presentation past works and applications related to UDP .
layers. The transport layer [3, 4] is the fourth layer of the
OSI reference model which provides transparent transfer of II. RELATED WORK
data between end systems using the services of the network UDP is used only a few percent in a typical network.
layer. It is layered just below the ‘Session’ and sits above the There are some internet applications that use UDP such as
IP (Internet Protocol) in (OSI) model. This layer is Domain Name System (DNS) [8], Simple Network
interesting in a sense that it resides in the architectural center Management Protocol (SNMP) [8], Dynamic Host
of the model. Accordingly, it represents an important Configuration Protocol (DHCP) [8] and the Routing
transition point between the hardware-associated layers Information Protocol (RIP) [8]. Many chat room based
below it and the layers above that are more software-oriented application have been proposed like outlook, win popup,
and abstract. The transport layer helps layers above it, akeni but mostly all of them are implemented using TCP
providing them cost effective data transfer and reliability. It protocol which is considered reliable but doesn’t provide the
enables end-to-end control and information transfer which speed and Multicasting as such. For real time voice and
can be implemented in all the End Systems (ES). In general video streaming application UDP is preferred over TCP
there are two transport layer protocols TCP (Transmission because of its higher speed. This application doesn’t have
Control Protocol) and UDP (User Datagram Protocol). UDP
is a connection less transport layer protocol which supports
Network Application and establishes network
communication [5].

c
978-1-4244-6349-7/10/$26.00 2010 IEEE V6-374
A. Unicasting
Unicast transmission is the sending of messages to a
single network destination host as shown in Fig 3. This
method solves network traffic problems to deliver messages
from one host to another. So, we can say that this is one-to-
one data delivering method. For better understanding,
consider a situation where one computer’s request for a site
is received by all connected to the Internet. This way you are
actually flooding the Internet with such requests. Hence, you
Figure 1. TCP need Unicast transmission [12] for small and large networks.
Examples of Unicast transmission are HTTP, SMTP, etc and
it is still predominant in LANs.
B. Broadcasting
Broadcast [11, 12] is a type of transmission where data
sent by one host is received by every host present in the
network as shown in Fig 4. Taking the case of Dynamic
Host Configuration Protocol in which when a system boots
up and requests for an IP from DHCP server which system
is not aware of so it broadcasts the request of an IP
Figure 2. UDP
throughout the network. It is used to send same message to
all computers in LANs, e.g. Address Resolution Protocol
any impact on loss of a single packet. Chat applications (ARP) uses this technique to send an address resolution
using UDP socket has been made, but that doesn't have query to all. Most routers designed these days’ blocks IP
features of sending files and real time audio, video chat from broadcast traffic and restrict it to the local subnet.
one peer to another. Most of the modern multiplayer games C. Multicasting
[9] use UDP broadcast to start game, send messages and
information to other players. Another popular use of UDP is In this method, you can transmit data or messages to all
a tunneling protocol [10]. A tunnel endpoint encapsulates destination host machines, which has been interested an
the packets into UDP and transmits them to tunnel endpoint appropriate multicast group. The sender generates only one
which encapsulates the UDP datagram’s and forward the data stream but it delivered to all destination hosts in the
original packets. Tunnels are used to create virtual links that group as shown in Fig 5. It supports one-to-many data
looks like a direct connection between two locations that are delivering networks.
distant in the physical internet topology. Multicast [11, 12] delivers a data or information
simultaneously to all interested destination hosts machines.
III. TRANSMISSION METHODS Multicast is placed in a class 'D' IP address which has
addresses space from 224.0.0.0 to 239.255.255.255. In our
This section introduces you how to deliver or transmit
implementation we have generated a group IP for every
data in network and describes the fundamental of various
multicast group to communicate in a group. Whenever a
techniques like: unicast, broadcast and multicast. There are
client wants to create a group, server would provide an IP in
numerous methods for delivering or transmitting data in the
the above given pool of IP's and store the information (IP
network as discussed below.
and Port Number) of all the clients in the group. One good
example of Multicast based network is video transmission in
which one computer needs to transmit video channel to a
specific group of computers. This way, other computers
which are part of this Multicast IP network will be able to
receive same set of data at the same time. Multicast offers
savings on bandwidth and is the preferred way of data
Figure 3. Unicasting communication when data is to be transmitted to a set of
computers. Unlike broadcast transmission, multicast clients
receive stream of packets only if they have previously
elected to do so (by joining the specific multicast group
address). Membership of any group is controlled by the
receivers and is dynamic in nature.
IV. FILE SHARING
Some Peer-to-Peer (P2P) file sharing operation models
Figure 4. Broadcasting over asymmetric networks have several shortcomings that

[Volume 6] 2010 2nd International Conference on Computer Engineering and Technology V6-375
sending a file and creates a room where users selected by
him interact with each other.
A. Peer to Peer Communication
This module refers to communication between any two
clients. Sender sends the request containing its name and a
generated random port to the receiver. After receiving the
sender’s request at the receiver’s end communication is
Figure 5. Multicasting established by starting a thread on both sides. When a
network gets established between peers, a counter will be
may have a significant impact to the system and network initialized at both the sides which will depict the sequence
performance. Paths on which data transmission occurs are number of the packet. For every packet sent on either side
highly redundant, thereby wasting a lot of bandwidth. The there will be an acknowledgment from the other side which
downloading throughput of the peer node is limited by the will increase the counter with 1. So if any kind of failure
upward bandwidth of other peer nodes. Since in TCP each occurs as discussed later can be identified and a packet may
and every packet is being followed by an acknowledgement be sent again. For example: If A sends a message with
packet on the upward channel which results in the deteriorate sequence number 10 to B, B will reply back with an
of performance in sending a file .These shortcomings acknowledgement with sequence number 11.
severely effects the efficiency of Peer to Peer file sharing as
well as network performance. Peer to Peer File transfer B. Multicasting
between the client's will be in the various number of packets This feature can be implemented using the multicasting
.Whole file would be broken into chunks of binary data concepts. When a user wants to create a chat room for
which would be send to the destination where it would be multiple users, it sends a request to the server. Server then
combined to form a complete file. acknowledges this request by providing a group IP and sends
the information about the room to all the concerned users.
V. PROPOSED SOLUTION Now, in this room whenever a user wants to send a message
We have implemented this using Java platform which it will be multicast to all the users through the group IP.
would be through Socket Programming. Our solution Server-Client Model as depicted in the figure 6 shows
includes features like peer to peer communication, client’s k1, k2, k3 establishing connection with the server.
multicasting and files sharing. The chat application is a client When another client k4 sends a request to join, server
server model as shown in figure 6. processes its request by adding its information in the table
Server: We maintain a thread at server side which i.e. Name and IP. Similarly, as client k1 logs out, server
receives various incoming clients request. It stores the deletes the entry related to k1 and correspondingly updates
information of the clients i.e. IP address and name in a list. the table.
This list is then broadcasted to all the users. Contrary to this, C. File Sending
whenever a client logs out, it deletes that particular client
entry from its list and updates it accordingly. It also keeps In this module there would be feature in our chat window
track of various chat rooms, providing a group IP to each which would allow the user to send a file through the
multicast group. network to the other user. When any user wants to send a file
to other user a message would appear on the receiver’s side
that whether he/she wants to accept it or not. After the
acceptance from the receiver whole file would be read and
send it to the receiver in the segments of 65,000 bytes and
finally at the receiver’s end the segments would be received
and stored in a buffer and clubbed according to the sequence
number. There would be confirmation message after
receiving the file.
D. Failure Model
During our implementation, we incurred various kinds of
failures for which we proposed the solution in the following
manner. As depicted in the Fig 7, we have discussed both
system and network failure. In system failure, either a server,

Figure 6. Server-Client Model

Client: It first registers itself by sending its username to


the server and starts a thread which receives list of all online
users from server. Each user has an option of establishing a
peer to peer communication with any of the online user,

V6-376 2010 2nd International Conference on Computer Engineering and Technology [Volume 6]
sender or receiver may get failed due to some unforeseen the implementation was to identify the packets which we
handled by accompanying the packet with a particular type
of string. Cryptographic algorithms [13] can be used to
secure the data and files that are being sent from one peer to
another. To increase the robustness we have used
acknowledgments with every packet being sent. This design
has some basic requirements of a chat room like instant
messaging, multicasting and file sending. We get messages
in order which we sent.

Figure 7. Failure Model ACKNOWLEDGMENT


The authors wish to express sincere thanks to the director
reasons. We have discussed following stages in our Mr. M.D. Tiwari and our project supervisor Dr. Neetesh
failure model- Purohit for providing excellent computational infrastructure
• Stage 1: It belongs from time t0 to t1 which and stimulating environment in accomplishing this research
corresponds to buffering time of the packet at sender work.
side. During this stage, if a sender gets failed, then
packet would not be sent and gets stored in the REFERENCES
queue. This packet will be send only when sender [1] The OSI Reference Model.
side recovers back. Next, if receiver gets failed, then [http://www.thecertificationhub.com/networkplus/the_osi_ref_model.
packet will not be received. htm] (14/01/2010)
• Stage 2: It belongs from time t1 to t2 which [2] Andrew S Tannenbaum, “Computer Network”, Edition 4th, Dorling
Kindersley, 2006, pp 487-557.
corresponds to the time, packet is in the network i.e.
[3] TCP/IP Transport Layer Protocols.
the packet is sent from the buffer of sender but not [http://www.tcpipguide.com/free/t_TransportLayerProtocols.htm]
yet received. If at this stage, sender gets failed, then (01/02/2010).
no matter what message will be received. Next, if [4] Transport Layer Protocol.
receiver gets failed, then packet will not be received. [http://www.erg.abdn.ac.uk/users/gorry/eg3561/inet-
But this information about receiver failure is not pages/transport.html] (03/02/2010).
known to sender. For this problem, we have [5] Zhao-na Zheng and Peng Sun, Design and Implementation of Chat
implemented acknowledgment of each packet we room using UDP, FCC 2009, CCIS Volume 34 pp 235-239, 2009.
send from sender side. If we don’t receive the [6] What are the advantages of UDP over TCP?
acknowledgement at the sender side, then it means [http://wiki.answers.com/Q/What_are_the_advantages_of_UDP_over
_TCP] (05/02/2010).
receiver has failed. By this, we do know about
[7] UDP, User Datagram Protocol, Network Sorcery Inc,
receiver status at the sender side. [http://www.networksorcery.com/enp/protocol/udp.htm]
• Stage 3: It belongs from time t2 to t3 in which (26/01/2010).
packet has now arrived in the buffer of the receiver. [8] Wikipedia ,User Datagram Protocol.
At this stage, failure at sender won’t have any impact [http://en.wikipedia.org/wiki/User_Datagram_Protocol#Applications]
on the packet because it has already arrived in the (25/01/2010)
receiver buffer. Next, if receiver gets failed, then this [9] Anthony Volodkin, Playing Multiplayer Games over a VPN.
packet would be recovered when the receiver comes [http://non-standard.net/freebsd/game-vpn/game-vpn.html]
(22/01/2010).
up again.
[10] The User Datagram Protocol
During all these stages, if server gets failed then a (UDP).[http://www.erg.abdn.ac.uk/users/gorry/eg3567/inet-
message informing about server failure would be shown on pages/udp.html] (03/02/2010).
each client in the network. [11] Unicast, Broadcast and Multicast.
[http://www.erg.abdn.ac.uk/users/gorry/eg3561/intro-pages/uni-b-
VI. CONCLUSION AND FUTURE WORK mcast.html](03/02/2010).
UDP can be used in peer to peer communication and [12] James Wang, CpSc 360: Distributed and Network Programming,
multicasting. There is a system that acts as a server and it Chapter 20, 21 Broadcasting and Multicasting.
[http://www.cs.clemson.edu/~jzwang/0808360/cpsc36015.pdf]
also stores the user’s information (username and their IP (01/02/2010).
address). Server sends this information to all the online users. [13] An Overview of Cryptography.
A user can have conversation to more than one user
[http://www.garykessler.net/library/crypto.html] (02/02/2010).
simultaneously. One user can send a file to other user. Server
can multicast the data to the users. Problem occurred during

[Volume 6] 2010 2nd International Conference on Computer Engineering and Technology V6-377

You might also like