⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 statistics.java

📁 The WLAN Traffic Visualizer is a platform independent Java program providing accurate measurement of
💻 JAVA
字号:
package model;

//Copyright (C) 2008 Harald Unander, Wang Wenjuan
//
//    This file is part of WlanTV.
//
//    WlanTV is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    WlanTV is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with WlanTV.  If not, see <http://www.gnu.org/licenses/>.

import model.Packet.CH_MODES;
import model.Transaction.OneTransaction;

public class Statistics {
	String[] totalDur = {"Busy","Access","Free"};
	public DataSet dsTotalDur = new DataSet("Bandwidth distribution",totalDur,true);

	String[] framePartDur = {"Preamble","PLCP","MAC","SIFS"};
	public DataSet dsFPartDur = new DataSet("Frame part time distribution",framePartDur,true);

	String[] frameTypeDur = {"Management","Control","Data","Unknown"};
	public DataSet dsFTypeDur = new DataSet("Frame type time distribution",frameTypeDur,true);

	String[] modes = {"802.11","802.11g","802.11a","802.11b_short","802.11b_long","Other"};
	public DataSet dsModeCount = new DataSet("Frame count per mode",modes,false);

	String[] rates = {"1Mbps","2Mbps","5.5Mbps","6Mbps","9Mbps","11Mbps","12Mbps","18Mbps",
			"22Mbps","24Mbps","33Mbps","36Mbps","48Mbps","54Mbps"};
	public DataSet dsRateCount = new DataSet("Frame count per data rate",rates,false);
	
	String[] frameQ = {"Normal","Retry","BadFCS","Retry&BadFCS"};
	public DataSet dsErrorCount = new DataSet("Frame count vs quality",frameQ,false);
	
	public Statistics(Transaction transaction, Availability availability){
		dsTotalDur.a[0] = availability.getBusyTime();
		dsTotalDur.a[1] = availability.getAccessTime();
		dsTotalDur.a[2] = availability.getFreeTime();

//		long totalBackoffTime = 0; 
//		for (OneTransaction one : s.transaction.list) {
//		totalBackoffTime += one.backOffTime;
//		}
//		dsFPartDur.a[5] = (int)totalBackoffTime; //TODO

//		synchronized (s.packets) {
		for (OneTransaction one : transaction.list) {
			if (!one.hide && one.timeStamp+one.totalDur>=availability.startTime && one.timeStamp<=availability.endTime) {
				dsFPartDur.a[3] += one.sifsDur;
				
				for (Packet p: one.packetList){
					//ModeNumber
					if(p.chMode == CH_MODES.m11){
						dsModeCount.a[0]++;
					}
					else if(p.chMode == CH_MODES.m11g) {
						dsModeCount.a[1]++;
					}
					else if(p.chMode == CH_MODES.m11a) {
						dsModeCount.a[2]++;
					}
					else if(p.chMode == CH_MODES.m11b_short) {
						dsModeCount.a[3]++;
					}
					else if(p.chMode == CH_MODES.m11b_long) {
						dsModeCount.a[4]++;
					}
					else
						dsModeCount.a[5]++;

					//DataRate
					int a=(int)(10*p.frameRate);					
					switch(a){
					case 0:
						dsRateCount.a[0]++;
						break;
					case 10:
						dsRateCount.a[0]++;
						break;
					case 20:
						dsRateCount.a[1]++;
						break;
					case 55:
						dsRateCount.a[2]++;
						break;
					case 60:
						dsRateCount.a[3]++;
						break;
					case 90:
						dsRateCount.a[4]++;
						break;
					case 110:
						dsRateCount.a[5]++;
						break;
					case 120:
						dsRateCount.a[6]++;
						break;
					case 180:
						dsRateCount.a[7]++;
						break;
					case 220:
						dsRateCount.a[8]++;
						break;
					case 240:
						dsRateCount.a[9]++;
						break;
					case 330:
						dsRateCount.a[10]++;
						break;
					case 360:
						dsRateCount.a[11]++;
						break;
					case 480:
						dsRateCount.a[12]++;
						break;
					case 540:
						dsRateCount.a[13]++;
						break;
					default:
						dsRateCount.a[14]++;
					break;
					}

					//Frame type
					if ((p.wlanSubtype & 0x30) == 0) {
						// management frame
						dsFTypeDur.a[0]+=p.frameDur;
					}
					else if ((p.wlanSubtype & 0x30) == 0x10) {
						// control frame
						dsFTypeDur.a[1]+=p.frameDur;
					}
					else if ((p.wlanSubtype & 0x30) == 0x20) {
						// data frame
						dsFTypeDur.a[2]+=p.frameDur;
					}
					else { 
						dsFTypeDur.a[3]+=p.frameDur;
					}

					//BusyTime
					dsFPartDur.a[0]+=p.getPreambleDur();
					dsFPartDur.a[1]+=p.getPlcpDur();
					dsFPartDur.a[2]+=p.psduDur;

					//State
					if((p.wlanBadFcs==1)&&(p.wlanRetry==0)){
						//Frame is badfcs
						dsErrorCount.a[2]++;
					}
					else if((p.wlanBadFcs==0)&&(p.wlanRetry==1)){
						//Frame is retransmitted
						dsErrorCount.a[1]++;
					}
					else if((p.wlanBadFcs==1)&&(p.wlanRetry==1)){
						dsErrorCount.a[3]++;
					}
					else if((p.wlanBadFcs==0)&&(p.wlanRetry==0)){
						//normal frame
						dsErrorCount.a[0]++;
					}
				}
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -