00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00034 #ifndef ns_hdr_mac802_16_h
00035 #define ns_hdr_mac802_16_h
00036
00037 #define EPSILON 0.0000000000005
00038
00039
00040
00041 #include <arp.h>
00042 #include <connector.h>
00043 #include <delay.h>
00044 #include <ll.h>
00045 #include <mac.h>
00046 #include "mac-802_16-timers.h"
00047 #include <marshall.h>
00048 #include <packet.h>
00049 #include <queue.h>
00050 #include <random.h>
00051
00052
00053
00054
00055
00056
00057 enum SchedType
00058 {
00059 UGS = 0x0000,
00060 RT_POLL = 0x0001,
00061 ERT_POLL = 0x0002,
00062 NRT_POLL = 0x0003,
00063 BEST_EFFORT = 0x0004
00064 };
00065
00066 enum PhsType
00067 {
00068 SUPRESS_ALL = 0x0000,
00069 SUPRESS_TCPIP = 0x0001,
00070 SUPRESS_UDPIP = 0x0002,
00071 SUPRESS_MAC = 0x0003,
00072 NO_SUPRESSION = 0x0004
00073 };
00074
00075 enum EventType
00076 {
00077 PKT_ARRIVAL = 0x0000,
00078 MAP_ARRIVAL = 0x0001,
00079 SEND_TIMER = 0x0002,
00080 REQ_TIMER = 0x0003,
00081 SEND_PKT = 0x0004,
00082 SEND_UREQ = 0x0006,
00083 CONTENTION_ON = 0x0007,
00084 CONTENTION_SLOTS = 0x0008,
00085 CONTENTION_BKOFF = 0x0009,
00086 UNLOCK_QUEUE = 0x00010,
00087
00088 PIGGYBACK_REQ = 0x00011
00089
00090 };
00091
00092 #define UPSTREAM 0
00093 #define DOWNSTREAM 1
00094 #define OFF 0
00095 #define ON 1
00096 #define BROADCAST_SID 1
00097
00098 #define DATA_PKT 0
00099 #define MGMT_PKT 1
00100
00101
00102 #define SUPRESS_ALL_SIZE 100
00103 #define SUPRESS_TCPIP_SIZE 40
00104 #define SUPRESS_UDPIP_SIZE 28
00105 #define SUPRESS_MAC_SIZE 28
00106
00107 #define DATA_GRANT 0
00108 #define UREQ_GRANT 1
00109 #define CONTENTION_GRANT 2
00110 #define SM_GRANT 3
00111 #define ETHER_HDR_LEN ((ETHER_ADDR_LEN << 1) + ETHER_TYPE_LEN)
00112 #define MAC802_16_HDR_LEN 6
00113 #define MAX_NUM_IE 240
00114 #define MAX_GRANT 255
00115
00116
00117 #define MAX_RETRY 10
00118 #define SIZE_MGMT_HDR 24
00119 #define SIZE_MAP_HDR 4
00120 #define MANAGEMENT_MSG_PAYLOAD_SIZE 5
00121 #define NUM_EXTENDED_HDR_ELEMENTS 2
00122 #define MAX_NUM_DOWNFLOWS_PERSS 10
00123
00124
00125 #define MAX_NUM_UPFLOWS_PERSS 10
00126
00127 #define NUM_802_16_LANS 5
00128 #define MAX_NUM_SS_NODES 500
00129 #define MAX_NUM_RETRIES 15
00130 #define FRAG_ENABLE_BIT 8
00131 #define CONCAT_ENABLE_BIT 7
00132 #define FRAG_ON_BIT 6
00133 #define CONCAT_ON_BIT 5
00134 #define PIGGY_ENABLE_BIT 4
00135 #define NO_PIGGY_BIT 3
00136 #define PIGGY_NOT_SEND 2
00137 #define CONCAT_THRESHHOLD 1
00138 #define QUEUE_THRESHOLD 25
00139 #define UGSSTATES 4
00140 #define RTPOLLSTATES 6
00141
00142 #define ERTPOLLSTATES 5
00143
00144 #define NRTPOLLSTATES 7
00145
00146
00147 #define BEFFORTSTATES 8
00148
00149 #define DOWNSTATES 4
00150
00151 #define UGS_IDLE 0
00152 #define UGS_DECISION 1
00153 #define UGS_TOSEND 2
00154 #define UGS_WAITFORMAP 3
00155 #define RTPOLL_IDLE 0
00156 #define RTPOLL_DECISION 1
00157 #define RTPOLL_TOSEND 2
00158 #define RTPOLL_WAITFORMAP 3
00159 #define RTPOLL_TOSENDREQ 4
00160 #define RTPOLL_REQSENT 5
00161
00162 #define ERTPOLL_IDLE 0
00163 #define ERTPOLL_DECISION 1
00164 #define ERTPOLL_TOSEND 2
00165 #define ERTPOLL_WAITFORMAP 3
00166 #define ERTPOLL_TOSENDREQ 4
00167
00168 #define NRTPOLL_IDLE 0
00169 #define NRTPOLL_DECISION 1
00170 #define NRTPOLL_TOSEND 2
00171 #define NRTPOLL_WAITFORMAP 3
00172 #define NRTPOLL_TOSENDREQ 4
00173 #define NRTPOLL_REQSENT 5
00174 #define NRTPOLL_CONTENTION 6
00175
00176 #define BEFFORT_IDLE 0
00177 #define BEFFORT_DECISION 1
00178 #define BEFFORT_TOSEND 2
00179 #define BEFFORT_WAITFORMAP 3
00180 #define BEFFORT_TOSENDREQ 4
00181 #define BEFFORT_REQSENT 5
00182 #define BEFFORT_CONTENTION 6
00183
00184 #define BEFFORT_RATECHECK 7
00185
00186
00187 #define DOWN_IDLE 0
00188 #define DOWN_DECISION 1
00189 #define DOWN_TOSEND 2
00190 #define DOWN_WAITFORMAP 3
00191
00192
00193 #define T16_TIMER 1 //in seconds
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00206 struct mac802_16_frame_hdr
00207 {
00208 u_char fc_type : 2;
00209 u_char fc_parm : 5;
00210 u_char ehdr_on : 1;
00211
00212
00213 u_int16_t mac_param;
00214 u_int16_t len;
00215 };
00216
00217
00218
00219
00221 struct mac802_16_extended_header_element
00222 {
00223 u_char eh_type : 4;
00224 u_char eh_len : 4;
00225 u_int16_t eh_data[6];
00226 };
00227
00228
00229
00230
00231
00232
00233
00234
00235
00237 struct hdr_mac802_16
00238 {
00239 struct mac802_16_frame_hdr dshdr_;
00240 int dt_conv_overhead_;
00241
00242
00243
00244 static int offset_;
00245
00246 inline static int& offset()
00247 {
00248 return offset_;
00249 }
00250
00251 inline static hdr_mac802_16* access(const Packet * p)
00252 {
00253 return (hdr_mac802_16*) p->access(offset_);
00254 }
00255
00256
00257 struct mac802_16_frame_hdr& dshdr()
00258 {
00259 return dshdr_;
00260 }
00261
00262 int& dt_conv_overhead()
00263 {
00264 return dt_conv_overhead_;
00265 }
00266 };
00267
00268
00269
00270
00272 struct hdr_mac802_16extd
00273 {
00274 struct mac802_16_extended_header_element exthdr_[NUM_EXTENDED_HDR_ELEMENTS];
00275
00276 int num_hdr;
00277 static int offset_;
00278
00279 inline static int& offset()
00280 {
00281 return offset_;
00282 }
00283
00284 inline static hdr_mac802_16extd* access(const Packet * p)
00285 {
00286 return (hdr_mac802_16extd*) p->access(offset_);
00287 }
00288
00289
00290 inline int& num_hdr_()
00291 {
00292 return num_hdr;
00293 }
00294
00295 struct mac802_16_extended_header_element* exthdr()
00296 {
00297 return exthdr_;
00298 }
00299 };
00300
00301
00302
00303
00305 struct hdr_mac802_16mgmt
00306 {
00307 int dstaddr;
00308 int srcaddr;
00309 u_char msg_payload_[MANAGEMENT_MSG_PAYLOAD_SIZE];
00310
00311
00312
00313
00314
00315 u_char type;
00316
00317 static int offset_;
00318
00319 inline static int& offset()
00320 {
00321 return offset_;
00322 }
00323
00324 inline static hdr_mac802_16mgmt* access(const Packet * p)
00325 {
00326 return (hdr_mac802_16mgmt*) p->access(offset_);
00327 }
00328
00329
00330 inline int& dstaddr_()
00331 {
00332 return dstaddr;
00333 }
00334
00335 inline int& srcaddr_()
00336 {
00337 return srcaddr;
00338 }
00339
00340 inline u_char& type_()
00341 {
00342 return type;
00343 }
00344 };
00345
00346
00347
00348
00349
00354 struct hdr_mac802_16map
00355 {
00356 double allocstarttime;
00357 double allocendtime;
00358 double acktime;
00359 u_char numIE;
00360 u_char bkoff_start;
00361 u_char bkoff_end;
00362
00363 static int offset_;
00364
00365 inline static int& offset()
00366 {
00367 return offset_;
00368 }
00369
00370 inline static hdr_mac802_16map* access(const Packet * p)
00371 {
00372 return (hdr_mac802_16map*) p->access(offset_);
00373 }
00374
00375
00376
00377 inline double& allocstarttime_()
00378 {
00379 return allocstarttime;
00380 }
00381
00382 inline double& allocendtime_()
00383 {
00384 return allocendtime;
00385 }
00386
00387 inline double& acktime_()
00388 {
00389 return acktime;
00390 }
00391
00392 inline u_char& numIE_()
00393 {
00394 return numIE;
00395 }
00396
00397 inline u_char& bkoff_start_()
00398 {
00399 return bkoff_start;
00400 }
00401
00402 inline u_char& bkoff_end_()
00403 {
00404 return bkoff_end;
00405 }
00406 };
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417 typedef struct pnode * plist;
00418
00419 struct pnode
00420 {
00421 Packet * pkt;
00422 double enq_time;
00423 plist next;
00424 };
00425
00426
00427
00428
00429
00430
00431
00434 struct flow_classifier
00435 {
00436 int32_t src_ip;
00437 int32_t dst_ip;
00438 packet_t pkt_type;
00439 };
00440
00441
00442
00443
00444 typedef struct allocation_time * aptr;
00445
00446 struct allocation_time
00447 {
00448 double start_time;
00449 double end_time;
00450 u_int32_t num_slots;
00451 aptr next;
00452 u_char type;
00453 u_char used;
00454
00455 };
00456
00457
00458
00459
00460
00461
00463 struct downstream_flow_record
00464 {
00465 struct flow_classifier classifier;
00466
00467
00468 SchedType sched_type;
00469
00470 plist packet_list;
00471
00472
00473 u_int16_t max_qsize;
00474
00475
00476 u_char state;
00477
00478 Packet* pkt;
00479
00480 u_char pending;
00481
00482 struct allocation_time* alloc_list;
00483
00484 double ugsjitter;
00485
00486 int jitterSamples;
00487 double last_granttime;
00488
00489
00490
00491 double nominal_alloctime;
00492 double last_jittercaltime;
00493
00494 double ginterval;
00495
00496 u_int16_t gsize;
00497
00498
00499 double latency;
00500
00501 u_int32_t min_bw;
00502
00503
00504
00505
00506 u_int16_t flow_id;
00507 PhsType PHS_profile;
00508
00509
00510 PacketQueue *tokenq_;
00511
00512
00513 double tokens_;
00514 double rate_;
00515 int bucket_;
00516 int tokenqlen_;
00517 double lastupdatetime_;
00518 int init_;
00519 Event intr;
00520 char ratecontrol;
00521
00522
00523
00524 double util_total_bytes_DS;
00525 int util_total_pkts_DS;
00526 int total_pkts_dropped;
00527 int dropped_tokenq;
00528
00529 double dsq_delay;
00530 int num_qsamples;
00531 int dropped_dsq;
00532 };
00533
00534
00535
00536
00538 struct upstream_flow_record
00539 {
00540 struct flow_classifier classifier;
00541 SchedType sched_type;
00542
00543 PhsType PHS_profile;
00544
00545 double ginterval;
00546
00547
00548 double latency;
00549
00550 u_int32_t min_bw;
00551
00552 u_int16_t flow_id;
00553 u_int16_t gsize;
00554 u_char flag;
00555 };
00556
00557
00558
00559
00560
00563 struct upstream_channel
00564 {
00565 double data_rate;
00566 double prop_delay;
00567 u_int32_t max_burst_size;
00568 u_int32_t overhead_bytes;
00569 u_char physlots_p_minislot;
00570 };
00571
00572
00573
00574
00575 struct downstream_channel
00576 {
00577 double data_rate;
00578 double prop_delay;
00579 u_int32_t overhead_bytes;
00580 };
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00595 struct up_flow_record
00596 {
00597 struct flow_classifier classifier;
00598 Packet* frag_pkt;
00599 SchedType sched_type;
00600 PhsType PHS_profile;
00601
00602 double ginterval;
00603
00604 u_int32_t frag_data;
00605 u_int16_t flow_id;
00606 u_int16_t gsize;
00607 u_int16_t seq_num;
00608 u_char flag;
00609
00610
00611 double latency;
00612 u_int32_t min_bw;
00613 double last_granttime;
00614 u_int16_t backlogged;
00615 int16_t granted_bw;
00616 };
00617
00618
00619
00620
00621 struct ss_record
00622 {
00623 struct downstream_flow_record d_rec[MAX_NUM_DOWNFLOWS_PERSS];
00624 struct up_flow_record u_rec[MAX_NUM_UPFLOWS_PERSS];
00625
00626 int ss_macaddr;
00627 u_int16_t priority;
00628
00629 u_char SizeDnFlTable;
00630 u_char SizeUpFlTable;
00631 u_char default_upstream_index_;
00632 u_char default_downstream_index_;
00633 };
00634
00635
00636
00637
00638
00640 struct mgmt_conf_param
00641 {
00642 double sync_msg_interval;
00643 double rng_msg_interval;
00644 double ucd_msg_interval;
00645 };
00646
00647
00648
00649
00650 struct map_conf_param
00651 {
00652 double time_covered;
00653
00654
00655
00656 double map_interval;
00657
00658 u_int32_t num_contention_slots;
00659 u_int32_t num_sm_slots;
00660
00661
00662
00663
00664
00665
00666 u_char bkoff_start;
00667
00668 u_char bkoff_end;
00669
00670 };
00671
00672
00673
00674
00676 struct bs_conf_param
00677 {
00678 struct mgmt_conf_param mgtparam;
00679 struct map_conf_param mapparam;
00680 };
00681
00682
00683
00684
00686 struct bs_statistics
00687 {
00688 double avg_interdpr_map;
00689 u_int32_t avg_datagrants;
00690 u_int32_t num_req;
00691 u_int32_t avg_contentionslots;
00692 u_int32_t data_sent;
00693 u_int32_t fragmented_count;
00694 u_int32_t concatenation_count;
00695 u_char num_IE;
00696 u_int32_t num_creq;
00697 u_int32_t num_piggyreq;
00698 u_int32_t num_creqgrant;
00699 u_int32_t num_creqdenied;
00700 u_int32_t total_num_cslots;
00701
00702 u_int32_t total_num_mgmtslots;
00703
00704 };
00705
00706
00707
00708
00710 typedef struct job* jptr;
00711
00712 struct job
00713 {
00714 double release_time;
00715 double period;
00716 double deadline;
00717 u_int32_t mini_slots;
00718 jptr next;
00719 u_int16_t flow_id;
00720 SchedType sclass;
00721 u_char type;
00722 u_char flag;
00723 u_char retry_count;
00724 double ugsjitter;
00725
00726
00727 int jitterSamples;
00728 double last_jittercaltime;
00729 };
00730
00731
00732
00733
00734 typedef struct map_list * mapptr;
00735
00736 struct map_list
00737 {
00738 double alloc_stime;
00739 double alloc_etime;
00740 double release_time;
00741 double deadline;
00742 u_int32_t nslots;
00743 mapptr next;
00744 u_int16_t flow_id;
00745 u_int16_t flag;
00746
00747 };
00748
00749
00750
00751
00752
00754 typedef struct token_timer_list* tkptr;
00755
00756 struct token_timer_list
00757 {
00758 double expiration_time;
00759 tkptr next;
00760 int cindex;
00761
00762
00763 int findex;
00764
00765 };
00766
00767
00768
00769
00771 typedef struct bsqnode * qlist;
00772
00773 struct bsqnode
00774 {
00775 Packet *pkt;
00776 double enq_time;
00777 int cindex;
00778 int findex;
00779 qlist next;
00780 };
00781
00782
00783
00784
00785
00786 typedef struct bs_snd_timer_list* bs_sptr;
00787
00788 struct bs_snd_timer_list
00789 {
00790 double expiration_time;
00791 bs_sptr next;
00792 int cindex;
00793
00794 int findex;
00795 };
00796
00797
00798
00799
00800
00803 typedef struct active_flows* acflows_ptr;
00804
00805 struct active_flows
00806 {
00807 acflows_ptr next;
00808 u_int16_t flow_id;
00809 u_int16_t backlogged_tmp;
00810 int16_t granted_bw_tmp;
00811 };
00812
00813
00814
00815
00816
00819 struct priority_array
00820 {
00821 int priority;
00822 jptr job_pointer;
00823 };
00824
00825 typedef struct priority_array* priority_array_p;
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835 typedef struct snd_timer_list* sptr;
00836
00837 struct snd_timer_list
00838 {
00839 double expiration_time;
00840 sptr next;
00841 u_char tindex;
00842
00843 };
00844
00845
00846
00847
00848 typedef struct req_timer_list* rptr;
00849
00850 struct req_timer_list
00851 {
00852 double expiration_time;
00853 rptr next;
00854 u_char rindex;
00855
00856 };
00857
00858
00859
00860
00861 struct upstream_sflow
00862 {
00863 struct upstream_flow_record upstream_record;
00864 struct allocation_time* alloc_list;
00865
00866 plist packet_list;
00867 u_int16_t max_qsize;
00868
00869 Packet* pkt;
00870 Packet* frag_pkt;
00871
00872 char debug;
00873
00874 double map_acktime;
00875 double req_time;
00876
00877
00878 double avg_queuing_delay;
00879
00880 u_int32_t queuing_samples;
00881
00882
00883 double avg_req_stime;
00884
00885
00886 double enque_time;
00887
00888
00889 u_int32_t num_delay_samples;
00890
00891
00892 u_int32_t curr_gsize;
00893
00894
00895 u_int32_t num_pkt_snt;
00896
00897
00898 u_int32_t drop_count;
00899
00900 u_int32_t seq_num;
00901 u_int32_t frag_data;
00902 double last_mfrtime;
00903 u_int32_t avg_pkts;
00904
00905 u_int32_t avg_bytes;
00906 u_int32_t num_bytes;
00907 u_int32_t num_pkts;
00908
00909
00910 u_int32_t SID_num_sent_bytes;
00911 u_int32_t SID_num_sent_pkts;
00912
00913 u_int32_t avg_slotspermap;
00914
00915
00916 u_int32_t totalACKs;
00917 u_int32_t totalACKsFiltered;
00918
00919 u_int32_t total_piggyreq;
00920 u_int32_t total_creq;
00921
00922 u_int32_t total_fcoll;
00923 u_int32_t avg_fcont;
00924
00925 u_int32_t fcont_count;
00926
00927 u_int32_t total_collision_drops;
00928
00929 u_int32_t total_queue_drops;
00930
00931
00932 int bs_addr;
00933 u_int16_t max_concat_threshhold;
00934
00935 u_char state;
00936
00937 u_int32_t bk_offwin;
00938 u_int32_t bk_offcounter;
00939 u_int32_t bk_offend;
00940 u_int32_t bk_offstart;
00941 u_char num_retries;
00942 u_char max_retries;
00943 u_char contention_on;
00944
00945
00946
00947 u_char pending;
00948
00949 Event intr;
00950 Event rintr;
00951
00952 double ugsjitter;
00953
00954
00955 int jitterSamples;
00956 double last_granttime;
00957
00958
00959
00960 double nominal_alloctime;
00961 double last_jittercaltime;
00962
00963
00964 double acceptance_rate;
00965 double prev_acceptance_rate;
00966 float wt_factor;
00967 u_int32_t num_slots_req;
00968 double tokens_;
00969 double rate_;
00970 int bucket_;
00971 double lastupdatetime_;
00972 int init_;
00973 char ratecontrol;
00974
00975
00976 int totalPacketsInConcatFrames;
00977 int totalConcatFrames;
00978
00979
00980 int not_requested_pkts;
00981
00982
00983 u_int16_t aggreqinterval;
00984 u_int16_t req_counter;
00985
00986
00987 };
00988
00989
00990
00991
00992
00995 struct downstream_sflow
00996 {
00997 struct downstream_flow_record downstream_record;
00998
00999 };
01000
01001
01002
01003
01004
01005 #endif