Sei sulla pagina 1di 13

MINOR PROJECT-I

End-Semester Report

ON

File Transfer and Communication within a Network

Submitted By

Damini Parihar Anurag Tripathi Abhishek Singh


500046177 500046287 500048091

Under the guidance of

Mr. Ravi Prakash


Assistant Professor (Selection Grade)

Department of Cyber Platforms


School of Computer Science and Engineering,
UNIVERSITY OF PETROLEUM AND ENERGY STUDIES
Dehradun-248007
December - 2017
School of Computer Science and Engineering,
University of Petroleum & Energy Studies, Dehradun

End Semester Report (2017-18)

Minor-I

Project Title: File Transfer and Communication within a Network


using Socket Programming.

Abstract:
Sockets play a vital role in client server applications. The client and server can communicate
with each other by writing to or reading from these sockets. One socket (node) listens on a
particular port at an IP, while other socket reaches out to the other to form a connection. In
this project, we have designed software which allows the file transfer across two nodes and
also the communication between them in the form of a chat forum. This will further be
optimized by compressing and decompressing the file at the sender and receiver node
respectively using the Huffman code mechanism.

Keywords: Socket, File Transfer, Huffman Code

Introduction:

A socket is the mechanism that most popular operating systems provide to give programs
access to the network. Network program can do lots of work. A simple network Program can
obtain information from many computers located all over the world. It can communicate with
millions of people around the world.
It allows messages to be sent and received between applications (unrelated processes) on
different networked machines. Network programming uses Client-Server model, so network
programming is also Client Server Programming. Where one program starts the
communication called client process or program and other who is waiting for communication
to start called the server process or program. In the simplest case, Client program sends the
request to the server. Server sends the response. Client then obtains the data from the server
and displays it. The Client-Server interaction allows efficient file transfer and also facilitates
real time chatting.
Problem Statement:

● It has always been a requirement in the case of data communication to have


the secure file transfer between any two nodes in the communication network,
and this has been accomplished in this project work.
● Also, it was not much easy to send the files of large size across the nodes in a
network; so a mechanism is required to ensure the efficient transfer.

Literature Review:
There are various file transfer techniques available in today’s world but all of them possess
some kind of issues and flaws.

● Email: Sending files via email is quite popular but all the major email providers like
Gmail, AOL Mail, and Yahoo!
● Cloud based files sharing: This is certainly the most convenient way to share files of
larger size but in a world full of cybercriminals this is not the most secure option.
● FTP: Data sent via FTP is vulnerable to sniffing, spoofing and brute force attacks,
among other basic attack methods. (Reference :https://digitalguardian.com/blog/what-
ftp-security-securing-ftp-usage).

Objectives Achieved:

● Communication across the nodes is enabled


● Transfer of file from one node to another node is made possible
● Compression of file is made possible using Huffman Code Algorithm.
● Decompression of Compressed File.

Methodology:
▪ One user will act as a server and other as a client. Thus, transfer of files and
communication will take place between the Server and the Client.

▪ Spiral Model will be used to complete the objective of this project. This model has
been chosen for two of its special feature i.e. PROTOTYPE DEVELOPMENT and
RISK ANALYSIS.

▪ The stages involved in Spiral Model are :


(i) Determining the objectives
(ii) Identifying and resolving the risks
(iii)Development and Testing
(iv)Planning the next Iteration
SDLC Model Used:
Algorithms Used:

Socket Programming:

Client Side:
 Create a socket with the socket() system call.
 Connect the socket to the address of the server using the connect()
system call.
 Send and receive data. There are a number of ways to do this, but
the simplest way is to use the read() and write() system calls.

Server Side:

• Create a socket with the socket() system call.

• Bind the socket to an address using the bind() system call. For a
server socket on the Internet, an address consists of a port number
on the host machine.

• Listen for connections with the listen() system call.

• Accept a connection with the accept() system call. This call


typically blocks the connection until a client connects with the
server.

• Send and receive data using the read() and write() system calls.
Flowchart for Socket Programming:
Huffman’s Coding Algorithm

Huffman’s algorithm constructs a binary coding tree in a greedy fashion, starting with the
leaves and repeatedly merging the two nodes with the smallest probabilities. A priority queue
is used as the main data structure to store the nodes. The pseudocode appears below.
Algorithm 1: Huffman Coding Input: Array f[1...n] of numerical frequencies or probabilities.
Output: Binary coding tree with n leaves that has minimum expected code length for f.
huffman(f[1...n])

1. T = empty binary tree

2. Q = priority queue of pairs (i,f[i]), i = 1...n, with f as c

3. for each k = 1...n−1

4. i = extractMin(Q)

5. j = extractMin(Q)

6. f[n + k] = f[i]+ f[j]

7. insertNode(T,n + k) with children i,j

8. insertRear(Q,(n + k,f[n + k]))

9. return T
Sending and Receiving of File:

On Server’s End:

File named ‘sendfromserver.txt’ is send from server to the client.

File named ‘output.txt’ is received on server’s end , which was sent from the client.
Communication within the network:

Chat-Forum:

‘User’ & ‘Server’ are involved here for communication.


2017
Compression and Decompression of a File:

Compression

A file ‘sample1.txt’ is taken to compress. Before compressing its size is 25.6 KB. After this
we run our file compression code.

Now we execute the code on terminal to compress the file named as ‘sample1.txt’.

In the following image we are encoding the file ‘sample1.txt’. After execution of this a new
file named as ‘sample1.txt.zip’ was created.
In this figure we can see the size of the file ‘sample1.txt.zip’ whose size is 16.8KB.

Result:
File Size before Compression: 25.6KB
File Size after Compression: 16.8KB

Decompression

We now take the compressed file ‘sample1.txt.zip’ and perform decompression on it.
A new file named as sample1.txt.zip.txt is formed.

Result

File Size after Compression: 16.8KB


File Size after Decompression: 25.6KB
References:

[1]https://pdfs.semanticscholar.org/9ef9/c58042b19d44b428803a5a6c82ecb91b85ca.pdf
[2]https://www.2brightsparks.com/resources/articles/ssh-file-transfer-protocol-explained.pdf
[3] https://gist.github.com/ozcanovunc/e3dda9c0886321fcc6ee
[4]https://stackoverflow.com/questions/18489271/socket-programming-in-cclient-server-
example
[5]http://ijcsit.com/docs/Volume%205/vol5issue03/ijcsit20140503462.pdf
[6]Software Engineering, Pearson Education; Tenth edition by Ian Sommerville
[7]Data Communication and Networking, McGraw Hill Education; Fifth edition by Forouzan
[8]UNIX Network Programming: The Sockets Networking Api, PHI Publications by Bill
Fenner

Approved By

(Name & Sign) (Name & Sign)

Project Guide Program Head

Potrebbero piacerti anche