From 6cf8242807faf25dcc40ed541edcb72ca95acfa8 Mon Sep 17 00:00:00 2001 From: tuvu Date: Tue, 11 Feb 2025 16:14:18 +0100 Subject: [PATCH] ok --- README.md | 14 +++++++++ images/p1_ex1_tftp.pcapng | Bin 0 -> 2440 bytes src/main/java/pr/tp2/udp/tftp/TftpDecode.java | 27 ++++++++++++++---- 3 files changed, 35 insertions(+), 6 deletions(-) create mode 100755 images/p1_ex1_tftp.pcapng diff --git a/README.md b/README.md index 254e425..3fe04a6 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,21 @@ ## Partie 1 : protocole TFTP ### 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 3 : Acquitter diff --git a/images/p1_ex1_tftp.pcapng b/images/p1_ex1_tftp.pcapng new file mode 100755 index 0000000000000000000000000000000000000000..482722db1c74ff08811d934366fb32736c344517 GIT binary patch literal 2440 zcmeHJU1%It6h1RMyV<1K$UM6zodT0=@((;pD2oy^Scj=M9n z%*>`W5wuWWN}w@`6%`*^ut+IYp%2nhoCOiI7h%_oj(PLZFO7~P!ePXdHs9gJ&6^%%b;HJB2GOutZ24b{?Q z01jS;9aX&|OBFtGNV8PCC|RW>k26#Kd}62O@KcR`MUqQWK~;FkZj1`)RC=viUm*Ua51)*G z0r{_-{Pwlx{4Xf>y!KU4Dk=&@c1*?*C7MKU1x3? z&x(!!Mdzt{F9l8DLuM*Cwo{&X-4O#JL9=F3n{z#XzJuxD=h_`8V05Q9k5{kiQJ zfa_wHpwqwqX))a*O;;^7uejZAx)B7=K~LOvBunsygoeY;s!~}fn@88!LPfG1K@>L+MyL_DMIAx6Ri&Wfy!X6$UBJ2v?gFlhj^`QR zVx@n^ag7Ms{aYctaV-K%39^QL>-4+}w93PLFe^&l(<;A)01zIQQR`^1OC z;lFBYS8)wGj-zr^LsYxFNJccOrAw!N8{34K+;3D%%=%kDP%WLgxmrsz=b6yGv6aL1 zTH-K8lV=5M_o=L<&U!7KLmgshPDnO&IJSNE4nRv3 zUl}K$_fOJi2%YpJ9TiVA(s6odc`S#R+;6C(%M4tf2gov?=N{Yvp-`!xqW;&onZ~3o zX?%oaLL-g4qDv=+u}|)|`n{f>eJP9g?3ZtQ8b9WH?*rtA$d4DB^UpEFf8pyV<3El3 z>pFkE)tvwI3h{sT{eSq`X7BAVict21_(h1ob@8K58R&))vx;9vmd)dJJf$i4i8A>X huQWbtScn3}c3e66amee(a2|*KH6B+O`+lPw_W?_r2NwVU literal 0 HcmV?d00001 diff --git a/src/main/java/pr/tp2/udp/tftp/TftpDecode.java b/src/main/java/pr/tp2/udp/tftp/TftpDecode.java index 95ac82b..122efbd 100644 --- a/src/main/java/pr/tp2/udp/tftp/TftpDecode.java +++ b/src/main/java/pr/tp2/udp/tftp/TftpDecode.java @@ -1,23 +1,38 @@ package pr.tp2.udp.tftp; +import java.io.IOException; import java.net.DatagramPacket; - +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.ServerSocket; 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 + DatagramSocket dSocket = new DatagramSocket(portTFTP); // Boucle - + while (true) { + byte[] buffer = new byte[512]; // Reception du packet - DatagramPacket p = null; + DatagramPacket reception =new DatagramPacket(buffer, buffer.length); + dSocket.receive(reception); // Affichage du packet - + System.out.println(new String(buffer)); + // Attention à ne pas afficher plus d'informations que nécessaire. // Décodage du packet - decodeRequest(p); + decodeRequest(reception); + } + } catch (IOException e) { + e.printStackTrace(); + } } public static void affiche(byte[] bytes) {