Update S11: Practice 3 authored by Rodrigo's avatar Rodrigo
......@@ -3,6 +3,7 @@
# Session 11: Practice 3
* **Time**: 2h
* **Date**: XXXX, XX-XX-2023
* **Goals**:
* Practicing on the programming of servers
* Develop our own server for working with DNA sequences
......@@ -25,9 +26,9 @@
## Introduction
The goal of this new assignment is to develop our own **Seq** server to work with **DNA sequences**. We have been working with DNA sequences for many sessions, but always in our local computer. Now we will make these calculations available to other applications on Internet
The goal of this new assignment is to develop our own **Seq** server to work with **DNA sequences**. We have been working with DNA sequences for several sessions now, but always in our local computer. Now we will make these calculations available to other applications on the Internet
The first step is to **define** the set of **rules** and **commands** that the **clients** need to follow in order to access the **services** given by our **server**: we should define the **protocol**
The first step is to **define** the set of **rules** and **commands** that the **clients** need to use in order to access the **services** provided by our **server**. We should define the communications **protocol**
| Service name | Request message | Argument | Response message | Description |
|--------------|-----------------|----------|------------------|-------------|
| **PING** | "PING" | none | "OK" | Ping service for testing whether the server is alive of not |
......@@ -50,19 +51,19 @@ T: 3 (14.3%)
The names of the **valid** genes to call the **GENE service** are: **U5**, **ADA**, **FRAT1**, **FXN**, and **RNU6_269P**
The server will be programmed **step by step**, following the guidelines given in the **exercises**.
The server will be programmed **step by step**, following the guidelines given in the **exercises** below.
## Localhost IP address
There is a special **IP** address: **127.0.0.1**, which is used to identify **your local machines**. When programming a server, instead of having to used the real IP, it is much easier to use this IP. By doing so, you do not have to change the code when running the server in a different computer.
There is a special **IP** address: **127.0.0.1**, which is used to identify **your local machines**. When programming a server, instead of using the real IP, it is much easier to use this IP. By doing so, you do not have to change the code when running the server in a different computer.
**We will always use the 127.0.0.1 address** in our local servers.
## Exercises
We will implement the **Seq Server**, and develop some clients to test it. While developing the server, we will use the **echo** and **nc** linux commands for **sending messages** to the **server**. But you can also do it from your own client if you like.
We will implement the so called **Seq Server**, and develop some clients to test it. While developing the server, we will use the **echo** and **nc** linux commands for **sending messages** to the **server**. But you can also do it from your own client if you like.
The server will be stored in a file called **Seq-Server.py** within a folder with name **P03**. You will need to use the **Seq1 module** developed in **P01**, and extend it.
The server will be stored in a file called **Seq-Server.py** within a folder with name **P03**. You will need to use the **Seq1 module** developed in **P01**, and extend it. As you can see, we are building on previous work.
### Exercise 1: PING
......@@ -78,11 +79,11 @@ echo "PING" | nc 127.0.0.1 8080
This is what we will see on the **linux console**:
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s10-client-server-3/1-client-server-4/exercises-01.png)
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s11-client-server-4/exercises-01.png)
And this is what we should get in the **Server's console**:
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s10-client-server-3/1-client-server-4/exercises-02.png)
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s11-client-server-4/exercises-02.png)
### Exercise 2: GET
......@@ -100,11 +101,11 @@ In this example the client is asking for the sequence number 2.
This is what is shown in the **Linux's console**:
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s10-client-server-3/1-client-server-4/exercises-03.png)
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s11-client-server-4/exercises-03.png)
And this is what we should get in the **Server's console**:
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s10-client-server-3/1-client-server-4/exercises-04.png)
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s11-client-server-4/exercises-04.png)
### Exercise 3: INFO
......@@ -120,17 +121,17 @@ echo "INFO AACCGTA" | nc 127.0.0.1 8080
This is what is shown in the **Linux's console**:
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s10-client-server-3/1-client-server-4/exercises-05.png)
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s11-client-server-4/exercises-05.png)
And this is what we should get in the **Server's console**:
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s10-client-server-3/1-client-server-4/exercises-06.png)
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s11-client-server-4/exercises-06.png)
### Exercise 4: COMP
* **Filename:** P03/Seq-server.py
Upgrade the Seq server to respond to the **COMP command**. The client sends a message with the word **COMP** followed by a sequence. The server will return a **response message** with the complement of that sequence. It must be obtained using the **Seq Class**.
Upgrade the server to respond to the **COMP command**. The client sends a message with the word **COMP** followed by a sequence (the argument of the command). The server will return a **response message** with the complement of that sequence. As always, it must be obtained using the **Seq Class**.
Use the following command to test the server:
......@@ -140,17 +141,17 @@ echo "COMP AACCGTA" | nc 127.0.0.1 8080
This is what is shown in the **Linux's console**:
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s10-client-server-3/1-client-server-4/exercises-07.png)
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s11-client-server-4/exercises-07.png)
And this is what we should get in the **Server's console**:
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s10-client-server-3/1-client-server-4/exercises-08.png)
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s11-client-server-4/exercises-08.png)
### Exercise 5: REV
* **Filename:** P03/Seq-server.py
Modify the Seq server and implement the **REV command**. The client sends a message with the word **REV** followed by a sequence. The server will return a **response message** with the reverse of the sequence. It must be obtained using the **Seq Class**.
Modify the server to implement the **REV command**. The client sends a message with the word **REV** followed by a sequence. The server will return a **response message** with the reverse of the sequence. It must be obtained using the **Seq Class**.
Use the following command to test the server:
......@@ -160,17 +161,17 @@ echo "REV AACCGTA" | nc 127.0.0.1 8080
This is what is shown in the **Linux's console**:
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s10-client-server-3/1-client-server-4/exercises-09.png)
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s11-client-server-4/exercises-09.png)
And this is what we should get in the **Server's console**:
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s10-client-server-3/1-client-server-4/exercises-10.png)
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s11-client-server-4/exercises-10.png)
### Exercise 6: GENE
* **Filename:** P3/Seq-Server.py
Work on the Seq server and implementing the **GENE command**. The client sends a message with the word **GENE** followed by a **gene name**: U5, ADA, FRAT1, FXN, or RNU6_269P. The server will return a **response message** with the whole sequence corresponding to that gene. It must be obtained using the **Seq Class** (and reading the gene from the corresponding file).
Work on the Seq server so it responds to the **GENE command**. The client sends a message with the word **GENE** followed by a specific (and valid) **gene name**: U5, ADA, FRAT1, FXN, or RNU6_269P. The server will return a **response message** with the whole sequence corresponding to that gene. It must be obtained using the **Seq Class** (and reading the gene from the corresponding file).
Use the following command to test the server:
......@@ -180,11 +181,11 @@ echo "GENE U5" | nc 127.0.0.1 8080
This is what is shown in the **Linux's console**:
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s10-client-server-3/1-client-server-4/exercises-11.png)
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s11-client-server-4/exercises-11.png)
And this is what we should get in the **Server's console**:
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s10-client-server-3/1-client-server-4/exercises-12.png)
![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s11-client-server-4/exercises-12.png)
### Exercise 7: Test client
......
......