Commit e016d712a7ca6293425c8de9d7b0156033eaae67

Authored by adumas
1 parent 57f0923c

bla

src/main/java/net/floodlightcontroller/pelstats/PELStats.java
... ... @@ -221,7 +221,7 @@ public class PELStats implements IFloodlightModule, IOFMessageListener, RestAPIP
221 221 if (cacEnabledMap.get(sw)==null){
222 222 cacEnabledMap.put(sw,false);
223 223 }
224   - if (((StatisticVoIP_CAC)srb.getStatistic()).getStats()[1]>100 ){//nbCalls>100
  224 + if (((StatisticVoIP_CAC)srb.getStatistic()).getStats()[2]<3.8 ){//average iMOS < 3.8
225 225 if (cacEnabledMap.get(sw)==false){
226 226 int nb= 2*16777216+7*65536+1*4096+1;
227 227 PelVendorHeader message= new PelVendorHeader(nb);
... ... @@ -257,6 +257,16 @@ public class PELStats implements IFloodlightModule, IOFMessageListener, RestAPIP
257 257  
258 258  
259 259 }
  260 + /*if (srb.getStatistic().getType()==8){
  261 + ArrayList<double[]> cacStats;
  262 + if(cacStatsMap.get(sw)!=null){
  263 + cacStats =new ArrayList<double[]>(cacStatsMap.get(sw));
  264 + }
  265 + cacStats.add(stats);
  266 + //System.out.println("@PELStats \tputting switch");
  267 + cacStatsMap.put(sw,cacStats);
  268 + }*/
  269 +
260 270  
261 271 if(enabledStatistics.containsKey(sw)){
262 272 //System.out.println("@PELStats contains key sw");
... ...
src/main/java/net/floodlightcontroller/pelstats/rest/RESTExportStats.java
... ... @@ -92,7 +92,7 @@ public class RESTExportStats extends ServerResource{
92 92 PrintWriter out=null;
93 93 try{
94 94 if(type==5){
95   - out = new PrintWriter("VoIPstatsExport.txt");
  95 + out = new PrintWriter("VoIPStatsExport.txt");
96 96  
97 97 //Retrieving all stats
98 98 ConcurrentHashMap<Double, List<double[]>> callsStatsMap = new ConcurrentHashMap<Double, List<double[]>>();
... ... @@ -143,11 +143,11 @@ public class RESTExportStats extends ServerResource{
143 143 System.out.println("-> stats export successful");
144 144 }
145 145 else if(type==7){
146   - out = new PrintWriter("CACstatsExport.txt");
  146 + out = new PrintWriter("CACStatsExport.txt");
147 147 if (idVoip==0){//export stats for all switches
148 148 for (Map.Entry<IOFSwitch, List<double[]>> entry : PELStats.cacStatsMap.entrySet()){
149 149 out.println("Switch:\t"+entry.getKey());
150   - out.println("Number of calls\tAverage iMOS");
  150 + out.println("Date\tNumber of calls\tAverage iMOS\tBandwidth");
151 151 for (double[] list:PELStats.cacStatsMap.get(entry.getKey())){
152 152 if(list[1]!=0)out.println(list[0]+"\t"+list[1]+"\t"+list[2]+"\t"+list[3]);
153 153 }
... ... @@ -156,13 +156,26 @@ public class RESTExportStats extends ServerResource{
156 156 }
157 157 else if (idVoip==1){//export stats for this switch only
158 158 for (double[] list:PELStats.cacStatsMap.get(mySwitch)){
  159 + out.println("Switch:\t"+mySwitch);
  160 + out.println("Date\tNumber of calls\tAverage iMOS\tBandwidth");
159 161 if(list[1]!=0)out.println(list[0]+"\t"+list[1]+"\t"+list[2]+"\t"+list[3]);
160 162 }
161   - }
162   -
163   -
164   -
  163 + }
165 164  
  165 + System.out.println("-> stats export successful");
  166 + }
  167 + else if (type==8){
  168 + out = new PrintWriter("BandwidthStatsExport.txt");
  169 + if (idVoip==0){//export stats for all switches
  170 + for (Map.Entry<IOFSwitch, List<double[]>> entry : PELStats.cacStatsMap.entrySet()){
  171 + out.println("Switch:\t"+entry.getKey());
  172 + out.println("Number of calls\tBandwidth\tVoIP Bandwidth");
  173 + for (double[] list:PELStats.cacStatsMap.get(entry.getKey())){
  174 + if(list[1]!=0)out.println(list[0]+"\t"+list[3]+"\t"+list[4]);
  175 + }
  176 + out.println("\n");
  177 + }
  178 + }
166 179  
167 180 System.out.println("-> stats export successful");
168 181 }
... ...
src/main/java/org/openflow/protocol/Pel/statistics/StatisticVoIP_CAC.java
... ... @@ -31,7 +31,7 @@ public class StatisticVoIP_CAC extends Statistic{
31 31 date=new Date();
32 32  
33 33 //TODO Change the condition
34   - if (nbCalls>100 ){
  34 + if (averageMos<3.8 ){
35 35 cacStatus="Too much calls";
36 36 }
37 37 else
... ... @@ -42,7 +42,7 @@ public class StatisticVoIP_CAC extends Statistic{
42 42  
43 43 }
44 44 public double[] getStats(){
45   - double stats[]=new double[4];
  45 + double stats[]=new double[5];//the 5th value is the voipBandwidth, added in the PELStats class when a Queue packet is detected
46 46 stats[1]=nbCalls;
47 47 stats[2]=averageMos;
48 48 stats[0]=date.getTime();
... ...
src/main/java/org/openflow/protocol/Pel/statistics/StatisticVoIP_Queue.java
... ... @@ -44,6 +44,17 @@ public class StatisticVoIP_Queue extends Statistic{
44 44 }
45 45  
46 46 }
  47 + public double getVoipBandwidth(){
  48 + double bw = 0;
  49 +
  50 + for (int i=0;i<nbQueues;i++){
  51 + if (protocol[i]==1){
  52 + bw+=bandwidth[i];
  53 + }
  54 + }
  55 +
  56 + return bw;
  57 + }
47 58  
48 59 private int getIntBytes(ByteBuffer b, int nbBytes){
49 60 byte[] bytes=new byte[4];
... ...