Final Exam - Practical Part

Distributed Systems and Network Programming - Spring 2023

Task 1 - UDP Socket Programming [8.5 Points]

Write a UDP server and a client using Python socket module to implement a minimalistic DNS service

Client (client.py)

Server (server.py)

Example Run

$ python3 server.py
Server: listening on 0.0.0.0:50000
Client: {'type': 'A', 'key': 'example.com'}
Server: Record found. Sending answer.
Client: {'type': 'PTR', 'key': '1.2.3.4'}
Server: Record found. Sending answer.
Client: {'type': 'CNAME', 'key': 'moodle.com'}
Server: Record not found. Sending error.
^CServer: Shutting down...
$ python3 client.py
Client: Sending query for example.com
Server: {'type': 'A', 'key': 'example.com', 'value': '1.2.3.4'}
Client: Sending query for 1.2.3.4
Server: {'type': 'PTR', 'key': '1.2.3.4', 'value': 'example.com'}
Client: Sending query for moodle.com
Server: {'type': 'CNAME', 'key': 'moodle.com', 'value': 'NXDOMAIN'}

Task 2 - Remote Procedure Call [8.5 Points]

Write a server and a client to implement a simple remote calculator

Server (server.py)

Client (client.py)

Schema file (calculator.proto)

Example Run

$ python3 server.py
gRPC server is listening on 0.0.0.0:50000
Add(10,2)
Subtract(10,2)
Multiply(10,2)
Divide(10,2)
Divide(10,0)
^CShutting down...
$ python3 client.py
Add(10,2) = 12.0
Subtract(10,2) = 8.0
Multiply(10,2) = 20.0
Divide(10,2) = 5.0
Divide(10,0) = nan