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

📄 ttnetwork.h

📁 一个很棒的网络控制系统仿真软件
💻 H
字号:
#define max(A,B) ((A) > (B) ? (A) : (B))#define min(A,B) ((A) < (B) ? (A) : (B))enum { CSMACD, CSMAAMP, RR, FDMA, TDMA, SFDSE };enum { COMMONBUF, OUTPUTBUF };enum { BUFFULLRETRY, BUFFULLDROP };#define COLLISION_WINDOW 0.000001  // 1 us#define ETHERNET_MINFRAMESIZE 64class NWmsg : public Node { public:  int sender;  int receiver;  int timesRead;  void *data;       // message content  char* dataMATLAB;   int length;       // in bytes - determines the transmission time  double prio;  double waituntil;    // when wait in pre/postprocQ has finished  double remaining;    // remaining nbr of bytes to be transmitted  void print();};void NWmsg::print() {  printf("msg: sender=%d, receiver=%d, length=%d ", sender, receiver, length);}class NWnode { public:  List *preprocQ;  List *inputQ;  List *postprocQ;  List *outputQ;  List *switchQ;  int state;  int nbrcollisions;  double waituntil;  int swstate;   // state of switch output  int switchmem; // output buffer memory  NWnode(); // constructor};NWnode::NWnode() {  preprocQ = new List("preprocQ",0);  inputQ = new List("inputQ",0);  outputQ = new List("outputQ",0);  postprocQ = new List("postprocQ",0);  switchQ = new List("switchQ",0);  state = 0; // idle  nbrcollisions = 0;  waituntil = 0.0;  swstate = 0; // idle}class RTnetwork { public:  int type;  int networkNbr;  int nbrOfNodes;  double datarate;     /* bytes(!)/s */  int minsize;         /* minimum frame size (bytes) */  double predelay;     /* preprocessing delay (s) */  double postdelay;    /* postprocessing delay (s) */  double lossprob;     /* probability of a packet getting lost */  double *bandwidths;  /* FDMA only: vector of bandwidth factors */  double slottime;     /* TDMA only: size of a slot in seconds */  int schedsize;       /* TDMA only: the length of the cyclic schedule */  int *schedule;       /* TDMA only: vector of senders */  int memsize;         /* SFDSE only: switch memory size */  int buftype;         /* SFDSE only: switch buffer type */  int overflow;        /* SFDSE only: switch overflow behavior */  NWnode **nwnodes;    /* vector of network nodes */  double time;      // Current time in simulation  double prevHit;   // Previous invocation of kernel  double nextHit;   // Next invocation of kernel  double *inputs;  double *oldinputs;  double *outputs;      // trigger outputs  double *sendschedule; // schedule outputs  int sending;          // nbr of the sending node, -1 if none (not FDMA)  double waituntil;     // the network is idle until this time (CSMA)  double lasttime;      // last time a frame started to be sent (CSMA)  int rrturn;           // Round Robin turn (0 - nbrOfNodes-1) (RR)  double currslottime;  // time current slot started (TDMA)  int slotcount;        // current slot in the schedule (TDMA)  int switchmem;        // global switch memory  RTnetwork(); // constructor};RTnetwork::RTnetwork() {  bandwidths = NULL;  schedule = NULL;  inputs = NULL;  oldinputs = NULL;  outputs = NULL;  sendschedule = NULL;}

⌨️ 快捷键说明

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