GithubHelp home page GithubHelp logo

springhhh / cmpt300 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from armour/cmpt300

0.0 1.0 0.0 227 KB

This is the repository for course CMPT300 assignments in SFU

Makefile 0.55% C 83.58% C++ 15.88%

cmpt300's Introduction

Lyrebird

lyrebird

Description

This program aims to decrypt large numbers of encrypted tweets. The program uses a distributed system with client-server architecture to take advantages of multiple machines. The server assigns tasks to the clients and stores messages in the log file. The client decrypts each task assigned and sends the result message back to the server. The program takes advantages of multiple CPU cores by allowing each client to use the fork function to allocate the decryption tasks across multiple processes and pipes to communicate between the parent and child processes with "first come first serve" scheduling algorithm.

Each tweet’s decryption follows four steps:

  1. Remove unnecessary characters in a regular interval.

  2. Transform each group of 6 characters into an integer using base 41.

  3. Map each cipher number onto a similar plain-text number.

  4. Get the final decrypted text by using the inverse function of Step 2.

(More details can be found in Assignment 4 Outline - A Distributed Flock of Lyrebirds)

Project Structure

  • "lyrebird.server.c" : contains the main loop function for the server side:
    1. accept new clients regularly and assign tasks to them;
    2. continuously receive messages from clients and write them to the log file;
    3. wait for all clients to finish their tasks;
    4. exit.
  • "lyrebird.client.c" : contains the main loop function for the client side:
    1. use fork function to create child processes to decrypt each tweet file;
    2. continuously communicates with the server side.
  • "svr_func.c" : contains server side functions
  • "cli_func.c" : contains client side functions
  • "scheduling.c" : contains a single 'fcfs' scheduling algorithm for assigning tasks to the child processes in the parent process.
  • "decrypt.c" : contains a decryption function of 4 steps. In each step, the decryption function calls functions in dec_func.c to handle decryption.
  • "dec_func.c" : contains functions for decrypting the tweets, such as removing extra characters,and transforming between characters and integers.
  • "line_io.c" : contains two functions for input/output one line of data from/to files
  • "memwatch.c" : mainly for un-freed memory detection, overflow and underflow to memory buffers.

How to Use

  1. Unzip all the files into one folder and cd into it.
  2. Run command make to link and compile the source files.
  3. Run command ./lyrebird.server <config_file> <log_file> to set up a server.
    • (e.g. "./lyrebird.server config_file.txt log_file.txt")
  4. Run command ./lyrebird.client <ip address> <port number> to set up a client and connect it to the server (multiple clients supported).
    • (e.g. "./lyrebird.client 207.23.199.37 58295")
  5. Run command make clean to remove all intermediate files.

Robustness

  • Check the number of command line parameters.
  • Check the existence of input and output file.
  • Dynamically manage memory and gaurantee to free all when program finishs (also check any failure of malloc function).
  • Check IP address and port number.
  • Parent process does not exit until all the child processes terminate.
  • Server does not exit until all the clients quit.
  • Close all unnecessary pipes in each process.
  • Test empty data and largest data.

Reference List

Beej's Guide to Network Programming

Linux man page

Plagiarism

This repo is intend as a reference for your personal project, DO NOT copy code in this repo for your SFU CMPT413 assignment!! Plagiarism is a serious academic offense, which applies as much to code as it does to essays and exams.

Author Information

  • Name : Chong Guo
  • Student ID : 301295753
  • SFU username : armourg
  • Lecture section : D1
  • Instructor : Brain G.Booth
  • TA : Scott Kristjanson

cmpt300's People

Contributors

armour avatar davidnazw avatar jupiy 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.