GithubHelp home page GithubHelp logo

guilhermedesousa / napster-java Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 17 KB

[ Java Project ] This is a simulation to represent a simple P2P system (Napster) designed to facilitate large files transfer among peers, facilitated by a central server, using the RMI and TCP protocols.

Java 100.00%

napster-java's Introduction

Napster

This project consists of a Peer-to-Peer (P2P) system developed in Java, allowing the transfer of large video files (MP4) transfer among peers.

The project is a simple implementation of a system that was very popular in the year 1999, known as Napster. It was also based on P2P file sharing, but with a focus on audio files.


Comunication

The data transfer between the parts of the system occurs through Remote Method Invocation (RMI) and the Transmission Control Protocol (TCP). The RMI is used for the peer-server communication, where the Peer invokes methods on the Server and receive responses. On the other hand, TCP is used for the video data transfer between peers.


Architecture

The system architecture is based on a centralized Server that keeps peer information such as IP address, port, and downloaded files, along with the Peers themselves.

1. Server

The server is responsible for storing the information of peers that join the network in a data structure, updating this information as peers perform download operations, and conducting searches for peers that possess the requested files.

1.1 Data structure

The storage of peer information is done non-persistently using Java HashMap. The selection of this structure is justified by its ease of storing data in a key-value mode and performing seaches based on specific keys.

  • key: file name with its extension
  • value: list of peers that contain the file

2. Peer

Peer is an entity capable to request video files from other peers in the network, as well as to provide files, done with TCP.

Threads

To make the system scalable and prevent process from becoming blocked, threads were employed within the peer entity.

To support multiple requests coming from other peers, each peer creates a thread named FileServerThread, which is responsible for accepting the connections initiated by other peers.

Support large video files

To transfer large video files, specifically those exceeding 1 gigabyte in size, the video's bytes is sent in small, separated packages.


Compilation

The compilation of the source code should be done in the terminal, compiling all the .java files simultaneously. Here's the suggested compilation code:

javac -d .\bin\ .\src\server\ServerInterface.java .\src\server\ServerImpl.java .\src\server\Server.java .\src\peer\Peer.java

Console operations

Server startup

java server.Server <ip> <RMI port>

Peer startup (JOIN)

java peer.Peer <ip> <port> <directory>

SEARCH operation in the Peer console

<file name with its extension>

DOWNLOAD operation in the Peer console

<peer ip>:<peer port>

Developed by Guilherme Santos

napster-java's People

Contributors

guilhermedesousa avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.