aide tracker
This commit is contained in:
parent
1355ef14b1
commit
3edb0bf9e5
@ -6,6 +6,12 @@ Lien vers le [document original](https://stri-online.net/FTLV/mod/resource/view.
|
|||||||
**But** : le but de ce projet est de créer une application répartie en Java de téléchargement de fichier en mode P2P (peer to peer ou poste à poste).
|
**But** : le but de ce projet est de créer une application répartie en Java de téléchargement de fichier en mode P2P (peer to peer ou poste à poste).
|
||||||
Les étapes suivantes sont conseillées.
|
Les étapes suivantes sont conseillées.
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
tracker : java -ea tracker.Tracker, to specify port (default localhost:6969, range 6000 -> 6999): java -ea trackerP2P.trackerP2P -- <PORT>
|
||||||
|
serveur : java -ea serveurP2P.ServeurP2P, to specify port and tracker (default for server localhost:7070 tracker localhost:6969, range 7000 -> 7999): java -ea serveurP2P.ServeurP2P -- <serveurPORT> <trackerHOSTNAME> <trackerPORT>
|
||||||
|
client/serveur : java -ea clientP2P.ClientP2P -- <serverPORT> <trackerHOSTNAME> <trackerPORT>
|
||||||
|
|
||||||
## Étape 1 : Téléchargement à la FTP
|
## Étape 1 : Téléchargement à la FTP
|
||||||
|
|
||||||
La première étape doit permettre de télécharger un fichier en intégralité d'une machine vers une autre machine de façon similaire aux applications suivant le protocole FTP.
|
La première étape doit permettre de télécharger un fichier en intégralité d'une machine vers une autre machine de façon similaire aux applications suivant le protocole FTP.
|
||||||
@ -47,4 +53,4 @@ Options :
|
|||||||
- Permettre la recherche de fichiers à partir de leur nom ou de toute autre caractéristique. À l'issu de la recherche on devra pouvoir connaître un ensemble d'application possédant le fichier et commencer le téléchargement.
|
- Permettre la recherche de fichiers à partir de leur nom ou de toute autre caractéristique. À l'issu de la recherche on devra pouvoir connaître un ensemble d'application possédant le fichier et commencer le téléchargement.
|
||||||
- Gérer le protocole d'une application de téléchargement P2P existante (bittorrent, emule ou autre).
|
- Gérer le protocole d'une application de téléchargement P2P existante (bittorrent, emule ou autre).
|
||||||
|
|
||||||
Note : toute fonctionnalité supplémentaire ne sera prise en compte dans la notation que si toutes les étapes ont été correctement traitées.
|
Note : toute fonctionnalité supplémentaire ne sera prise en compte dans la notation que si toutes les étapes ont été correctement traitées.
|
||||||
|
@ -73,7 +73,7 @@ public class ClientP2P {
|
|||||||
*/
|
*/
|
||||||
public static void main(String [] args) {
|
public static void main(String [] args) {
|
||||||
if (args[1].equals("help") || args[1].equals("-h") || args[1].equals("h")){
|
if (args[1].equals("help") || args[1].equals("-h") || args[1].equals("h")){
|
||||||
System.out.println("usage : java -ea clientP2P.ClientP2P -- <PORT> ");
|
System.out.println("usage : java -ea clientP2P.ClientP2P -- <serverPORT> <trackerHOSTNAME> <trackerPORT>");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ClientP2P c;
|
ClientP2P c;
|
||||||
|
27
src/tools/TestPort.java
Normal file
27
src/tools/TestPort.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package tools;
|
||||||
|
|
||||||
|
/** Test ports.
|
||||||
|
* @author Louis Royer
|
||||||
|
* @author Flavien Haas
|
||||||
|
* @author JS Auge
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class TestPort {
|
||||||
|
|
||||||
|
public boolean testPortServer(int port) {
|
||||||
|
if((port > 7000) && (port < 7999)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean testPortTracker(int port) {
|
||||||
|
if((port > 6000) && (port < 6999)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,9 +1,12 @@
|
|||||||
package tracker;
|
package tracker;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
import tracker.TrackerManagementTCP;
|
import tracker.TrackerManagementTCP;
|
||||||
import tracker.TrackerManagementUDP;
|
import tracker.TrackerManagementUDP;
|
||||||
import tools.Directories;
|
import tools.Directories;
|
||||||
import tools.Logger;
|
import tools.Logger;
|
||||||
import java.util.Scanner;
|
import tools.LogLevel;
|
||||||
|
import tools.TestPort;
|
||||||
|
|
||||||
/** Tracker implementation
|
/** Tracker implementation
|
||||||
* First argument of main method is port listened by the tracker, and is mandatory.
|
* First argument of main method is port listened by the tracker, and is mandatory.
|
||||||
@ -16,6 +19,7 @@ public class Tracker {
|
|||||||
private int port;
|
private int port;
|
||||||
private Directories directories;
|
private Directories directories;
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
|
private static final int defaultPort = 6969;
|
||||||
|
|
||||||
/** Constructor with portStr containing a port number.
|
/** Constructor with portStr containing a port number.
|
||||||
* @param portStr String containing port number of listening.
|
* @param portStr String containing port number of listening.
|
||||||
@ -36,15 +40,31 @@ public class Tracker {
|
|||||||
* @param args parameters
|
* @param args parameters
|
||||||
*/
|
*/
|
||||||
public static void main(String [] args) {
|
public static void main(String [] args) {
|
||||||
Tracker t = new Tracker(args[1]);
|
if (args[1].equals("help") || args[1].equals("-h") || args[1].equals("h")){
|
||||||
TrackerManagementUDP tmudp = new TrackerManagementUDP(t.port, t.logger);
|
System.out.println("usage : java -ea trackerP2P.trackerP2P, to specify port (default 6969, range 6000 -> 6999): java -ea trackerP2P.trackerP2P -- <PORT>");
|
||||||
TrackerManagementTCP tmtcp = new TrackerManagementTCP(t.port, t.logger);
|
}
|
||||||
Thread tudp = new Thread(tmudp);
|
else{
|
||||||
tudp.setName("Tracker UDP P2P-JAVA-PROJECT");
|
Tracker t;
|
||||||
tudp.start();
|
TestPort testPortTracker = new TestPort();
|
||||||
Thread ttcp = new Thread(tmtcp);
|
if(testPortTracker.testPortTracker(Integer.parseInt(args[1]))){
|
||||||
ttcp.setName("Tracker TCP P2P-JAVA-PROJECT");
|
t = new Tracker(args[1]);
|
||||||
ttcp.start();
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("Wrong port (6000 -> 6999), using default port 6969");
|
||||||
|
t = new Tracker(String.valueOf(defaultPort));
|
||||||
|
//t.logger.writeUDP("Wrong port (6000 -> 6999), using default port 6969", LogLevel.Warning);
|
||||||
|
//t.logger.writeTCP("Wrong port (6000 -> 6999), using default port 6969", LogLevel.Warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
TrackerManagementUDP tmudp = new TrackerManagementUDP(t.port, t.logger);
|
||||||
|
TrackerManagementTCP tmtcp = new TrackerManagementTCP(t.port, t.logger);
|
||||||
|
Thread tudp = new Thread(tmudp);
|
||||||
|
tudp.setName("Tracker UDP P2P-JAVA-PROJECT");
|
||||||
|
tudp.start();
|
||||||
|
Thread ttcp = new Thread(tmtcp);
|
||||||
|
ttcp.setName("Tracker TCP P2P-JAVA-PROJECT");
|
||||||
|
ttcp.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,32 +1,32 @@
|
|||||||
package tracker;
|
package tracker;
|
||||||
import tools.Logger;
|
|
||||||
import tools.LogLevel;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.net.InetAddress;
|
||||||
import protocolP2P.ProtocolP2PPacketTCP;
|
import protocolP2P.ProtocolP2PPacketTCP;
|
||||||
import protocolP2P.ProtocolP2PPacket;
|
import protocolP2P.ProtocolP2PPacket;
|
||||||
import protocolP2P.RequestResponseCode;
|
import protocolP2P.RequestResponseCode;
|
||||||
import protocolP2P.Payload;
|
import protocolP2P.Payload;
|
||||||
import protocolP2P.Register;
|
import protocolP2P.Register;
|
||||||
import protocolP2P.Unregister;
|
import protocolP2P.Unregister;
|
||||||
import tools.HostItem;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.io.IOException;
|
|
||||||
import exception.LocalException;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import protocolP2P.DiscoverRequest;
|
import protocolP2P.DiscoverRequest;
|
||||||
import protocolP2P.DiscoverResponse;
|
import protocolP2P.DiscoverResponse;
|
||||||
import protocolP2P.FileList;
|
import protocolP2P.FileList;
|
||||||
import localException.InternalError;
|
import exception.LocalException;
|
||||||
import remoteException.EmptyDirectory;
|
import remoteException.EmptyDirectory;
|
||||||
import java.net.UnknownHostException;
|
import localException.InternalError;
|
||||||
import java.net.InetAddress;
|
|
||||||
import localException.SocketClosed;
|
import localException.SocketClosed;
|
||||||
import tracker.TrackerManagement;
|
import tracker.TrackerManagement;
|
||||||
|
import tools.HostItem;
|
||||||
|
import tools.Logger;
|
||||||
|
import tools.LogLevel;
|
||||||
|
|
||||||
/** Tracker management implementation with tcp
|
/** Tracker management implementation with tcp
|
||||||
* @author Louis Royer
|
* @author Louis Royer
|
||||||
@ -114,6 +114,7 @@ public class TrackerManagementTCP extends TrackerManagement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Implementation of writeLog
|
/** Implementation of writeLog
|
||||||
* @param text Text to log
|
* @param text Text to log
|
||||||
* @param logLevel level of logging
|
* @param logLevel level of logging
|
||||||
@ -144,7 +145,7 @@ public class TrackerManagementTCP extends TrackerManagement {
|
|||||||
protected Object getHostItemSocket(HostItem hostItem) {
|
protected Object getHostItemSocket(HostItem hostItem) {
|
||||||
return (Object)hostItem.getTCPSocket();
|
return (Object)hostItem.getTCPSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Close HostItem socket
|
/** Close HostItem socket
|
||||||
* @param hostItem HostItem
|
* @param hostItem HostItem
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user