Coder Social home page Coder Social logo

gasshow1325 / rtp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rovinbhandari/rtp

0.0 0.0 0.0 107 KB

Implementation of a simple Remote Timestamp Protocol (RTP) client and multi-threaded server using UDP as the transport layer protocol.

C 97.36% Shell 2.64%

rtp's Introduction

Simple RTP Client+Server
========================

Description
-----------
RTP stands for Remote Timestamp Protocol. The implementation of RTP
consists of a client application and a server application; the client
can ask for the (last modified) timestamp of a file on the remote
machine while the server satisfies that request.
RTP uses User Datagram Protocol (UDP) as its transport layer protocol.

High-Level Implementational Details
-----------------------------------
The server creates a socket in the internet domain bound to port
SERVER_PORT. The server receives requests through this port,
processes the requests and replies to the client which had made the
request. The client also creates a socket in the internet domain,
sends requests to SERVER_PORT of a given IP address (i.e., server's
IP address), and receives replies and displays results obtained from
the server. The state-machines for a single connection for client and
server are as the following:
	Client side protocol state machine:
		|
		| begin
		|
	    ____V_____
	    |        | 
	    | closed |________
	    |________|        \ startup, request
		/\             \
		|               \ 
		|	         |
		|           _____V_____
	done/	|           |         |
done_acknowledgement        | request |
		|           |  sent   |
		|           |_________|
	        |                |       
		|                |
		|                |
	    ____|____            |
	    |       |           /
	    | wait, |          / request_acknowledgement
	    | done  |/________/
	    |_______|\
	
	Server side protocol state machine:
		|
		| begin
		|
	    ____V_____
	    |        | 
	    | closed |________
	    |________|        \ request, request_acknowledgement
		/\             \
		|               \ 
		|	         |
		|           _____V_____
		|           |         |
    done_acknowledgement    |   new   |
		|           | request |
		|           |_________|
	        |                |       
		|                |
		|                |
	    ____|____            |
	    |       |           /
	    | done  |          / query file timestamp, done
	    | sent  |/________/
	    |_______|\

The server handles each client with a separate thread; the main thread
of the server spawns a new thread at a new incoming request. Since UDP
is connectionless, the incoming datagrams are matched to their threads
using connection_id. The threads the server can spawn are bounded by an
upper limit (i.e., the threads reside in a finite-sized thread pool).
Threads are not made to wait on spin-waiting loops, conditional-wait
with mutex has been used to make threads wait and to notify a waiting
thread. A thread after serving a client goes back to the pool of
available threads. If the pool of available threads becomes empty at
some stage and a new incoming request is pending, that request is
dropped (which is justified since the underlying transport protocol is
UDP anyway).
The information between the client and the server is exchanged by means
of custom packets. A packet has the following fields:
	1. connection_id
	   : given by the server if the request is a valid one and
	     there is at least one thread in the pool of
	     available threads.
	2. type
	   : varies among
	   	REQU (request)
		RACK (request_acknowledgement)
		DONE (done)
		DACK (done_acknowledgement)
	3. status
	   : determines the success or failure of finding the
	     timestamp of a file.
	4. buffer
	   : contains data (garbage value if the packet is
	     a control packet only).
Since the byte order of the client, server and the network can all
vary, the packets are converted to native architecture supported
byte order when received and to network byte order at the time of
sending.

rtp's People

Contributors

rovinbhandari 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.