
es.tid.vntm.management.VNTMManagementSession Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of network-emulator Show documentation
Show all versions of network-emulator Show documentation
Emulator of GMPLS-controlled transport Network
The newest version!
package es.tid.vntm.management;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;
import java.util.concurrent.LinkedBlockingQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import es.tid.netManager.emulated.SimpleEmulatedNetworkLSPManager;
import es.tid.ospf.ospfv2.OSPFv2LinkStateUpdatePacket;
import es.tid.vntm.LSPManager;
public class VNTMManagementSession extends Thread {
private Socket socket;
private PrintStream out;
private Logger log;
private LSPManager lspmanager;
public VNTMManagementSession(Socket s, LSPManager lspmanager){
this.socket=s;
this.lspmanager=lspmanager;
log=LoggerFactory.getLogger("PCEServer");
}
public void run(){
log.info("Starting VNTM Management session");
boolean running=true;
try {
out=new PrintStream(socket.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
return;
}
try {
//out.print("-------------\n");
BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
while (running) {
out.print("VNTM:>");
String command = null;
try {
command = br.readLine();
} catch (IOException ioe) {
log.warn("IO error trying to read your command");
return;
}
if (command.equals("quit")) {
log.info("Ending VNTM Management Session");
try {
out.close();
} catch (Exception e){
e.printStackTrace();
}
try {
br.close();
} catch (Exception e){
e.printStackTrace();
}
return;
}
if (command.equals("show TE Links")) {
out.println("TE Links:");
out.println(lspmanager.printLSPs());
out.println("Number of TE Links : "+ lspmanager.countTELinks());
out.println("Number of Reserve Transport Links: "+lspmanager.countCapacity() );
}
else if (command.equals("help")){
out.print("Available commands:\r\n");
out.print("show TE Links\r\n");
out.print("quit\r\n");
}
else if (command.equals("reset")){
//Recorrer y Borrar todas las lsps que haya
lspmanager.removeAllLSPs();
//Llamar al network emulator thread: recargar la topologia
LinkedBlockingQueue sendingQueue = new LinkedBlockingQueue();
SimpleEmulatedNetworkLSPManager net = new SimpleEmulatedNetworkLSPManager(sendingQueue,"hola");
//net.reset();
//rester ok
}
else if (command.equals("hard reset")){
}
else if (command.equals("set traces on")) {
// log.setLevel(Level.ALL);
// Logger log2=LoggerFactory.getLogger("VNTMServer");
// log2.setLevel(Level.ALL);
// Logger log3= LoggerFactory.getLogger("PCEPParser");
// log3.setLevel(Level.ALL);
out.print("traces on!\r\n");
}
else if (command.equals("set traces off")) {
// log.setLevel(Level.error);
// Logger log2=LoggerFactory.getLogger("VNTMServer");
// log2.setLevel(Level.error);
// Logger log3= LoggerFactory.getLogger("PCEPParser");
// log3.setLevel(Level.error);
out.print("traces off!\r\n");
}
else{
//out.print("invalid command\n");
out.print("\n");
}
}
} catch (Exception e) {
e.printStackTrace();
return;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy