This commit is contained in:
tuvu
2025-02-11 16:14:18 +01:00
parent f00da403b2
commit 6cf8242807
3 changed files with 35 additions and 6 deletions

View File

@@ -3,7 +3,21 @@
## Partie 1 : protocole TFTP ## Partie 1 : protocole TFTP
### Exercice 1 : Observation ### Exercice 1 : Observation
Côté client
```
tftp localhost 6969
tftp> get test.html
put test.html
quit
Transfer timed out.
```
Côté serveur
```
nc -u -l -p 6969
test.htmlnetasciitest.htmlnetasciitest.htmlnetasciitest.htmlnetasciitest.htmlnetasciitest.htmlnetasciitest.htmlnetasciitest.htmlnetasciitest.htmlnetasciitest.htmlnetascii
```
### Exercice 2 : Décodage des requêtes. ### Exercice 2 : Décodage des requêtes.
### Exercice 3 : Acquitter ### Exercice 3 : Acquitter

BIN
images/p1_ex1_tftp.pcapng Executable file

Binary file not shown.

View File

@@ -1,23 +1,38 @@
package pr.tp2.udp.tftp; package pr.tp2.udp.tftp;
import java.io.IOException;
import java.net.DatagramPacket; import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.ServerSocket;
public class TftpDecode { public class TftpDecode {
public static void main(String[] args) { public static void main(String[] args) throws IOException {
int portTFTP = 7777;
int portServeur= 6969;
InetAddress ipServeur = InetAddress.getByName("localhost");
try{
// Attends sur le port 6969 // Attends sur le port 6969
DatagramSocket dSocket = new DatagramSocket(portTFTP);
// Boucle // Boucle
while (true) {
byte[] buffer = new byte[512];
// Reception du packet // Reception du packet
DatagramPacket p = null; DatagramPacket reception =new DatagramPacket(buffer, buffer.length);
dSocket.receive(reception);
// Affichage du packet // Affichage du packet
System.out.println(new String(buffer));
// Attention à ne pas afficher plus d'informations que nécessaire. // Attention à ne pas afficher plus d'informations que nécessaire.
// Décodage du packet // Décodage du packet
decodeRequest(p); decodeRequest(reception);
}
} catch (IOException e) {
e.printStackTrace();
}
} }
public static void affiche(byte[] bytes) { public static void affiche(byte[] bytes) {