#include #include #include "simulation.h" #include "random.h" #define NUM_PORTS 4 #define MIN_FRAME_SIZE 64 #define MAX_FRAME_SIZE 32768 #define FRAME_SPACE 960 #define t_frame (double)80*size #define t_interval t_frame+FRAME_SPACE+negexp(1/(double)lambda) #define t_sim 10*1E9 using namespace std; class TFrame : public CProcess { private: unsigned in_port, out_port, size; double lambda, *Fx; virtual void Run(); public: TFrame(unsigned ip, double l, double *F) { in_port = ip; lambda = l; Fx = F; out_port = discrete(Fx); size = (unsigned) uniform(MIN_FRAME_SIZE, MAX_FRAME_SIZE); }; unsigned getInPort() {return in_port;}; unsigned getOutPort() {return out_port;}; unsigned getFrameSize() {return size;}; }; class TPort : public CProcess { private: int port; virtual void Run(); public: TPort(int p) {port = p;}; }; template class Stat { private: T suma; T max; int pocet; public: Stat() {suma=0; max=0; pocet=0;}; void addItem(T item) {pocet++; suma+=item; if(item > max) max=item;}; T getMax() {return max;}; double getAvg() {return suma/(double) pocet;}; }; CHead *PortFIFO[NUM_PORTS]; // Vystupni fronty portu TPort *Port[NUM_PORTS]; // Obsluhy portu Stat