This is the web page for Fall 2020 Operation Systems Theory at the University of Oklahoma.
In this course, we have discussed how machines communicate with eachother. Several issues arise while managing communication between nodes. For this assignment, you will build a system to demonstrate client-server communication.
Your task is to set up three nodes — two clients and one server. Have each client send an “encrypted message” to the server and have the server print out the unencrypted message.
You may choose your own encryption scheme for your message. Messages may be numbers, bytes, or strings. We will use docker-compose, protocol buffers, and gRPC for setting up nodes and managing networking and communication. You may use any compatible programming language to write your code. As of today, docker and docker-compose are not available on the computer lab machines. You may install it on any laptop or inside of a virtual machine.
In a readme
file, you should describe your encryption message and the message that will be sent between systems.
To demonstrate the working system, record a video or annimated .gif
clearly show messages being sent and received across the systems.
Besure to clearly describe the contents of the video in the readme file.
To be clear, your code should demonstrate the following:
COLLABORATORS
fileThis file should contain a comma separated list describing who you worked with and text description describing the nature of the collaboration. This information should be listed in three fields as in the example is below:
Katherine Johnson, kj@nasa.gov, Helped me understand calculations
Dorothy Vaughan, doro@dod.gov, Helped me with multiplexed time management
http://examples.com/my-specific-example1, helpe be debug error
http://examples.com/my-specific-example2, helpe be architect classes
Submit all source code to a private github repository.
Submit a link to the private repository to Canvas.
Also, you must add @cegme
as a collaborator to the github project.
Code must accessable by the instructor to receive any credit.
The video/annotated .gif
should also be uploaded.
This is project may not be done in groups.
Any code copying is subject to the university’s academic dishonesty policy.
Any websites or discussion should be added to a COLLABORATORS
file.
readme
file 20%Errors or shortcomings in categories above will result in a reduction of percentage points removed.
To view your python logging code add the following line at the start of your program
logging.basicConfig(format='%(asctime)s %(levelname)s:%(name)s %(message)s', level=logging.DEBUG)
To request a machine sleep using Python, import the time package import time
and use the method time.sleep(seconds)
to sleep for a particular.
After creating an Ubuntu 20.04 instance on you google cloud machine.
You can install docker with
sudo apt install docker.io
sudo systemctl enable --now docker
sudo usermod -aG docker myusername
Run the docker hello world
docker run hello-world
Interactive
docker run -it ubuntu bash
More details here: Docs
sudo apt install docker-compose
Assuming you have one python file called node.py
that runs everything here is a template code you can use.
To run the code
docker-compose up --build
To tear down the machine
docker-compose down
To inspect a container called client1
docker exec -it client1 /bin/bash
FROM ubuntu:rolling
MAINTAINER cgrant@ou.edu
RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG en_US.utf8
RUN apt-get update && apt-get upgrade -y && apt-get install -y python3-pip ipython3
RUN apt-get install -y vim nmap iputils-ping ssh netcat htop slurm net-tools
ENV GRPC_PYTHON_VERSION 1.15.0
RUN apt-get install -y libprotoc-dev protobuf-compiler
RUN python3 -m pip install --upgrade pip && python3 -m pip install click grpcio grpcio-tools
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Build python stuff
COPY requirements.txt /usr/src/app/
RUN pip install --no-cache-dir -r requirements.txt
COPY . /usr/src/app
# Create the protobuf files
# RUN protoc --python_out=. rsa.proto # Code below works similarly
RUN python3 -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. rsa.proto
EXPOSE 22
EXPOSE 80
EXPOSE 50050-50100
# Unbuffer to see logs with docker logs <containername>
ENV PYTHONUNBUFFERED=1
# Run the node
CMD ["python3", "node.py"]
(This is an example file, you should customize this to fit your needs.)
syntax = "proto3";
package ousystems;
service SecureMessaging {
// Requests and returns the Public Key
rpc GetPublicKey (NullMsg) returns (PublicKey) {}
// Receives an Encrypt a message
rpc SendEncryptedMessage (EncryptedMessage) returns (MsgAck) {}
}
message PublicKey {
int32 n = 1;
int32 e = 2;
}
message EncryptedMessage {
// Integer representing encrypted message
int32 message = 1;
string src = 2;
string dst = 3;
}
// Return this acknowledging the receipt of a message
message MsgAck {
int32 status = 1;
string src = 2;
string dst = 3;
}
// Empty Message Type
message NullMsg {
int32 status = 1;
}
version: '3.7'
services:
server:
build: .
environment:
- TZ=America/Chicago
- DEBIAN_FRONTEND=noninteractive
hostname: server
container_name: server
networks:
- default
client1:
build: .
environment:
- TZ=America/Chicago
- DEBIAN_FRONTEND=noninteractive
hostname: client1
container_name: client1
networks:
- default
client2:
build: .
environment:
- TZ=America/Chicago
- DEBIAN_FRONTEND=noninteractive
hostname: client2
container_name: client2
networks:
- default
networks:
default:
driver: bridge
import logging
logging.basicConfig(format='%(asctime)s %(levelname)s:%(name)s %(message)s', level=logging.DEBUG)`
Back to CS5113