ns-2.28/mac/mac-802_16.h

Go to the documentation of this file.
00001 /****************************************************************************
00002  * This file contains SS and BS class definitions. 
00003  * Both of these classes are derived from an abstract base class 
00004  *
00005  * Revisions:
00006  *   $A0:  4/2/03:  int byte counters were exceeding the large int...
00007  *                  change to double
00008  *   $A1:  6/22/2003:  change int byte counters to doubles
00009  *   $A2: 7/16/04:  added look_at_queue method so we can examine packets queued
00010  *                  in the SS.
00011  *                  And, added filterACKs method to allow ack suppression
00012  *   $A4: 8/10/04:  Added print_short_map_list 
00013  *   $A5: 9/18/04:  Added  counter: total_num_mgt_pkts_US
00014  *   $A6: 9/28/04:  added packetTrace method in bs code
00015  *   $A7: 2/17/2005: upstream rate control (Viraj)
00016  *   $A8: 3/6/05:   Support tracking avg number of IP packets per concat frame    
00017  *   $A9: 3/27/05:  Fixed bug with default upstream flow table index
00018  *   $A10: 4/7/05:  Added insert_pkt_to_Head() method
00019  *   $A11: 4/29/05: Added timingsTrace() method to the SS
00020  *   $A12: 5/3/05:  Add MapPropDelay variable to BS
00021  *   $A13: 3/15/06: (J. Freitag) included non-real-time service
00022  *   $A14: 4/03/06: (J. Freitag) included downlink QoS scheduling services
00023  *   $A15: 8/30/06: (J. Freitag) new uplink scheduling algorithm at the base station
00024  *   $A16: 4/27/07: (J. Freitag) included extended-real-time service
00025  *   $A17: 7/10/07: (J. Freitag) included periodic aggregate bandwidth request 
00026  *   $A18: 7/16/07: (J. Freitag) included the ertPS service in the downlink direction
00027  *   $A19: 08/13/07: (J. Freitag) excluded the DataGrantPending, since in the 802.16 standard
00028  *                   the SSs has no knowledge about the pending grants in the BS queues. 
00029   ***************************************************************************/
00030 
00036 #ifndef ns_mac_802_16_h
00037 #define ns_mac_802_16_h
00038 
00039 #include "hdr-802_16.h"
00040 
00041 /*=======================MACRO & CONSTANT DEFINITIONS=====================*/
00042 
00043 #define SET_RX_STATE(x)                 \
00044   {                                             \
00045     rx_state_ = (x);                            \
00046   }
00047 #define SET_TX_STATE(x)                         \
00048   {                                                     \
00049     tx_state_ = (x);                                    \
00050   }
00051 
00052 /*========================END MACRO DEFINTIONS=============================*/
00053 
00054 
00055 
00056 /*=======================CLASS DEFINITIONS============================*/
00057 
00058 /*=======================Abstract Base class declaration===============*/
00060 class Mac802_16BS;
00061 
00062 /*************************************************************************
00063 
00064 *************************************************************************/
00066 class Mac802_16 : public Mac 
00067 {
00068   friend class TxPkt802_16Timer;
00069   friend class RxPkt802_16Timer;
00070   
00071  public:
00072   /* Timers */
00073   TxPkt802_16Timer mhTxPkt_ ;
00074   RxPkt802_16Timer mhRxPkt_ ;
00075   
00076   /* 
00077      Variables to store configurable parameters for channels  
00078      These variables will be filled-in by calling 
00079      'command' function from the TCL code
00080   */    
00081   
00082   struct upstream_channel   upchannel;  /* Upstream channel parameters */
00083   struct downstream_channel downchannel;/* Downstream channel parameters*/
00084   
00085   char      collision;       /* Indicate whether collision occured */
00086   u_int16_t bytes_pminislot; /* Number of bytes per mini-slot */
00087   u_int32_t minislots_psec;  /* Number of min-slots per second */
00088   double    size_mslots;     /* In micro-seconds..*/    
00089   u_int16_t size_ureqgrant;
00090   
00091   /* Simulation statistics variables */
00092   
00093   u_int32_t avg_pkts;
00094   u_int32_t avg_bytes;
00095   u_int32_t num_pkts;  /* Num of packets received per sec */
00096   
00097   //$A1
00098   double num_bytes; /* Num of bytes received per sec */
00099   
00100   /*STATISTICS*/
00101   u_int32_t total_num_sent_pkts; /* total Num of packets sent */
00102   
00103   /*
00104     Note:  need this to be a TracedDouble to access from tcl right ????
00105   */
00106   //$A0:  Need to change to a  double to avoid int overrun
00107   
00108   double total_num_sent_bytes; /* total Num of bytes received 
00109                                   used to for BSdown 
00110                                   used to for SSup */
00111   
00112   //$A5
00113   u_int32_t total_num_mgt_pkts_US; /* total Num of mgt received  */
00114   u_int32_t total_num_rng_pkts_US; 
00115   u_int32_t total_num_concat_pkts_US; 
00116   u_int32_t total_num_frag_pkts_US; 
00117   u_int32_t total_num_req_pkts_US; 
00118   u_int32_t total_num_plaindata_pkts_US; 
00119   u_int32_t total_num_concatdata_pkts_US; 
00120   u_int32_t total_num_frames_US; 
00121   u_int32_t total_num_BE_pkts_US; 
00122   u_int32_t total_num_RTVBR_pkts_US; 
00123   u_int32_t total_num_UGS_pkts_US; 
00124   u_int32_t total_num_OTHER_pkts_US; 
00125   
00126   u_int32_t total_num_rx_pkts; /* total Num of packets received */
00127   
00128   //$A0
00129   double total_num_rx_bytes; /* total Num of bytes received 
00130                                 used to for BSup 
00131                                 used to for SSdown */
00132   
00133   //$A1
00134   double total_num_BW_bytesUP;   /* total Num of bytes for BW calculation*/
00135   double total_num_BW_bytesDOWN; /* total Num of bytes for BW calculation*/
00136   
00137   double total_num_appbytesUS;   /*total Num app bytes received 
00138                                    on US w/o 802_16 overhead*/
00139   
00140   double total_num_appbytesDS;   /*total Num app bytes forwarded 
00141                                    on DS w/o 802_16 overhead*/
00142   
00143   u_int32_t total_packets_dropped;/* total packets dropped
00144                                      for bs, this is downstream,
00145                                      for ss, this is upstream*/
00146   
00147   double last_BWCalcTime;            /* Indicates the last time the BW was computed*/
00148   
00149   double last_rtime;                 /* Indicates the last time the avg was taken */
00150   
00151   u_int32_t avg_mgmtpkts;
00152   u_int32_t num_mgmtpkts;            /* Num of packets received per sec */
00153   u_int32_t avg_mgmtbytes;
00154   u_int32_t num_mgmtbytes;           /* Num of packets received per sec */
00155   double last_mmgmttime;             /* Indicates the last time the avg
00156                                         was taken */    
00157 
00158   /* 
00159      Support for multiple 802_16 lans. The array stores address of each
00160      bs, so that ss's can use it during the registration 
00161   */  
00162   static int lan_num;
00163   static Mac802_16BS* bs_arr[NUM_802_16_LANS];
00164   
00165   /* Internal MAC state */
00166   MacState rx_state_;   // incoming state (MAC_RECV or MAC_IDLE)
00167   MacState tx_state_;   // outgoing state
00168   int tx_active_;
00169   
00170   /* Methods */
00171   Mac802_16();
00172   virtual ~Mac802_16(){};
00173   
00174   virtual void BsUcdHandler(Event *e) {};
00175   virtual void BsSyncHandler(Event *e) {};
00176   virtual void BsRngHandler(Event *e) {};
00177   virtual void BsMapHandler(Event *e) {};
00178   virtual void SSRngHandler(Event *e) {};
00179   virtual void SSSndTimerHandler(Event *e) {};
00180   virtual void SSReqTimerHandler(Event *e) {};
00181   virtual void RecvFrame(Packet* p,int i) {};
00182   virtual void BsSendHandler(Event *e) {};
00183   virtual void BsSndTimerHandler(Event *e) {};
00184   //$A15
00185   virtual void BsWindowTimerHandler(Event * e) {};
00186   
00187   //#ifdef RATE_CONTROL//-------------------------------------------------
00188   virtual void BsTokenHandler(Event *e) {};
00189   //#endif//--------------------------------------------------------------
00190   
00191   int command(int argc, const char*const* argv);
00192   
00193   /* Timer handler */
00194   void recvHandler(Event *e);
00195   void sendHandler(Event *e);
00196   void recv(Packet* p, Handler *h);
00197   void configure_upstream();
00198   void set_bit(u_char*,int,int);
00199   void dump_pkt(Packet*);
00200   char ClassifyDataMgmt(Packet*); 
00201   int is_idle();
00202   int match(Packet*, struct flow_classifier);
00203   int bit_on(u_char, int);
00204   u_int32_t calculate_slots(double,double);
00205   u_int32_t power(u_int32_t,u_int32_t);
00206   double TX_Time(Packet *p,int);
00207   Packet* AllocPkt(int);  
00208 
00209   //$A14
00210   void insert_alloclist(aptr&,u_int16_t,double,double,u_int16_t,u_int32_t);
00211   int CanBeSent(aptr&,Packet*,u_int32_t);
00212   int len_queue(plist);
00213 
00214   //$A16
00215   int CanErtPSBeSent(aptr&, Packet*);
00216 
00217 };
00218  
00219 /*================= End Abstract Base class declaration===============*/
00220  
00221 
00222 /*=======================BS class declaration=======================*/
00223 
00224 /*************************************************************************
00225 
00226 *************************************************************************/
00228 class Mac802_16BS : public Mac802_16 
00229 {
00230   friend class Map802_16Timer;
00231   friend class BsUcd802_16Timer;
00232   friend class BsRng802_16Timer;
00233   friend class BsSync802_16Timer;
00234   friend class BsTxPkt802_16Timer;
00235   friend class BsServiceFlowSendTimer;
00236   
00237   //#ifdef RATE_CONTROL //-------------------------------------------------
00238   friend class BsToken802_16Timer;
00239   //#endif //--------------------------------------------------------------
00240   
00241  public:
00242   struct ss_record *SSRecord; /* All the SSs information will be stored*/
00243   
00244   u_int16_t CurrIndexSSTable;
00245   
00246   /* Registration function called by SSs before they start*/
00247   
00248   int register_to_bs(int macaddr, 
00249                        u_int16_t priority,
00250                        u_char def_up,
00251                        u_char def_dn,
00252                        struct upstream_sflow *UpEntry,
00253                        u_char UpSize, 
00254                        struct downstream_sflow *DownEntry, 
00255                        u_char DownSize);
00256   
00257   int compare_priority(priority_array_p A, priority_array_p B);
00258 
00259   Mac802_16BS();
00260   ~Mac802_16BS(){};
00261   
00262  protected:
00263   int  command(int argc, const char*const* argv);
00264   
00265  private:
00266 
00267   //$A15 - window used to control the provision of the minimum BW requests
00268   double window_;  
00269 
00270   /* Timer variables */
00271   Map802_16Timer mhMap_;
00272   BsRng802_16Timer mhRng_;
00273   BsUcd802_16Timer mhUcd_;
00274   BsSync802_16Timer mhSync_;
00275   BsTxPkt802_16Timer mhBsTxPkt_;
00276   //$A14
00277   BsServiceFlowSendTimer mhBsSend_;
00278 
00279   //$A15
00280   BsUplinkSchedWindowTimer mhWdw_;
00281   
00282   //#ifdef RATE_CONTROL//------------------------------------
00283   BsToken802_16Timer mhToken_;
00284   tkptr TokenList;
00285   //#endif//-------------------------------------------------
00286   
00287   /* Configuration parameters */
00288   struct bs_conf_param Conf_Table_;
00289   u_int16_t SizeSSTable;
00290   
00291   /* Simulation statistics variables */
00292   struct bs_statistics SSStatistics_;
00293   
00294   /*$A13 and $A14
00295   /* Allocation algorithm variables 
00296   struct job* job_list[10]; /*Uplink: 
00297                                job_list[0] -> UGS periodic (data), 
00298                                job_list[1] -> RT-VBR periodic (bw request), 
00299                                job_list[2] -> NRT-POLL periodic (bw request),
00300                                job_list[3] -> RT-VBR non periodic (data),
00301                                job_list[4] -> NRT-POLL non periodic (data), 
00302                                job_list[5]->  best effort (data), 
00303                               Downlink:
00304                                job_list[6] -> UGS periodic (data),     
00305                                job_list[7] -> RT-VBR non periodic (data), 
00306                                job_list[8] -> NRT-POLL non periodic (data), 
00307                                job_list[9] -> best effort (data),
00308                              */
00309   //$A15
00310   /*Now, I'm implementing a new scheduling algorithm just for uplink*/
00311   struct job* job_list[8]; /*Uplink: queues for the clients' (ss's) requests at the base station (bs)
00312                               job_list[0] -> high priority queue - reqs must be schedule in the next frame, 
00313                               job_list[1] -> intermediate queue - RT-POLL and NRT-POLL requests
00314                               job_list[2] -> low priority queue - best-effort,
00315                              Downlink: 
00316                               job_list[3] -> UGS periodic (data),     
00317                               job_list[4] -> RT-POLL non periodic (data), 
00318                               job_list[5] -> ERT-POLL non periodic (data)
00319                               job_list[6] -> NRT-POLL non periodic (data), 
00320                               job_list[7] -> best effort (data),
00321                             */
00322 #define UP_HIGH_QUEUE 0
00323 #define UP_INTERM_QUEUE 1
00324 #define UP_LOW_QUEUE 2
00325 #define DOWN_UGS_QUEUE 3
00326 #define DOWN_RT_QUEUE 4
00327 #define DOWN_ERT_QUEUE 5 //$A18
00328 #define DOWN_NRT_QUEUE 6 
00329 #define DOWN_BE_QUEUE 7
00330 
00331   /* MAP variables */
00332   mapptr mptr;         /* Pointer to the head of MAP list */
00333 
00334   bs_sptr BsSndList; /* Snd timer list header */
00335 
00336   double map_stime;
00337   double omap_stime;
00338   double map_etime;
00339   double omap_etime;
00340 
00341   double map_acktime;
00342   double AckTime; 
00343   double max_slots_pmap;
00344   double next_map;
00345 
00346   int numIE;
00347   int map_lookahead;
00348   int MAP_LOOKAHEAD; // Configurable from tcl script
00349   int max_burst_slots;  
00350   int rem_overhead;
00351 //$A12 
00352   int MapPropDelay;
00353   
00354   /* Simulation output parameters */
00355   int size_rtqueue; /*Avg size of rtqueue per sec */
00356   int avg_szrtqueue;
00357   double last_mrqtime;
00358 
00359   int size_bfqueue;
00360   int avg_szbfqueue;
00361   double last_mbfqtime;
00362   
00363   int num_bfreq;
00364   int avg_bfreq;
00365   double last_mbfreq;
00366   
00367   int num_rtreq;
00368   int avg_rtreq;
00369   double last_mrtreq;
00370   
00371   double last_dmptime;
00372   
00373   u_int32_t num_dgrant;     /* Avg num of data grants per MAP */
00374   u_int32_t num_contention; /* Avg num of contention grants per MAP */
00375   u_int32_t num_req;        /* Avg num of Unicast req per MAP */
00376   u_int32_t num_gpend;      /* Avg num of grant pending per MAP */
00377   
00378   u_int32_t avg_dgrant;     /* Avg num of data grants per MAP */
00379   u_int32_t avg_contention; /* Avg num of contention grants per MAP */
00380   u_int32_t avg_req;        /* Avg num of Unicast req per MAP */
00381   u_int32_t avg_gpend;      /* Avg num of grant pending per MAP */
00382   
00383   u_int32_t dropped_tokenq; /* total packets dropped at the token 
00384                                queues of different flows*/
00385   u_int32_t dropped_dsq;    /* total packets dropped at the DS queue*/
00386   
00387   /* Tuning parameters */
00388   double proportion;        /* To control the proportion of allocation
00389                                between RT-POLL and Best-effort */
00390 
00391   u_char contention_thrhold;/* Indicates the tolerable threshhold
00392                                for percentage of collisions in 
00393                                contention slot.If this threshhold
00394                                is crossed , then number of 
00395                                contention-slots will be 
00396                                increased */
00397   
00398   u_char network_status;    /* 0 - underutilized, 1 - overloaded */
00399   
00400   u_int32_t rtpoll_ddlinemiss;  /* Number of ddline misses per 
00401                                    second of RT_POLL data grants */
00402   
00403   u_int32_t beffort_ddlinemiss; /* Number of ddline misses per 
00404                                    second of BEST_EFFORT data grants */
00405   int32_t num_rtslots;
00406   //$A13
00407   int32_t num_nrtslots;
00408   int32_t num_befslots;
00409   u_int32_t num_adjust_slots;
00410   
00411   Event intr;
00412 
00413   /* Events to be consumed on expiration of management messages*/
00414   Event uintr; 
00415   Event sintr;
00416   Event rintr;
00417   Event rxintr_; // Event to be consumed when SSMgmt timer expires..
00418   //$A21 - event to be consimed by the window for minimum bw provision timer
00419   Event wintr;
00420   
00421   static int next_flowid;
00422   
00423   /*
00424     DROP-TAIL
00425     Note: can also create a REDQueue ....
00426     Not that simple....
00427   */
00428   // PacketQueue * txq_; /* Packet queue for downstream channel */
00429   
00430   qlist   txq_; /* Packet queue for downstream channel */
00431   
00432   // DropTail * txq_; /* Packet queue for downstream channel */
00433   // Queue * txq_; /* Packet queue for downstream channel */
00434   
00435   int qnp_;                      /* same as len_ */
00436   int qnb_;                      /* no bytes in queue */
00437   int max_qnp_;                  /* Max # of pkts observed */
00438   int max_qnb_;                  /* Max # of bytes observed */
00439   int min_qnp_;                  /* Min # of pkts  observed */
00440   int min_qnb_;                  /* Min # of bytes observed */
00441 
00442   int queue_total_bytes_in, queue_total_bytes_out;  /*used for final 
00443                                                       utilization stats*/
00444   
00445   //$A0: switch to doubles
00446   double util_total_bytes_US;    /* used for final utilization stats*/
00447   double util_total_bytes_DS;    /* used for final utilization stats*/
00448   int util_total_pkts_US;        /* used for final utilization stats*/
00449   int util_total_pkts_DS;        /* used for final utilization stats*/
00450   
00451   //$A0
00452   double util_bytes_US;          /* used by dump802_16UtilStats*/
00453   double util_bytes_DS;          /* used by dump802_16UtilStats*/
00454   int  qlim_;                    /* max queue size in packets */
00455   double lastDumpTime;
00456   double lastUtilDumpTime;
00457   
00458   /* Methods */  
00459   inline void SSRngHandler(Event * e) {}
00460   inline void SSSndTimerHandler(Event * e) {}
00461   inline void SSReqTimerHandler(Event * e) {}
00462   inline void UnlockQueue() {}
00463 
00464   void BsMapHandler(Event *e);
00465   void BsSyncHandler(Event * e);
00466   void BsUcdHandler(Event * e);
00467   void BsRngHandler(Event * e);
00468 
00469   //$A15  
00470   void BsWindowTimerHandler(Event * e);
00471 
00472   
00473   //#ifdef RATE_CONTROL//-------------------------------------
00474   void RateControl(Packet*, int,int,int);
00475   double getupdatedtokens(int,int);
00476   void BsTokenHandler(Event*);
00477   void insert_tokenlist(double,int,int);
00478   //#endif//-------------------------------------------------
00479                 
00480   void sendUp(Packet* p);
00481   void sendDown(Packet* p);
00482   void RecvFrame(Packet*,int);
00483   void PassDownstream(Packet*);
00484   void HandleInData(Packet*,int,int);
00485   void HandleInMgmt(Packet*);
00486   void HandleFrag(Packet*);
00487   void HandleConcat(Packet*,int,int);
00488   void ReleaseJobs();
00489   void fill_job(struct job*,char,char,double,u_int32_t,double,double,u_int16_t);
00490   void InsertJob(struct job*,int);
00491   //$A17
00492   //void HandleReq(u_int16_t,int,int);
00493   void HandleReq(u_int16_t,int,int,bool);
00494   void tune_parameters();
00495   void alloc_bw();
00496   void delete_joblist(int);
00497   void PhUnsupress(Packet*,int,int);
00498   void ApplyPhs(Packet*,int,int );
00499   void MakeAperiodicAlloc(struct job*,mapptr,int);
00500   void AllocMemSSrecord();
00501   void MakePeriodicAllocation(int,mapptr,double);
00502   void ReOrder(mapptr);
00503   void MarkOtherSlots(mapptr,u_int32_t,int);
00504   void jobdrop(mapptr);
00505   void MarkGrantPending(u_int32_t*,double);
00506   void SendMap();
00507   u_int32_t  MarkUnusedSlots(u_int32_t);
00508   void find_flowindex(u_int16_t,int*,int*);
00509   void SendFrame(Packet*,int);
00510   void BsSendHandler(Event *); 
00511   void dump_stats();
00512   void ParseExtHdr(Packet *);
00513   void dumpUGSJITTER(char *);
00514   void UpdateJitter(int,u_int16_t, double);
00515   
00516   //u_char find_size_map();
00517   
00518   int find_size_map();
00519   int NumContSlots(mapptr *);
00520   int ChkQoSJobs(double,double);
00521   int  classify(Packet*,char,int*);
00522   int insert_mapjob(int , jptr , u_int32_t *, int);
00523   int insert_mapjob(struct job*,u_int32_t*);
00524   int find_ss(int);
00525   u_int32_t MarkOtherAlloc(u_int32_t);
00526   u_int32_t FillMap(int,int,int,int,int); 
00527   mapptr find_best_hole(u_int32_t);
00528   mapptr find_next(mapptr);
00529   mapptr find_prv(mapptr);
00530   mapptr TryAlloc(double,u_int32_t);
00531   double determine_deadline(char, int,int);
00532   double FitMap(mapptr,double);
00533   double CalculateAckTime();
00534   
00535   /* De-bugging functions */
00536   void print_job_list(int);
00537   void print_map_list();
00538   
00539   //$A4
00540   void print_short_map_list(Packet* Pkt);
00541   void delete_maplist();
00542   void dumpBWBS(char *fileName);
00543   void dumpFinalBSStats(char *fileName, int DSBW, int USBW);
00544   void dumpFinalSIDStats(int cindex, int findex,char *fileName, int DSBW);
00545   void dumpFinalDSSIDS(char *fileName, int DSBW);
00546   void dump802_16QueueStats(char *fileName, int channelBW);
00547   void dump802_16UtilStats(char *fileName, int channelDSBW, int channelUSBW);
00548   
00549   /* Queue functions */
00550 
00551   //$A10
00552   void insert_pkt_at_Head(Packet*, int , int);
00553 
00554   int len_mgmtqueue();
00555 
00556   Packet* deque_pkt();
00557   int packetTrace(Packet *p, int direction);   
00558 
00559   //$A14
00560   void HandleOutData(Packet*, int, int);
00561 
00562   int down_idle(int, int, EventType, Packet*);
00563   int down_decision(int, int, EventType, Packet*); 
00564   int down_tosend(int, int, EventType, Packet*); 
00565   int down_waitformap(int, int, EventType, Packet*);
00566   int(Mac802_16BS::*DOWNswitch[DOWNSTATES])(int, int, EventType, Packet*) ;    
00567 
00568   void UpdateAllocationTable(int, int);
00569   void UpdateJitter(int, int);
00570   bool insert_pkt(Packet*,int, int);
00571   double timer_expiration(int, int, Packet*);
00572   Packet * deque_pkt(int, int);
00573   void insert_mgmtpkt(Packet*, int, int);
00574   void insert_sndlist(double, int, int);
00575   void BsSndTimerHandler(Event * e);
00576   //end $A14
00577   //$A15
00578   void alloc_ul_bw(double, double,u_int32_t);
00579   void alloc_dl_bw(double, double,u_int32_t);
00580   void checkDeadline(double, double, u_int32_t&);
00581   void checkMinimumBW(u_int32_t&, priority_array_p&, int&);
00582   void MakeAllocation(jptr, int, mapptr,char, int);
00583 
00584   int CanBeSent(aptr&, Packet*);
00585 
00586 };
00587 
00588 /*========================End BS class declaration====================*/
00589 
00590 /*========================SS class declaration==========================*/
00591 
00592 /*************************************************************************
00593 
00594 *************************************************************************/
00596 class Mac802_16SS : public Mac802_16 
00597 { 
00598   friend class SSRng802_16Timer;
00599   friend class SSServiceFlowSendTimer;
00600   friend class SSServiceFlowRequestTimer;
00601   
00602  public:
00603   Mac802_16SS();
00604   ~Mac802_16SS(){};
00605       
00606  protected:
00607   int  command(int argc, const char*const* argv);
00608  
00609  private:
00610   
00611   RNG* rng_; /* Object for generating random numbers */
00612     
00613   /* Timer variables */
00614   SSRng802_16Timer mhSSRng_;
00615   SSServiceFlowSendTimer mhSSSend_;
00616   SSServiceFlowRequestTimer mhReq_; 
00617   
00618   Packet* map_;            /* The latest MAP received */
00619                           
00620   /* Debug variables */
00621   char debug_ss;
00622 
00623   u_int32_t ss_id; /* SS id assigned via tcl script */
00624   
00625   u_char my_lan;   /* my_lan stores the lan number which 
00626                       will be used as index on array bs_arr 
00627                       to obtain pointer to bs object */
00628   
00629   u_char SizeUpFlowTable;
00630   struct upstream_sflow UpFlowTable[MAX_NUM_UPFLOWS_PERSS];
00631   
00632   u_char SizeDownFlowTable;
00633   struct downstream_sflow DownFlowTable[MAX_NUM_DOWNFLOWS_PERSS];
00634   
00635   u_char default_upstream_index_;
00636   u_char default_dstream_index_;
00637 
00638   u_int16_t priority; /* Used for best-effort flows only*/
00639   double rng_freq;    /* frequency of RNG-REQ msgs*/
00640   int bs_addr;
00641   double map_acktime; /*The ack-time in last MAP*/
00642   u_int32_t total_num_frag;
00643   u_int32_t total_num_collisions;
00644   u_int32_t total_num_bkoff;
00645   
00646   u_int32_t total_collision_drops; /* Total number of packets dropped due 
00647                                       to transmission attempt exceeding 16 */
00648 
00649   u_int32_t total_queue_drops;     /* Total number of packets dropped due 
00650                                       to service-flow queue overflow */
00651   
00652   sptr SndList; /* Snd timer list header */
00653   rptr ReqList; /* Req timer list header */
00654   //$A7
00655   rptr tempReqList; 
00656     
00657   /* 
00658      Array of function pointers to 
00659      implement the state machines 
00660   */
00661   int(Mac802_16SS::*UGSswitch[UGSSTATES])(char, EventType, Packet*) ;    
00662   int(Mac802_16SS::*RTPOLLswitch[RTPOLLSTATES])(char, EventType, Packet*);
00663   //$A16
00664   int(Mac802_16SS::*ERTPOLLswitch[ERTPOLLSTATES])(char, EventType, Packet*);
00665   //$A13
00666   int(Mac802_16SS::*NRTPOLLswitch[NRTPOLLSTATES])(char, EventType, Packet*);   
00667   int(Mac802_16SS::*BEFFORTswitch[BEFFORTSTATES])(char, EventType,Packet*);
00668   
00669   Event rintr; /* Event to be consumed when SSMgmt timer expires..*/
00670   
00671   double last_dmptime;
00672   
00673   /* Methods */  
00674   inline void BsMapHandler(Event * e) {}
00675   inline void BsSyncHandler(Event * e) {}
00676   inline void BsUcdHandler(Event * e) {}
00677   inline void BsRngHandler(Event * e) {}
00678   inline  void BsSendHandler(Event *e) {};
00679 
00680   //#ifdef RATE_CONTROL //-----------------------------------
00681   inline void BsTokenHandler(Event *e) {};
00682   //#endif //------------------------------------------------
00683   
00684   void SSRngHandler(Event * e);
00685   void SSSndTimerHandler(Event * e);
00686   void SSReqTimerHandler(Event * e);
00687   void sendUp(Packet* p);
00688   void sendDown(Packet* p);
00689   void Initialize_entry(char direction, char index);
00690   void HandleMap(Packet*);
00691   void HandleOutData(Packet*, char);
00692   void SendData(Packet*, char);
00693 //$A7
00694 //  void SendReq(char, Packet*);
00695   int  SendReq(char, Packet*);
00696   void decide_frag(Packet*,char);
00697   void send_frag_data(Packet*,char);
00698   void fill_extended_header(int, Packet*, char);
00699   void send_concat(Packet*, char);
00700   void RecvFrame(Packet*,int);
00701   void handle_indata(Packet*,char);
00702   void handle_inmgmt(Packet*,char);
00703   void SetDefaultFlow();
00704   void PhUnsupress(Packet*, char);
00705   void ApplyPhs(Packet*, char);
00706 
00707 
00708   void print_alloclist(char);
00709   
00710   //$A4
00711   void print_short_map_list(Packet* Pkt);
00712   void print_classifiers();
00713   void dump_stats();
00714   char classify(Packet*,char);
00715   int check_concat_req(char);
00716   int check_frag_req(u_int32_t,char);
00717   int fill_piggyback_req(char);
00718   void MarkUsedContentionSlots(int,char);
00719   void turn_off_contention(char);
00720   //void back_off(char,Packet*);
00721   int back_off(char,Packet*);
00722   void insert_sndlist(double,char);
00723   void insert_reqlist(double,char);
00724   void refresh_reqlist(char);
00725 
00726   //$A7
00727   void reinsert_reqlist(char); 
00728 
00729   void insert_pkt(Packet*,char);
00730   void UpdateAllocationTable(char);
00731   void HandleOtherMgmt(Packet*);
00732   /* $A14 - moved to Mac802_16 class, since it is also used by the bs
00733     void insert_alloclist(char,u_int16_t,double,double,u_int16_t,u_int32_t); */
00734   void print_ssalloclist();
00735   void HandleOutMgmt(Packet*,char);
00736   void FillPiggyReq(char, Packet*);
00737 //  $A7
00738 //  void FillPiggyExtHdr(char,Packet*, int);
00739   int FillPiggyExtHdr(char,Packet*, int);
00740   void UpdateJitter(char);
00741 
00742   /*$A14 - the method was moved to Mac802_16 class
00743     int CanBeSent(char,Packet*);*/
00744 
00745   int CanBeSent(aptr&, Packet*, char);
00746 
00747   int CanUnicastReqBeSent(char);
00748   int CanContentionReqBeSent(char);
00749   int DataGrantPending(char);   
00750   int MapSentAfterReq(char);
00751   int NumContentionSlots(char);
00752 
00753   void USRateMeasure(char, Packet*);
00754   void us_getupdatedtokens(char);
00755 
00756   /*$A14 - moved do Mac802_16 class
00757     int len_queue(char);*/
00758   
00759   //$A2
00760   int look_at_queue(char);
00761   int filterACKPackets(Packet *pkt, char tbindex);
00762   int packetMatch(Packet *pkt1, Packet *pkt2);
00763   
00764   double find_contention_slot(char,u_int32_t);
00765   double timer_expiration(char,Packet*,int);
00766   Packet * deque_pkt(char);
00767   Packet* pkt_lookup(char tbindex,int i);
00768   
00769   //Statistics
00770   void dumpBWSS(char *fileName);
00771   void dumpUGSJITTER(char,char *filename);
00772   void dumpFinalSSStats(char *fileName);
00773   void dump802_16QueueStats(char *fileName, int channelBW);
00774   void dump802_16UtilStats(char *fileName, int channelDSBW, int channelUSBW);   
00775 //$A7
00776   int reqFlag, reqFlagCounter;
00777   int packetTrace(Packet *p, int direction);   
00778   //$A11
00779   int timingsTrace(Packet *p, int id);
00780 
00781 
00782   int ugs_idle(char, EventType, Packet*);
00783   int ugs_decision(char, EventType, Packet*); 
00784   int ugs_tosend(char, EventType, Packet*); 
00785   int ugs_waitformap(char, EventType, Packet*);
00786   int rtpoll_idle(char, EventType, Packet*);
00787   int rtpoll_decision(char, EventType, Packet*);
00788   int rtpoll_tosend(char, EventType, Packet*);
00789   int rtpoll_waitformap(char, EventType, Packet*);
00790   int rtpoll_tosendreq(char, EventType, Packet*);
00791   //$A19 int rtpoll_reqsent(char, EventType, Packet*);
00792 
00793   //A16
00794   int ertpoll_idle(char, EventType, Packet*);
00795   int ertpoll_decision(char, EventType, Packet*);
00796   int ertpoll_tosend(char, EventType, Packet*);
00797   int ertpoll_waitformap(char, EventType, Packet*);
00798   int ertpoll_tosendreq(char, EventType, Packet*);
00799   //$A13
00800   int nrtpoll_idle(char, EventType, Packet*);
00801   int nrtpoll_decision(char, EventType, Packet*);
00802   int nrtpoll_tosend(char, EventType, Packet*);
00803   int nrtpoll_waitformap(char, EventType, Packet*);
00804   int nrtpoll_tosendreq(char, EventType, Packet*);
00805   int nrtpoll_reqsent(char, EventType, Packet*);
00806   int nrtpoll_contention(char, EventType, Packet*);
00807   int beffort_idle(char, EventType, Packet*);
00808   int beffort_decision(char, EventType, Packet*);
00809   int beffort_tosend(char, EventType, Packet*);
00810   int beffort_waitformap(char, EventType, Packet*);
00811   int beffort_tosendreq(char, EventType, Packet*);
00812   int beffort_reqsent(char, EventType, Packet*);
00813   int beffort_contention(char, EventType, Packet*);
00814   //$A7
00815   int beffort_ratecheck(char, EventType, Packet*);
00816 
00817   //$A16
00818   void FillErtPSPiggyReq(char, Packet *);
00819   int  SendErtPSReq(char, Packet*);
00820 
00821 };
00822 
00823 /*======================== End SS class declaration========================*/
00824 
00825 #endif /* __mac_802_16_h__ */

Generated on Fri Feb 8 16:42:33 2008 for WiMAX by  doxygen 1.5.1