📄 mac-802_16.h
字号:
/**************************************************************************** * WiMAX module * * Copyright (C) 2008 Juliana Freitag Borin, Flavio Kubota and Nelson L. * S. da Fonseca - wimaxgroup@lrc.ic.unicamp.br * * This program is a free result: you can redistribute it and/or modify * it under the terms of the UOL Public License Version 1 or (at your * option) any later version. The license terms are available at * http://bolsapesquisa.uol.com.br/lpu.jhtm. * * This file contains SS and BS class definitions. * Both of these classes are derived from an abstract base class * * Revisions: * $A0: 4/2/03: int byte counters were exceeding the large int... * change to double * $A1: 6/22/2003: change int byte counters to doubles * $A2: 7/16/04: added look_at_queue method so we can examine packets queued * in the SS. * And, added filterACKs method to allow ack suppression * $A4: 8/10/04: Added print_short_map_list * $A5: 9/18/04: Added counter: total_num_mgt_pkts_US * $A6: 9/28/04: added packetTrace method in bs code * $A7: 2/17/2005: upstream rate control (Viraj) * $A8: 3/6/05: Support tracking avg number of IP packets per concat frame * $A9: 3/27/05: Fixed bug with default upstream flow table index * $A10: 4/7/05: Added insert_pkt_to_Head() method * $A11: 4/29/05: Added timingsTrace() method to the SS * $A12: 5/3/05: Add MapPropDelay variable to BS * $A13: 3/15/06: (J. Freitag) included non-real-time service * $A14: 4/03/06: (J. Freitag) included downlink QoS scheduling services * $A15: 8/30/06: (J. Freitag) new uplink scheduling algorithm at the base station * $A16: 4/27/07: (J. Freitag) included extended-real-time service * $A17: 7/10/07: (J. Freitag) included periodic aggregate bandwidth request * $A18: 7/16/07: (J. Freitag) included the ertPS service in the downlink direction * $A19: 08/13/07: (J. Freitag) excluded the DataGrantPending, since in the 802.16 standard * the SSs has no knowledge about the pending grants in the BS queues. ***************************************************************************//*! \file mac-802_16.h This file contains SS and BS class definitions. Both of these classes are derived from an abstract base class*/#ifndef ns_mac_802_16_h#define ns_mac_802_16_h#include "hdr-802_16.h"/*=======================MACRO & CONSTANT DEFINITIONS=====================*/#define SET_RX_STATE(x) \ { \ rx_state_ = (x); \ }#define SET_TX_STATE(x) \ { \ tx_state_ = (x); \ }/*========================END MACRO DEFINTIONS=============================*//*=======================CLASS DEFINITIONS============================*//*=======================Abstract Base class declaration===============*//*! Mac802_16BS class */class Mac802_16BS;/**************************************************************************************************************************************************//*! Mac802_16 class */class Mac802_16 : public Mac { friend class TxPkt802_16Timer; friend class RxPkt802_16Timer; public: /* Timers */ TxPkt802_16Timer mhTxPkt_ ; RxPkt802_16Timer mhRxPkt_ ; /* Variables to store configurable parameters for channels These variables will be filled-in by calling 'command' function from the TCL code */ struct upstream_channel upchannel; /* Upstream channel parameters */ struct downstream_channel downchannel;/* Downstream channel parameters*/ char collision; /* Indicate whether collision occured */ u_int16_t bytes_pminislot; /* Number of bytes per mini-slot */ u_int32_t minislots_psec; /* Number of min-slots per second */ double size_mslots; /* In micro-seconds..*/ u_int16_t size_ureqgrant; /* Simulation statistics variables */ u_int32_t avg_pkts; u_int32_t avg_bytes; u_int32_t num_pkts; /* Num of packets received per sec */ //$A1 double num_bytes; /* Num of bytes received per sec */ /*STATISTICS*/ u_int32_t total_num_sent_pkts; /* total Num of packets sent */ /* Note: need this to be a TracedDouble to access from tcl right ???? */ //$A0: Need to change to a double to avoid int overrun double total_num_sent_bytes; /* total Num of bytes received used to for BSdown used to for SSup */ //$A5 u_int32_t total_num_mgt_pkts_US; /* total Num of mgt received */ u_int32_t total_num_rng_pkts_US; u_int32_t total_num_concat_pkts_US; u_int32_t total_num_frag_pkts_US; u_int32_t total_num_req_pkts_US; u_int32_t total_num_plaindata_pkts_US; u_int32_t total_num_concatdata_pkts_US; u_int32_t total_num_frames_US; u_int32_t total_num_BE_pkts_US; u_int32_t total_num_RTVBR_pkts_US; u_int32_t total_num_UGS_pkts_US; u_int32_t total_num_OTHER_pkts_US; u_int32_t total_num_rx_pkts; /* total Num of packets received */ //$A0 double total_num_rx_bytes; /* total Num of bytes received used to for BSup used to for SSdown */ //$A1 double total_num_BW_bytesUP; /* total Num of bytes for BW calculation*/ double total_num_BW_bytesDOWN; /* total Num of bytes for BW calculation*/ double total_num_appbytesUS; /*total Num app bytes received on US w/o 802_16 overhead*/ double total_num_appbytesDS; /*total Num app bytes forwarded on DS w/o 802_16 overhead*/ u_int32_t total_packets_dropped;/* total packets dropped for bs, this is downstream, for ss, this is upstream*/ double last_BWCalcTime; /* Indicates the last time the BW was computed*/ double last_rtime; /* Indicates the last time the avg was taken */ u_int32_t avg_mgmtpkts; u_int32_t num_mgmtpkts; /* Num of packets received per sec */ u_int32_t avg_mgmtbytes; u_int32_t num_mgmtbytes; /* Num of packets received per sec */ double last_mmgmttime; /* Indicates the last time the avg was taken */ /* Support for multiple 802_16 lans. The array stores address of each bs, so that ss's can use it during the registration */ static int lan_num; static Mac802_16BS* bs_arr[NUM_802_16_LANS]; /* Internal MAC state */ MacState rx_state_; // incoming state (MAC_RECV or MAC_IDLE) MacState tx_state_; // outgoing state int tx_active_; /* Methods */ Mac802_16(); virtual ~Mac802_16(){}; virtual void BsUcdHandler(Event *e) {}; virtual void BsSyncHandler(Event *e) {}; virtual void BsRngHandler(Event *e) {}; virtual void BsMapHandler(Event *e) {}; virtual void SSRngHandler(Event *e) {}; virtual void SSSndTimerHandler(Event *e) {}; virtual void SSReqTimerHandler(Event *e) {}; virtual void RecvFrame(Packet* p,int i) {}; virtual void BsSendHandler(Event *e) {}; virtual void BsSndTimerHandler(Event *e) {}; //$A15 virtual void BsWindowTimerHandler(Event * e) {}; //#ifdef RATE_CONTROL//------------------------------------------------- virtual void BsTokenHandler(Event *e) {}; //#endif//-------------------------------------------------------------- int command(int argc, const char*const* argv); /* Timer handler */ void recvHandler(Event *e); void sendHandler(Event *e); void recv(Packet* p, Handler *h); void configure_upstream(); void set_bit(u_char*,int,int); void dump_pkt(Packet*); char ClassifyDataMgmt(Packet*); int is_idle(); int match(Packet*, struct flow_classifier); int bit_on(u_char, int); u_int32_t calculate_slots(double,double); u_int32_t power(u_int32_t,u_int32_t); double TX_Time(Packet *p,int); Packet* AllocPkt(int); //$A14 void insert_alloclist(aptr&,u_int16_t,double,double,u_int16_t,u_int32_t); int CanBeSent(aptr&,Packet*,u_int32_t); int len_queue(plist); //$A16 int CanErtPSBeSent(aptr&, Packet*);}; /*================= End Abstract Base class declaration===============*/ /*=======================BS class declaration=======================*//**************************************************************************************************************************************************//*! Mac802_16 class */class Mac802_16BS : public Mac802_16 { friend class Map802_16Timer; friend class BsUcd802_16Timer; friend class BsRng802_16Timer; friend class BsSync802_16Timer; friend class BsTxPkt802_16Timer; friend class BsServiceFlowSendTimer; //#ifdef RATE_CONTROL //------------------------------------------------- friend class BsToken802_16Timer; //#endif //-------------------------------------------------------------- public: struct ss_record *SSRecord; /* All the SSs information will be stored*/ u_int16_t CurrIndexSSTable; /* Registration function called by SSs before they start*/ int register_to_bs(int macaddr, u_int16_t priority, u_char def_up, u_char def_dn, struct upstream_sflow *UpEntry, u_char UpSize, struct downstream_sflow *DownEntry, u_char DownSize); int compare_priority(priority_array_p A, priority_array_p B); Mac802_16BS(); ~Mac802_16BS(){}; protected: int command(int argc, const char*const* argv); private: //$A15 - window used to control the provision of the minimum BW requests double window_; /* Timer variables */ Map802_16Timer mhMap_; BsRng802_16Timer mhRng_; BsUcd802_16Timer mhUcd_; BsSync802_16Timer mhSync_; BsTxPkt802_16Timer mhBsTxPkt_; //$A14 BsServiceFlowSendTimer mhBsSend_; //$A15 BsUplinkSchedWindowTimer mhWdw_; //#ifdef RATE_CONTROL//------------------------------------ BsToken802_16Timer mhToken_; tkptr TokenList; //#endif//------------------------------------------------- /* Configuration parameters */ struct bs_conf_param Conf_Table_; u_int16_t SizeSSTable; /* Simulation statistics variables */ struct bs_statistics SSStatistics_; /*$A13 and $A14 /* Allocation algorithm variables struct job* job_list[10]; /*Uplink: job_list[0] -> UGS periodic (data), job_list[1] -> RT-VBR periodic (bw request), job_list[2] -> NRT-POLL periodic (bw request), job_list[3] -> RT-VBR non periodic (data), job_list[4] -> NRT-POLL non periodic (data), job_list[5]-> best effort (data), Downlink: job_list[6] -> UGS periodic (data), job_list[7] -> RT-VBR non periodic (data), job_list[8] -> NRT-POLL non periodic (data), job_list[9] -> best effort (data), */ //$A15 /*Now, I'm implementing a new scheduling algorithm just for uplink*/ struct job* job_list[8]; /*Uplink: queues for the clients' (ss's) requests at the base station (bs) job_list[0] -> high priority queue - reqs must be schedule in the next frame, job_list[1] -> intermediate queue - RT-POLL and NRT-POLL requests job_list[2] -> low priority queue - best-effort, Downlink: job_list[3] -> UGS periodic (data), job_list[4] -> RT-POLL non periodic (data), job_list[5] -> ERT-POLL non periodic (data) job_list[6] -> NRT-POLL non periodic (data), job_list[7] -> best effort (data), */#define UP_HIGH_QUEUE 0#define UP_INTERM_QUEUE 1#define UP_LOW_QUEUE 2#define DOWN_UGS_QUEUE 3#define DOWN_RT_QUEUE 4#define DOWN_ERT_QUEUE 5 //$A18#define DOWN_NRT_QUEUE 6 #define DOWN_BE_QUEUE 7 /* MAP variables */ mapptr mptr; /* Pointer to the head of MAP list */ bs_sptr BsSndList; /* Snd timer list header */ double map_stime; double omap_stime; double map_etime; double omap_etime; double map_acktime; double AckTime; double max_slots_pmap; double next_map; int numIE; int map_lookahead; int MAP_LOOKAHEAD; // Configurable from tcl script int max_burst_slots; int rem_overhead;//$A12 int MapPropDelay; /* Simulation output parameters */ int size_rtqueue; /*Avg size of rtqueue per sec */ int avg_szrtqueue; double last_mrqtime; int size_bfqueue; int avg_szbfqueue; double last_mbfqtime; int num_bfreq; int avg_bfreq; double last_mbfreq; int num_rtreq; int avg_rtreq; double last_mrtreq; double last_dmptime; u_int32_t num_dgrant; /* Avg num of data grants per MAP */ u_int32_t num_contention; /* Avg num of contention grants per MAP */ u_int32_t num_req; /* Avg num of Unicast req per MAP */ u_int32_t num_gpend; /* Avg num of grant pending per MAP */ u_int32_t avg_dgrant; /* Avg num of data grants per MAP */ u_int32_t avg_contention; /* Avg num of contention grants per MAP */ u_int32_t avg_req; /* Avg num of Unicast req per MAP */ u_int32_t avg_gpend; /* Avg num of grant pending per MAP */ u_int32_t dropped_tokenq; /* total packets dropped at the token queues of different flows*/ u_int32_t dropped_dsq; /* total packets dropped at the DS queue*/ /* Tuning parameters */ double proportion; /* To control the proportion of allocation between RT-POLL and Best-effort */ u_char contention_thrhold;/* Indicates the tolerable threshhold for percentage of collisions in contention slot.If this threshhold is crossed , then number of contention-slots will be increased */ u_char network_status; /* 0 - underutilized, 1 - overloaded */ u_int32_t rtpoll_ddlinemiss; /* Number of ddline misses per second of RT_POLL data grants */ u_int32_t beffort_ddlinemiss; /* Number of ddline misses per second of BEST_EFFORT data grants */ int32_t num_rtslots; //$A13 int32_t num_nrtslots; int32_t num_befslots;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -