package Simulator; /* generate the network traffic we generate the traffic of the network through changing the traffic message size the biggest message size is 1500 bytes (10M traffic) */ public class Traffic { int TrafficMessSize; // the traffic message size String trafficType; // what kind of traffic you want to generate // Flat/Slope/Web/VoIP distribution double TIntervalTime; // (message size is constant) we generate the traffic by changing the lanuching interval time between messages // for linear(slope) traffic pattern private double segmentValue; // the changed traffic mess size in one segment. private int segmentNo; private int segmentNum; private boolean angle; // true is positive angle, false is negetive value private int StartTrafficMessSize; // the beginning message size // for OverLoad traffic pattern private double maxTimeInterval,minTimeInterval; // constractor for flat/static traffic public Traffic(double bottleneckBandwidth, float bandwidth, String trafficType, int MessSize, double TBIntervalTime) { // bandwidth means the available bandwidth this.TrafficMessSize = MessSize*8; this.trafficType = trafficType; double quote = (bandwidth*1e+6)/bottleneckBandwidth; int QueuingSize = (int) (46*8*(1/quote - 1)); this.TIntervalTime = (TBIntervalTime / (TBIntervalTime*bottleneckBandwidth + QueuingSize))*(MessSize*8); } // constractor for Slope traffic public Traffic(String trafficType, double maxTimeInterval,double minTimeInterval, int Size, double SMT, double EMT, double PBIntervalTime) { this.TrafficMessSize = Size*8; // bits this.trafficType = trafficType; this.TIntervalTime = maxTimeInterval; this.maxTimeInterval = maxTimeInterval; this.minTimeInterval = minTimeInterval; //this.PBIntervalTime = PBIntervalTime; segmentNum = (int) (Math.floor((EMT - SMT)/PBIntervalTime)); segmentValue = ((maxTimeInterval - minTimeInterval) / (segmentNum-5)); segmentNo = 0; } // constractor for web traffic public Traffic(String trafficType) { this.trafficType = trafficType; } public void ArguChange(boolean changed) { if (trafficType.compareTo("Flat")==0) { // do nothing } if (trafficType.compareTo("Web")==0) { // time gap between two request messages(sleep time) is pareto distribution // time gap between two reference messages is weibull distribution // the reference number in one web page is the pareto distribution // file size is the pareto distribution // No arguments need to be changed. } if (trafficType.compareTo("Slope")==0) { // time gap between two traffic messages is switched between alternativeTimeInterval and TIntervalTime // until it reachs the minTimeInterval, then starts from maxTimeInterval again. // file size is constant if (changed) { segmentNo ++; if (segmentNo < (segmentNum-5)) TIntervalTime = maxTimeInterval - (segmentNo * segmentValue); else TIntervalTime = minTimeInterval; } } } }