Coder Social home page Coder Social logo

p2p-image-app's Introduction

Distributed-Systems-Fall19

OpenCV 2 Boost v1.66+ Qt 5.12.6

Authors

  • Khaled Soliman
  • Mohamed Ads
  • Khloud Ghattas
  • Ahmed

p2p-image-app's People

Contributors

khaledsoliman avatar khloudz avatar mobsella avatar

Watchers

 avatar  avatar

p2p-image-app's Issues

RPC protocol

Marshaling and unMarshalling of messages between the client and the server

  • - Static function serialize message object
  • - Static function deserialize message object
  • - Base64 encode data
  • - Base64 decode data
  • - Convert integers to hex
  • - Fragmentation of large data
  • - RPC_ID
  • - Propagate exceptions to client/server with transparency

Steganography and Data Structures

  • In this exercise you are required to design and implement an Image Service that is capable of
    storing a special type of image files (although it appears as a normal JPG or PNG file).
  • The service should receive an image from a client together with a set of attributes to be embedded seamlessly into the image using steganography techniques. Steganography is a technique of concealing data inside another data, and is extensively being used in media whereby secret data can be hidden into an image files

Sockets

The client and the server programs should be built on top of an OO class hierarchy, which utilizes sockets and concurrency primitives.


The UDPSocket class encapsulates all the data and methods necessary to establish communication between two entities. This class acts as a parent class to the UDPClientSocket and the UDPServerSocket. Notice the wealth of methods for reading and writing from a UDP socket with different timeout options.


UDPSOCKET_H
#define UDPSOCKET_H
class UDPSocket
{
protected:
int sock;
sockaddr_in myAddr; sockaddr_in peerAddr; char * myAddress;
char * peerAddress;
int myPort;
int peerPort;
bool enabled; pthread_mutex_t mutex;
public:
UDPSocket ();
void setFilterAddress (char * _filterAddress);
char * getFilterAddress ();
bool initializeServer (char * _myAddr, int _myPort); bool initializeClient (char * _peerAddr, int _peerPort);
int writeToSocket (char * buffer, int maxBytes );
int writeToSocketAndWait (char * buffer, int maxBytes,int microSec );
int readFromSocketWithNoBlock (char * buffer, int maxBytes );
int readFromSocketWithTimeout (char * buffer, int maxBytes, int timeoutSec, int timeoutMilli); int readFromSocketWithBlock (char * buffer, int maxBytes );
int readSocketWithNoBlock (char * buffer, int maxBytes );
int readSocketWithTimeout (char * buffer, int maxBytes, int timeoutSec, int timeoutMilli);
int readSocketWithBlock (char * buffer, int maxBytes );
int getMyPort ();
int getPeerPort ();
void enable();
void disable();
bool isEnabled();
void lock();
void unlock();
int getSocketHandler();
~UDPSocket ( );
};
#endif // UDPSOCKET_H

Messages

This class encapsulates the state of the message to be sent between a client and a server. Notice the method “marshal” which converts the data members of an object instantiated from this class to a data stream. I recommend using a data stream format that avoids the null character as you may send binary data; a good candidate for that is the base64 format, and you can read about the base64 encode and decode here http://en.wikipedia.org/wiki/Base64. Of course there are other alternatives that you can use but you need to be very careful and have very good reasons for your choice.
The “unmarshalling” is carried out via the second parameterized constructor, which receives a base64 formatted character array. In exercise 1 you will not need to utilize the “operation” and “rpc_id” data members but they will be needed in the next phases of the project. The message type should be set by the client and the server objects whose class definitions are presented below. For exercise 2 you will definitely need to extend this class either through inheritance of through amendment to account for other data attributes of the media file to be transferred such as file name, file attributes, storage location, etc.


#ifndef MESSAGE_H #define MESSAGE_H
enum MessageType { Request, Reply}; class Message
{
 private:MessageType message_type; int operation;
void * message; size_t message_size; int rpc_id;
public:Message(int operation, void * p_message, size_t p_message_size,int p_rpc_id); Message(char * marshalled_base64);
char * marshal ();
int getOperation ();
ing getRPCId();
void * getMessage();
size_t getMessageSize();
MessageType getMessageType();
void setOperation (int _operation);
void setMessage (void * message, size_t message_size); void setMessageType (MessageType message_type); ~Message();
};
#endif // MESSAGE_H

Useful Resources

Useful Resources


To help you start with Linux, we have compiled a list of Linux resources that would help take you from novice stage to Kernel expert (as needed). The list is the work of the very large community of people who have worked with the Linux kernel.
For Starters
♦ Kernel Newbies: Intended to help new kernel hackers
♦ Linux Questions: A civil forum asking linux questions
♦ Ubuntu Support Forums: From the best-known consumer distribution of Linux, including a section for absolute beginners
Kernel News
• Linux Weekly News (LWN.net) Kernel Hacking
• Here is where you can get any kernel you want: Linux Kernel Archives at kernel.org
• The Linux Kernel Documentation Project
• The Linux Kernel by David A Rusling
• Linux Kernel Internals by Tigran Aivazian
• The Linux Kernel Hackers' Guide: HTML Linux Kernel Debuggers
• KDB: built-in kernel debugger with multiprocessor support
• Kgdb: kernel debugger used through serial line
Source Navigators
The source navigators provide browse-able kernel code, making it easier to read than your ssh window or emacs. However, the kernel is not necessarily the same version as the kernel you will be working with, so watch out for subtle differences.
• Linux Source Navigator
• Another Linux Source Navigator

Steganography
http://en.wikipedia.org/wiki/Steganography
http://easybmp.sourceforge.net/steganography.html
http://manytools.org/hacker-tools/steganography-encode-text-into-image/
http://www.maketecheasier.com/hide-confidential-data-inside-images-in-linux/
http://www.findbestopensource.com/tagged/Steganography
http://punkroy.drque.net/PNG_Steganography/SteganographyC.php
C Language Resources
As Linux is written mostly in C, if you are unfamiliar with the language, we provide you with few links that will jump-start your C capabilities in no time.
• C programming.com
• ANSI C On Unix Systems
• Common C Problems
• C Frequently Asked Questions
• This includes a tutorial and full reference to C: Programming In C: Unix System Calls and Subroutines in C

Client

Client: this takes the name of the server computer as an argument (i.e. at the command line).

  • It repeatedly requests a string to be entered by the user,
  • and uses message to send the string to the server, awaiting a reply.
  • Each reply should be printed out.

The Client class encapsulates the client functionalities. It has an instance of the UDPClientSocket class, which implements the UDP client. The constructor receives the host name that the server process resides on as well as the port number. The execute method receives a message which is transmitted for remote execution, and the reply message is returned. Prior to sending the request, the message type should be set as a “Request”. The type of the message received as a reply should be checked and its type should be a “Reply”. All the network operations details should be encapsulated inside the execute method, and the calling routine should not be aware of the remote execution.


#ifndef CLIENT_H #define CLIENT_H
class Client
{
private:
UDPClientSocket * udpSocket;
public:
Client(char * _hostname, int _port); Message * execute(Message * _message); ~Client();
};
#endif // CLIENT_H


This class represents a client UDP socket and it inherits from theUDPSocket class. It has an initialization method that initializes the UDPSocket in a client mode.


#ifndef UDPCLIENTSOCKET_H #define UDPCLIENTSOCKET_H
class UDPClientSocket : public UDPSocket {
public:
UDPClientSocket ();
bool initializeClient (char * _peerAddr, int _peerPort);
};
~UDPClientSocket ( ); #endif // UDPCLIENTSOCKET_H

Functional Requirements

  • Users can only see their own images that they uploaded,
  • Users can see images that have their usernames hidden into them.
  • Each time a user views an image, the number of views needs to be updated inside the image - - [ ] The user is denied view to the image when the number of views gets consumed.
  • The owner of the image has the right to update the image data by:
    • adding users to the image
    • removing users from the image
    • changing their viewing quota.
  • users can retrieve a list of their own images
  • users can retrieve a list of all the images they can view
    • with the remaining view quota for each image
  • (The use of robots that roam the service to collect such data is encouraged). Such facility
    would provide for reconstructing permissions should a failure happen to one of the peers.

Server

Server:

  • 1. repeatedly receives a string using GetRequest
  • 2. prints it on the screen
  • 3. and replies with SendReply.
  • 4. The server exits when the string consists of the single character `q' is first received.

The server class encapsulates all the server operation. The constructor receives two parameters, which indicate the interface and the port that the server should listen on. The public method “serveRequest” should block upon calling it until a message is received from a client. The message type needs to be checked and verified that it is of type “Request” message. The method will use the three private methods “getRequest”, “doOperation”, and “sendReply” to execute the received request and send the results back to the client. All deserialization/unmarshalling and serialization/marshalling should take place inside “getRequest” and “sendReply” methods respectively. The “handleRequest” method acts as a dispatcher, which might need to instantiate more objects from different classes based on the message operation id to be able to perform the request tasks. For exercise 1, the logic of the echo server should be implemented inside the “doOperation” method without the need for the dispatcher. Prior to sending the reply, the message type should be set as a “Reply”.


#ifndef SERVER_H #define SERVER_H
class Server
{
private:
UDPServerSocket * udpServerSocket; Message * getRequest();
Message * doOperation();
public:void sendReply (Message * _message);
Server(char * _listen_hostname, int _listen_port); void serveRequest();
~server();
};
#endif // SERVER_H

Graphical User Interface (GUI in QT)

  • GUI using QT library in C++
    • Download the QT Editor
    • The client need to have a GUI interface whereby it can initiate requests to the image service.
    • Authentication Module
    • Directory of users Module

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.