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:
-
Remove unnecessary characters in a regular interval.
-
Transform each group of 6 characters into an integer using base 41.
-
Map each cipher number onto a similar plain-text number.
-
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)
- "lyrebird.server.c" : contains the main loop function for the server side:
- accept new clients regularly and assign tasks to them;
- continuously receive messages from clients and write them to the log file;
- wait for all clients to finish their tasks;
- exit.
- "lyrebird.client.c" : contains the main loop function for the client side:
- use fork function to create child processes to decrypt each tweet file;
- 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.
- Unzip all the files into one folder and cd into it.
- Run command
make
to link and compile the source files. - Run command
./lyrebird.server <config_file> <log_file>
to set up a server.- (e.g. "./lyrebird.server config_file.txt log_file.txt")
- 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")
- Run command
make clean
to remove all intermediate files.
- 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.
Beej's Guide to Network Programming
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.
- Name : Chong Guo
- Student ID : 301295753
- SFU username : armourg
- Lecture section : D1
- Instructor : Brain G.Booth
- TA : Scott Kristjanson