
es.tid.pce.client.multiLayer.AutomaticExponentialTesterMLNetworkTask 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.pce.client.multiLayer;
import java.io.BufferedWriter;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Timer;
import java.util.TimerTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cern.jet.random.Exponential;
import es.tid.emulator.node.transport.EmulatedPCCPCEPSession;
import es.tid.pce.client.ClientRequestManager;
import es.tid.pce.client.emulator.AutomaticTesterStatistics;
import es.tid.pce.pcep.PCEPProtocolViolationException;
import es.tid.pce.pcep.constructs.Path;
import es.tid.pce.pcep.messages.PCEPRequest;
import es.tid.pce.pcep.messages.PCEPResponse;
import es.tid.pce.pcep.messages.PCEPTELinkSuggestion;
import es.tid.pce.pcep.objects.ExplicitRouteObject;
import es.tid.rsvp.objects.subobjects.EROSubobject;
import es.tid.rsvp.objects.subobjects.IPv4prefixEROSubobject;
import es.tid.rsvp.objects.subobjects.SubObjectValues;
public class AutomaticExponentialTesterMLNetworkTask extends TimerTask {
private static int counter=0;
private ClientRequestManager crm;
private Logger log;
static long requestID=123;
private EmulatedPCCPCEPSession psVNTM;
/*Variable used for counter how many requests there are*/
private Timer timer;
PCEPRequest request;
Exponential expSendRequest;
Exponential connectionTime;
private AutomaticTesterStatistics stats;
private Timer planificationTimer;
PrintWriter pw;
PrintWriter apw;
public AutomaticExponentialTesterMLNetworkTask(Exponential expSendRequest,Exponential connectionTime, Timer timer,Timer planificationTimer,PCEPRequest request,ClientRequestManager crm,EmulatedPCCPCEPSession psVNTM,AutomaticTesterStatistics stats,PrintWriter pw, PrintWriter apw ){
this.request = request;
log=LoggerFactory.getLogger("PCCClient");
this.crm=crm;
this.psVNTM=psVNTM;
this.expSendRequest=expSendRequest;
this.connectionTime = connectionTime;
this.timer=timer;
this.stats=stats;
this.planificationTimer=planificationTimer;
this.pw=pw;
this.apw=apw;
}
@Override
public void run() {
//First, we schedule the next request
double timeNextReqD=expSendRequest.nextDouble();
long timeNextReq =(long)timeNextReqD;
AutomaticExponentialTesterMLNetworkTask exponentialTester = new AutomaticExponentialTesterMLNetworkTask(expSendRequest,connectionTime,timer,planificationTimer,request, crm, psVNTM,stats,pw,apw);
log.info("Scheduling next request in "+timeNextReq+" MS ("+timeNextReqD+" )");
timer.schedule(exponentialTester,timeNextReq);
//Measure initial time
long timeIni=System.nanoTime();
PCEPResponse pr;
request.getRequestList().getFirst().getRequestParameters().setRequestID(requestID);
requestID=requestID+1;
//Count one request
stats.addRequest();
//FIXME: COGER POSIBLES FALLOS EN EL REQUEST
pr=crm.newRequest(this.request);
long timeIni2=System.nanoTime();
log.info("Response "+pr.toString());
double reqTime_ms=(timeIni2-timeIni)/1000000;
double reqTime_us=(timeIni2-timeIni)/1000;
stats.analyzeReqTime(reqTime_us);
log.info("Request Time "+reqTime_us+" us");
String strPrev=null;
if (pr.getResponseList().isEmpty()){
log.error("ERROR in response");
//FIXME: QUE HACEMOS? CANCELAMOS SIMULACION?
//stats.addNoPathResponse();
System.exit(1);
return;
}else {
if (pr.getResponseList().get(0).getNoPath()!=null){
log.info("NO PATH");
stats.addNoPathResponse();
stats.analyzeBlockingProbability(1);
return;
}else {
Path path=pr.getResponseList().get(0).getPath(0);
ExplicitRouteObject ero=path.geteRO();
LinkedList eroSubObjList=ero.getEROSubobjectList();
boolean layerInfoFound=false;
int numNewLinks=0;
ArrayList sourceList = new ArrayList();
ArrayList destinationList = new ArrayList();
//cREAR LISTA DE EROS
LinkedList eroList=new LinkedList();
LinkedList eroSubObjList2=null;
int counterArray=0;
for (int i=0;i0){
stats.addMLResponse();
}else {
stats.addSLResponse();
}
stats.analyzeBlockingProbability(0);
for (int i=0;i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy