patch-wimax-prerelease-092206
上传用户:hzie11
上传日期:2013-10-07
资源大小:1487k
文件大小:477k
- diff -Naur ns-2.29-org/common/packet.h ns-2.29/common/packet.h
- --- ns-2.29-org/common/packet.h 2006-09-22 11:53:10.000000000 -0400
- +++ ns-2.29/common/packet.h 2006-09-22 17:27:47.000000000 -0400
- @@ -167,6 +167,9 @@
- // HDLC packet
- PT_HDLC,
-
- + // WIMAX inter-BS packets
- + PT_WIMAXBS,
- +
- // insert new packet types here
- PT_NTYPE // This MUST be the LAST one
- };
- @@ -263,6 +266,9 @@
- // XCP
- name_[PT_XCP]="xcp";
-
- + // WIMAX
- + name_[PT_WIMAXBS]="wimaxCtrl";
- +
- name_[PT_NTYPE]= "undefined";
- }
- const char* name(packet_t p) const {
- diff -Naur ns-2.29-org/mac/mac-stats.h ns-2.29/mac/mac-stats.h
- --- ns-2.29-org/mac/mac-stats.h 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/mac/mac-stats.h 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,273 @@
- +/* This software was developed at the National Institute of Standards and
- + * Technology by employees of the Federal Government in the course of
- + * their official duties. Pursuant to title 17 Section 105 of the United
- + * States Code this software is not subject to copyright protection and
- + * is in the public domain.
- + * NIST assumes no responsibility whatsoever for its use by other parties,
- + * and makes no guarantees, expressed or implied, about its quality,
- + * reliability, or any other characteristic.
- + * <BR>
- + * We would appreciate acknowledgement if the software is used.
- + * <BR>
- + * NIST ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND
- + * DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING
- + * FROM THE USE OF THIS SOFTWARE.
- + * </PRE></P>
- + * @author woon
- + */
- +
- +#ifndef mac_stats_h
- +#define mac_stats_h
- +
- +/** Action to execute on the threshold */
- +enum threshold_action_t {
- + NO_ACTION_TH,
- + INIT_ACTION_TH,
- + ROLLBACK_ACTION_TH,
- + EXEC_ACTION_TH
- +};
- +
- +/**
- + * NIST: Stats Watch
- + * Used to maintain statistics of a particular parameter
- + *
- + * Positive gradient means that when the value measured increases, it will trigger INIT_ACTION_TH
- + * A positive gradient is used for measurements such as packet loss, where as negative gradient
- + * is used for RSSI.
- + */
- +class StatWatch : public TimerHandler {
- +public:
- + StatWatch(double ti=1, double alpha=1, bool pos_gradient=true) : TimerHandler() {
- + timer_interval_ = ti;
- + alpha_ = alpha;
- + pos_gradient_ = pos_gradient;
- + current_ = 0;
- + average_ = 0;
- + instant_ = 0;
- + total_ = 0;
- + sample_number_ = 0;
- + th_set_ = false;
- + init_sent_ = false;
- + init_th_ = 0;
- + rollback_th_ = 0;
- + exec_th_ = 0;
- + pending_action_ = NO_ACTION_TH;
- + delay_ = 0;
- + }
- + virtual void expire(Event*) { schedule_next(); }
- +
- + inline void reset() {
- + average_ = 0;
- + instant_ = 0;
- + total_ = 0;
- + sample_number_ = 0;
- + }
- +
- + inline void set_thresholds (double init_th, double rollback_th, double exec_th) {
- + assert ( (pos_gradient_ && rollback_th <= init_th && init_th <= exec_th)
- + || (!pos_gradient_ && rollback_th >= init_th && init_th >= exec_th));
- + init_th_ = init_th;
- + rollback_th_ = rollback_th;
- + exec_th_ = exec_th;
- + th_set_ = true;
- + }
- +
- + inline void set_timer_interval(double ti) { timer_interval_ = ti; }
- + inline void set_alpha(double a) { alpha_= a; }
- + inline void set_current(double c) { current_= c; }
- + inline void set_pos_gradient(bool b) { pos_gradient_ = b; }
- + inline void set_delay (double d) { delay_ = d; }
- + virtual threshold_action_t update(double new_val) {
- + old_average_ = average_;
- + average_ = alpha_*new_val + (1-alpha_)*average_;
- + total_ += new_val;
- + sample_number_++;
- + instant_ = new_val;
- +
- + //evaluate if threshold has been crossed
- + if (th_set_) {
- + if (pos_gradient_) {
- + //check if threshold is crossed
- + if (old_average_ > rollback_th_ && average_ <= rollback_th_ && init_sent_) {
- + pending_action_ = ROLLBACK_ACTION_TH;
- + ts_ = NOW+delay_;
- + } else if (old_average_ < exec_th_ && average_ >= exec_th_) {
- + pending_action_ = EXEC_ACTION_TH;
- + ts_ = NOW+delay_;
- + } else if (old_average_ < init_th_ && average_ >= init_th_) {
- + pending_action_ = INIT_ACTION_TH;
- + ts_ = NOW+delay_;
- + } else {
- + //check if threshold is canceled
- + if (pending_action_ == ROLLBACK_ACTION_TH && average_ > rollback_th_
- + || pending_action_ == EXEC_ACTION_TH && average_ < exec_th_
- + || pending_action_ == INIT_ACTION_TH && average_ < init_th_) {
- + pending_action_ = NO_ACTION_TH;
- + }
- + }
- + //check if action is still valid
- + if (pending_action_ != NO_ACTION_TH && NOW >= ts_) {
- + threshold_action_t tmp = pending_action_;
- + pending_action_ = NO_ACTION_TH;
- + return tmp;
- + }
- +
- + } else {
- + //check if threshold is crossed
- + if (old_average_ < rollback_th_ && average_ >= rollback_th_ && init_sent_) {
- + pending_action_ = ROLLBACK_ACTION_TH;
- + ts_ = NOW+delay_;
- + } else if (old_average_ > exec_th_ && average_ <= exec_th_) {
- + pending_action_ = EXEC_ACTION_TH;
- + ts_ = NOW+delay_;
- + } else if (old_average_ > init_th_ && average_ <= init_th_) {
- + pending_action_ = INIT_ACTION_TH;
- + ts_ = NOW+delay_;
- + } else {
- + //check if threshold is canceled
- + if (pending_action_ == ROLLBACK_ACTION_TH && average_ < rollback_th_
- + || pending_action_ == EXEC_ACTION_TH && average_ > exec_th_
- + || pending_action_ == INIT_ACTION_TH && average_ > init_th_) {
- + pending_action_ = NO_ACTION_TH;
- + }
- + }
- + //check if action is still valid
- + if (pending_action_ != NO_ACTION_TH && NOW >= ts_) {
- + threshold_action_t tmp = pending_action_;
- + pending_action_ = NO_ACTION_TH;
- + return tmp;
- + }
- + }
- + }
- + return NO_ACTION_TH;
- + }
- + inline void schedule_next() { resched(timer_interval_); }
- +
- + inline double current() { return current_; }
- + inline double total() { return total_; }
- + inline double sample_number() { return sample_number_; }
- + inline double average() { return average_; }
- + inline double old_average() { return old_average_; }
- + inline double instant() { return instant_; }
- + inline double simple_average() { return total_/sample_number_; }
- +
- +protected:
- + double timer_interval_;
- + double alpha_;
- + double current_;
- + double average_;
- + double old_average_;
- + double instant_;
- + double total_;
- + int sample_number_;
- + bool pos_gradient_;
- + double delay_;
- + threshold_action_t pending_action_;
- + double ts_;
- + bool th_set_;
- + bool init_sent_;
- + double init_th_;
- + double rollback_th_;
- + double exec_th_;
- +};
- +
- +/**
- + * Class to handle throughput measurements
- + */
- +class ThroughputWatch: public StatWatch {
- + public:
- + /**
- + * Constructor
- + */
- + ThroughputWatch() { }
- +
- + /**
- + * Virtual desctructor
- + */
- + virtual ~ThroughputWatch() {};
- +
- + inline void set_alpha(double a) { size_.set_alpha(a); time_.set_alpha(a); }
- + inline double get_timer_interval () { return 0.01; }
- +
- + threshold_action_t update(double size, double time) {
- + size_.update (size);
- + time_.update (time-time_.current());
- + time_.set_current (time);
- + old_average_ = average_;
- + average_ = size_.average()/time_.average();
- +
- + //evaluate if threshold has been crossed
- + if (th_set_) {
- + if (pos_gradient_) {
- + //check if threshold is crossed
- + if (old_average_ > rollback_th_ && average_ <= rollback_th_ && init_sent_) {
- + pending_action_ = ROLLBACK_ACTION_TH;
- + ts_ = NOW+delay_;
- + } else if (old_average_ < exec_th_ && average_ >= exec_th_) {
- + pending_action_ = EXEC_ACTION_TH;
- + ts_ = NOW+delay_;
- + } else if (old_average_ < init_th_ && average_ >= init_th_) {
- + pending_action_ = INIT_ACTION_TH;
- + ts_ = NOW+delay_;
- + } else {
- + //check if threshold is canceled
- + if (pending_action_ == ROLLBACK_ACTION_TH && average_ > rollback_th_
- + || pending_action_ == EXEC_ACTION_TH && average_ < exec_th_
- + || pending_action_ == INIT_ACTION_TH && average_ < init_th_) {
- + pending_action_ = NO_ACTION_TH;
- + }
- + }
- + //check if action is still valid
- + if (pending_action_ != NO_ACTION_TH && NOW >= ts_) {
- + threshold_action_t tmp = pending_action_;
- + pending_action_ = NO_ACTION_TH;
- + return tmp;
- + }
- +
- + } else {
- + //check if threshold is crossed
- + if (old_average_ < rollback_th_ && average_ >= rollback_th_ && init_sent_) {
- + pending_action_ = ROLLBACK_ACTION_TH;
- + ts_ = NOW+delay_;
- + } else if (old_average_ > exec_th_ && average_ <= exec_th_) {
- + pending_action_ = EXEC_ACTION_TH;
- + ts_ = NOW+delay_;
- + } else if (old_average_ > init_th_ && average_ <= init_th_) {
- + pending_action_ = INIT_ACTION_TH;
- + ts_ = NOW+delay_;
- + } else {
- + //check if threshold is canceled
- + if (pending_action_ == ROLLBACK_ACTION_TH && average_ < rollback_th_
- + || pending_action_ == EXEC_ACTION_TH && average_ > exec_th_
- + || pending_action_ == INIT_ACTION_TH && average_ > init_th_) {
- + pending_action_ = NO_ACTION_TH;
- + }
- + }
- + //check if action is still valid
- + if (pending_action_ != NO_ACTION_TH && NOW >= ts_) {
- + threshold_action_t tmp = pending_action_;
- + pending_action_ = NO_ACTION_TH;
- + printf ("Action triggered %dn", tmp);
- + return tmp;
- + }
- + }
- + }
- + return NO_ACTION_TH;
- + }
- +
- + protected:
- + /**
- + * Watch for packet size
- + */
- + StatWatch size_;
- +
- + /**
- + * Watch for inter arrival time
- + */
- + StatWatch time_;
- +
- +};
- +
- +
- +
- +#endif //mac_stats_h
- diff -Naur ns-2.29-org/Makefile.in ns-2.29/Makefile.in
- --- ns-2.29-org/Makefile.in 2006-09-22 11:53:09.000000000 -0400
- +++ ns-2.29/Makefile.in 2006-09-22 17:27:47.000000000 -0400
- @@ -70,6 +70,7 @@
- -I./diffusion3/lib/nr -I./diffusion3/ns
- -I./diffusion3/filter_core -I./asim/ -I./qs
- -I./diffserv -I./satellite
- + -I./wimax
- -I./wpan
-
-
- @@ -301,6 +302,37 @@
- wpan/p802_15_4nam.o wpan/p802_15_4phy.o
- wpan/p802_15_4sscs.o wpan/p802_15_4timer.o
- wpan/p802_15_4trace.o wpan/p802_15_4transac.o
- + wimax/ofdmphy.o
- + wimax/mac802_16pkt.o
- + wimax/serviceflowqos.o
- + wimax/serviceflow.o
- + wimax/serviceflowhandler.o
- + wimax/connection.o
- + wimax/connectionmanager.o
- + wimax/peernode.o
- + wimax/mac802_16.o
- + wimax/sduclassifier.o
- + wimax/destclassifier.o
- + wimax/mac802_16timer.o
- + wimax/neighborentry.o
- + wimax/neighbordb.o
- + wimax/scheduling/wimaxscheduler.o
- + wimax/scheduling/bsscheduler.o
- + wimax/scheduling/ssscheduler.o
- + wimax/scheduling/ulsubframetimer.o
- + wimax/scheduling/dlsubframetimer.o
- + wimax/scheduling/burst.o
- + wimax/scheduling/contentionslot.o
- + wimax/scheduling/contentionrequest.o
- + wimax/scheduling/contentiontimer.o
- + wimax/scheduling/dlburst.o
- + wimax/scheduling/ulburst.o
- + wimax/scheduling/framemap.o
- + wimax/scheduling/phypdu.o
- + wimax/scheduling/profile.o
- + wimax/scheduling/subframe.o
- + wimax/scheduling/scanningstation.o
- + wimax/scheduling/wimaxctrlagent.o
- @V_STLOBJ@
-
-
- @@ -456,6 +488,7 @@
- tcl/lib/ns-srcrt.tcl
- tcl/mcast/ns-lms.tcl
- tcl/lib/ns-qsnode.tcl
- + tcl/lib/ns-wimax.tcl
- @V_NS_TCL_LIB_STL@
-
- $(GEN_DIR)ns_tcl.cc: $(NS_TCL_LIB)
- diff -Naur ns-2.29-org/tcl/lib/ns-lib.tcl ns-2.29/tcl/lib/ns-lib.tcl
- --- ns-2.29-org/tcl/lib/ns-lib.tcl 2006-09-22 11:53:09.000000000 -0400
- +++ ns-2.29/tcl/lib/ns-lib.tcl 2006-09-22 17:27:47.000000000 -0400
- @@ -217,6 +217,9 @@
- #LMS
- source ../mcast/ns-lms.tcl
-
- +#WIMAX
- +source ns-wimax.tcl
- +
- # STL dependent modules get included
- # ONLY when STL is found
-
- diff -Naur ns-2.29-org/tcl/lib/ns-packet.tcl ns-2.29/tcl/lib/ns-packet.tcl
- --- ns-2.29-org/tcl/lib/ns-packet.tcl 2006-09-22 11:53:09.000000000 -0400
- +++ ns-2.29/tcl/lib/ns-packet.tcl 2006-09-22 17:27:47.000000000 -0400
- @@ -170,6 +170,8 @@
- Encap # common/encap.cc
- IPinIP # IP encapsulation
- HDLC # High Level Data Link Control
- +# WIMAX:
- + 802_16 # Mac IEEE 802.16
- } {
- add-packet-header $prot
- }
- diff -Naur ns-2.29-org/tcl/lib/ns-wimax.tcl ns-2.29/tcl/lib/ns-wimax.tcl
- --- ns-2.29-org/tcl/lib/ns-wimax.tcl 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/tcl/lib/ns-wimax.tcl 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,54 @@
- +# This class contains default value for tcl
- +
- +Phy/WirelessPhy/OFDM set g_ 0
- +
- +Mac/802_16 set queue_length_ 50 ;#maximum number of packets
- +
- +Mac/802_16 set frame_duration_ 0.004
- +Mac/802_16 set channel_ 0
- +Mac/802_16 set fbandwidth_ 5e+6
- +Mac/802_16 set rtg_ 10
- +Mac/802_16 set ttg_ 10
- +Mac/802_16 set dcd_interval_ 5 ;#max 10s
- +Mac/802_16 set ucd_interval_ 5 ;#max 10s
- +Mac/802_16 set init_rng_interval_ 1 ;#max 2s
- +Mac/802_16 set lost_dlmap_interval_ 0.6
- +Mac/802_16 set lost_ulmap_interval_ 0.6
- +Mac/802_16 set t1_timeout_ [expr 5* [Mac/802_16 set dcd_interval_]]
- +Mac/802_16 set t2_timeout_ [expr 5* [Mac/802_16 set init_rng_interval_]]
- +Mac/802_16 set t3_timeout_ 0.2
- +Mac/802_16 set t6_timeout_ 3
- +Mac/802_16 set t12_timeout_ [expr 5* [Mac/802_16 set ucd_interval_]]
- +Mac/802_16 set t16_timeout_ 3 ;#qos dependant
- +Mac/802_16 set t17_timeout_ 5
- +Mac/802_16 set t21_timeout_ 0.02 ;#max 10s. Use 20ms to replace preamble scanning
- +Mac/802_16 set contention_rng_retry_ 16
- +Mac/802_16 set invited_rng_retry_ 16 ;#16
- +Mac/802_16 set request_retry_ 2 ;#16
- +Mac/802_16 set reg_req_retry_ 3
- +Mac/802_16 set tproc_ 0.001
- +Mac/802_16 set dsx_req_retry_ 3
- +Mac/802_16 set dsx_rsp_retry_ 3
- +
- +Mac/802_16 set rng_backoff_start_ 2
- +Mac/802_16 set rng_backoff_stop_ 6
- +Mac/802_16 set bw_backoff_start_ 2
- +Mac/802_16 set bw_backoff_stop_ 6
- +
- +Mac/802_16 set scan_duration_ 50
- +Mac/802_16 set interleaving_interval_ 50
- +Mac/802_16 set scan_iteration_ 2
- +Mac/802_16 set t44_timeout_ 0.1
- +Mac/802_16 set max_dir_scan_time_ 0.2 ;#max scan for each neighbor BSs
- +Mac/802_16 set client_timeout_ 0.5
- +Mac/802_16 set nbr_adv_interval_ 0.5
- +Mac/802_16 set scan_req_retry_ 5
- +
- +Mac/802_16 set lgd_factor_ 1
- +Mac/802_16 set print_stats_ false ;#true to activate print of statistics
- +Mac/802_16 set rxp_avg_alpha_ 1
- +Mac/802_16 set delay_avg_alpha_ 1
- +Mac/802_16 set jitter_avg_alpha_ 1
- +Mac/802_16 set loss_avg_alpha_ 1
- +Mac/802_16 set throughput_avg_alpha_ 1
- +Mac/802_16 set throughput_delay_ 0.02
- diff -Naur ns-2.29-org/tcl/wimax/datarate/datarate802.16 ns-2.29/tcl/wimax/datarate/datarate802.16
- --- ns-2.29-org/tcl/wimax/datarate/datarate802.16 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/tcl/wimax/datarate/datarate802.16 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,41 @@
- +#!/bin/bash
- +
- +# Bash file to run datarate simulations for different modulation and cyclic prefix
- +# @author rouil
- +
- +if [ "$1" == "clean" ]; then
- + rm -r res_datarate
- +else
- + mkdir res_datarate
- + cd res_datarate
- + for modulation in "OFDM_BPSK_1_2" "OFDM_QPSK_1_2" "OFDM_QPSK_3_4" "OFDM_16QAM_1_2" "OFDM_16QAM_3_4" "OFDM_64QAM_2_3" "OFDM_64QAM_3_4" ; do
- +
- + if [ "$1" != "" ]; then
- + modulation=$1
- + fi
- + mkdir $modulation
- + cd $modulation
- +
- + for cp in "0" "0.03125" "0.0625" "0.125" "0.25"; do
- + mkdir cp_$cp
- + cd cp_$cp
- + echo -n "Running for modulation" $modulation " and CP="$cp
- + ns ../../../datarate.tcl $modulation $cp &> log.t
- +
- + DATARATE=`grep ^r out.res|grep "1 0 cbr"|awk 'BEGIN{first=-1; last=-1} {if (first==-1) {first=$2}; last=$2; i+=$6-0;} END {print (8*i/(last-first))}'`
- + echo " datarate = " $DATARATE
- + echo $modulation $cp $DATARATE >>../../result$modulation.dat
- + echo $modulation $cp $DATARATE >>../../result.dat
- + #rm out.res
- + #rm log.t
- + cd ..
- + done
- + cd ..
- + if [ "$1" != "" ]; then
- + break
- + fi
- + done
- + cd ..
- + gnuplot plot-datarate
- +fi
- +
- diff -Naur ns-2.29-org/tcl/wimax/datarate/datarate802_16.eps ns-2.29/tcl/wimax/datarate/datarate802_16.eps
- --- ns-2.29-org/tcl/wimax/datarate/datarate802_16.eps 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/tcl/wimax/datarate/datarate802_16.eps 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,606 @@
- +%!PS-Adobe-2.0 EPSF-2.0
- +%%Title: datarate802_16.eps
- +%%Creator: gnuplot 4.0 patchlevel 0
- +%%CreationDate: Wed Sep 20 12:10:17 2006
- +%%DocumentFonts: (atend)
- +%%BoundingBox: 50 50 410 302
- +%%Orientation: Portrait
- +%%EndComments
- +/gnudict 256 dict def
- +gnudict begin
- +/Color false def
- +/Solid false def
- +/gnulinewidth 5.000 def
- +/userlinewidth gnulinewidth def
- +/vshift -46 def
- +/dl {10.0 mul} def
- +/hpt_ 31.5 def
- +/vpt_ 31.5 def
- +/hpt hpt_ def
- +/vpt vpt_ def
- +/Rounded false def
- +/M {moveto} bind def
- +/L {lineto} bind def
- +/R {rmoveto} bind def
- +/V {rlineto} bind def
- +/N {newpath moveto} bind def
- +/C {setrgbcolor} bind def
- +/f {rlineto fill} bind def
- +/vpt2 vpt 2 mul def
- +/hpt2 hpt 2 mul def
- +/Lshow { currentpoint stroke M
- + 0 vshift R show } def
- +/Rshow { currentpoint stroke M
- + dup stringwidth pop neg vshift R show } def
- +/Cshow { currentpoint stroke M
- + dup stringwidth pop -2 div vshift R show } def
- +/UP { dup vpt_ mul /vpt exch def hpt_ mul /hpt exch def
- + /hpt2 hpt 2 mul def /vpt2 vpt 2 mul def } def
- +/DL { Color {setrgbcolor Solid {pop []} if 0 setdash }
- + {pop pop pop 0 setgray Solid {pop []} if 0 setdash} ifelse } def
- +/BL { stroke userlinewidth 2 mul setlinewidth
- + Rounded { 1 setlinejoin 1 setlinecap } if } def
- +/AL { stroke userlinewidth 2 div setlinewidth
- + Rounded { 1 setlinejoin 1 setlinecap } if } def
- +/UL { dup gnulinewidth mul /userlinewidth exch def
- + dup 1 lt {pop 1} if 10 mul /udl exch def } def
- +/PL { stroke userlinewidth setlinewidth
- + Rounded { 1 setlinejoin 1 setlinecap } if } def
- +/LTw { PL [] 1 setgray } def
- +/LTb { BL [] 0 0 0 DL } def
- +/LTa { AL [1 udl mul 2 udl mul] 0 setdash 0 0 0 setrgbcolor } def
- +/LT0 { PL [] 1 0 0 DL } def
- +/LT1 { PL [4 dl 2 dl] 0 1 0 DL } def
- +/LT2 { PL [2 dl 3 dl] 0 0 1 DL } def
- +/LT3 { PL [1 dl 1.5 dl] 1 0 1 DL } def
- +/LT4 { PL [5 dl 2 dl 1 dl 2 dl] 0 1 1 DL } def
- +/LT5 { PL [4 dl 3 dl 1 dl 3 dl] 1 1 0 DL } def
- +/LT6 { PL [2 dl 2 dl 2 dl 4 dl] 0 0 0 DL } def
- +/LT7 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 1 0.3 0 DL } def
- +/LT8 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 0.5 0.5 0.5 DL } def
- +/Pnt { stroke [] 0 setdash
- + gsave 1 setlinecap M 0 0 V stroke grestore } def
- +/Dia { stroke [] 0 setdash 2 copy vpt add M
- + hpt neg vpt neg V hpt vpt neg V
- + hpt vpt V hpt neg vpt V closepath stroke
- + Pnt } def
- +/Pls { stroke [] 0 setdash vpt sub M 0 vpt2 V
- + currentpoint stroke M
- + hpt neg vpt neg R hpt2 0 V stroke
- + } def
- +/Box { stroke [] 0 setdash 2 copy exch hpt sub exch vpt add M
- + 0 vpt2 neg V hpt2 0 V 0 vpt2 V
- + hpt2 neg 0 V closepath stroke
- + Pnt } def
- +/Crs { stroke [] 0 setdash exch hpt sub exch vpt add M
- + hpt2 vpt2 neg V currentpoint stroke M
- + hpt2 neg 0 R hpt2 vpt2 V stroke } def
- +/TriU { stroke [] 0 setdash 2 copy vpt 1.12 mul add M
- + hpt neg vpt -1.62 mul V
- + hpt 2 mul 0 V
- + hpt neg vpt 1.62 mul V closepath stroke
- + Pnt } def
- +/Star { 2 copy Pls Crs } def
- +/BoxF { stroke [] 0 setdash exch hpt sub exch vpt add M
- + 0 vpt2 neg V hpt2 0 V 0 vpt2 V
- + hpt2 neg 0 V closepath fill } def
- +/TriUF { stroke [] 0 setdash vpt 1.12 mul add M
- + hpt neg vpt -1.62 mul V
- + hpt 2 mul 0 V
- + hpt neg vpt 1.62 mul V closepath fill } def
- +/TriD { stroke [] 0 setdash 2 copy vpt 1.12 mul sub M
- + hpt neg vpt 1.62 mul V
- + hpt 2 mul 0 V
- + hpt neg vpt -1.62 mul V closepath stroke
- + Pnt } def
- +/TriDF { stroke [] 0 setdash vpt 1.12 mul sub M
- + hpt neg vpt 1.62 mul V
- + hpt 2 mul 0 V
- + hpt neg vpt -1.62 mul V closepath fill} def
- +/DiaF { stroke [] 0 setdash vpt add M
- + hpt neg vpt neg V hpt vpt neg V
- + hpt vpt V hpt neg vpt V closepath fill } def
- +/Pent { stroke [] 0 setdash 2 copy gsave
- + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat
- + closepath stroke grestore Pnt } def
- +/PentF { stroke [] 0 setdash gsave
- + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat
- + closepath fill grestore } def
- +/Circle { stroke [] 0 setdash 2 copy
- + hpt 0 360 arc stroke Pnt } def
- +/CircleF { stroke [] 0 setdash hpt 0 360 arc fill } def
- +/C0 { BL [] 0 setdash 2 copy moveto vpt 90 450 arc } bind def
- +/C1 { BL [] 0 setdash 2 copy moveto
- + 2 copy vpt 0 90 arc closepath fill
- + vpt 0 360 arc closepath } bind def
- +/C2 { BL [] 0 setdash 2 copy moveto
- + 2 copy vpt 90 180 arc closepath fill
- + vpt 0 360 arc closepath } bind def
- +/C3 { BL [] 0 setdash 2 copy moveto
- + 2 copy vpt 0 180 arc closepath fill
- + vpt 0 360 arc closepath } bind def
- +/C4 { BL [] 0 setdash 2 copy moveto
- + 2 copy vpt 180 270 arc closepath fill
- + vpt 0 360 arc closepath } bind def
- +/C5 { BL [] 0 setdash 2 copy moveto
- + 2 copy vpt 0 90 arc
- + 2 copy moveto
- + 2 copy vpt 180 270 arc closepath fill
- + vpt 0 360 arc } bind def
- +/C6 { BL [] 0 setdash 2 copy moveto
- + 2 copy vpt 90 270 arc closepath fill
- + vpt 0 360 arc closepath } bind def
- +/C7 { BL [] 0 setdash 2 copy moveto
- + 2 copy vpt 0 270 arc closepath fill
- + vpt 0 360 arc closepath } bind def
- +/C8 { BL [] 0 setdash 2 copy moveto
- + 2 copy vpt 270 360 arc closepath fill
- + vpt 0 360 arc closepath } bind def
- +/C9 { BL [] 0 setdash 2 copy moveto
- + 2 copy vpt 270 450 arc closepath fill
- + vpt 0 360 arc closepath } bind def
- +/C10 { BL [] 0 setdash 2 copy 2 copy moveto vpt 270 360 arc closepath fill
- + 2 copy moveto
- + 2 copy vpt 90 180 arc closepath fill
- + vpt 0 360 arc closepath } bind def
- +/C11 { BL [] 0 setdash 2 copy moveto
- + 2 copy vpt 0 180 arc closepath fill
- + 2 copy moveto
- + 2 copy vpt 270 360 arc closepath fill
- + vpt 0 360 arc closepath } bind def
- +/C12 { BL [] 0 setdash 2 copy moveto
- + 2 copy vpt 180 360 arc closepath fill
- + vpt 0 360 arc closepath } bind def
- +/C13 { BL [] 0 setdash 2 copy moveto
- + 2 copy vpt 0 90 arc closepath fill
- + 2 copy moveto
- + 2 copy vpt 180 360 arc closepath fill
- + vpt 0 360 arc closepath } bind def
- +/C14 { BL [] 0 setdash 2 copy moveto
- + 2 copy vpt 90 360 arc closepath fill
- + vpt 0 360 arc } bind def
- +/C15 { BL [] 0 setdash 2 copy vpt 0 360 arc closepath fill
- + vpt 0 360 arc closepath } bind def
- +/Rec { newpath 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto
- + neg 0 rlineto closepath } bind def
- +/Square { dup Rec } bind def
- +/Bsquare { vpt sub exch vpt sub exch vpt2 Square } bind def
- +/S0 { BL [] 0 setdash 2 copy moveto 0 vpt rlineto BL Bsquare } bind def
- +/S1 { BL [] 0 setdash 2 copy vpt Square fill Bsquare } bind def
- +/S2 { BL [] 0 setdash 2 copy exch vpt sub exch vpt Square fill Bsquare } bind def
- +/S3 { BL [] 0 setdash 2 copy exch vpt sub exch vpt2 vpt Rec fill Bsquare } bind def
- +/S4 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt Square fill Bsquare } bind def
- +/S5 { BL [] 0 setdash 2 copy 2 copy vpt Square fill
- + exch vpt sub exch vpt sub vpt Square fill Bsquare } bind def
- +/S6 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill Bsquare } bind def
- +/S7 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill
- + 2 copy vpt Square fill
- + Bsquare } bind def
- +/S8 { BL [] 0 setdash 2 copy vpt sub vpt Square fill Bsquare } bind def
- +/S9 { BL [] 0 setdash 2 copy vpt sub vpt vpt2 Rec fill Bsquare } bind def
- +/S10 { BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt Square fill
- + Bsquare } bind def
- +/S11 { BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt2 vpt Rec fill
- + Bsquare } bind def
- +/S12 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill Bsquare } bind def
- +/S13 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill
- + 2 copy vpt Square fill Bsquare } bind def
- +/S14 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill
- + 2 copy exch vpt sub exch vpt Square fill Bsquare } bind def
- +/S15 { BL [] 0 setdash 2 copy Bsquare fill Bsquare } bind def
- +/D0 { gsave translate 45 rotate 0 0 S0 stroke grestore } bind def
- +/D1 { gsave translate 45 rotate 0 0 S1 stroke grestore } bind def
- +/D2 { gsave translate 45 rotate 0 0 S2 stroke grestore } bind def
- +/D3 { gsave translate 45 rotate 0 0 S3 stroke grestore } bind def
- +/D4 { gsave translate 45 rotate 0 0 S4 stroke grestore } bind def
- +/D5 { gsave translate 45 rotate 0 0 S5 stroke grestore } bind def
- +/D6 { gsave translate 45 rotate 0 0 S6 stroke grestore } bind def
- +/D7 { gsave translate 45 rotate 0 0 S7 stroke grestore } bind def
- +/D8 { gsave translate 45 rotate 0 0 S8 stroke grestore } bind def
- +/D9 { gsave translate 45 rotate 0 0 S9 stroke grestore } bind def
- +/D10 { gsave translate 45 rotate 0 0 S10 stroke grestore } bind def
- +/D11 { gsave translate 45 rotate 0 0 S11 stroke grestore } bind def
- +/D12 { gsave translate 45 rotate 0 0 S12 stroke grestore } bind def
- +/D13 { gsave translate 45 rotate 0 0 S13 stroke grestore } bind def
- +/D14 { gsave translate 45 rotate 0 0 S14 stroke grestore } bind def
- +/D15 { gsave translate 45 rotate 0 0 S15 stroke grestore } bind def
- +/DiaE { stroke [] 0 setdash vpt add M
- + hpt neg vpt neg V hpt vpt neg V
- + hpt vpt V hpt neg vpt V closepath stroke } def
- +/BoxE { stroke [] 0 setdash exch hpt sub exch vpt add M
- + 0 vpt2 neg V hpt2 0 V 0 vpt2 V
- + hpt2 neg 0 V closepath stroke } def
- +/TriUE { stroke [] 0 setdash vpt 1.12 mul add M
- + hpt neg vpt -1.62 mul V
- + hpt 2 mul 0 V
- + hpt neg vpt 1.62 mul V closepath stroke } def
- +/TriDE { stroke [] 0 setdash vpt 1.12 mul sub M
- + hpt neg vpt 1.62 mul V
- + hpt 2 mul 0 V
- + hpt neg vpt -1.62 mul V closepath stroke } def
- +/PentE { stroke [] 0 setdash gsave
- + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat
- + closepath stroke grestore } def
- +/CircE { stroke [] 0 setdash
- + hpt 0 360 arc stroke } def
- +/Opaque { gsave closepath 1 setgray fill grestore 0 setgray closepath } def
- +/DiaW { stroke [] 0 setdash vpt add M
- + hpt neg vpt neg V hpt vpt neg V
- + hpt vpt V hpt neg vpt V Opaque stroke } def
- +/BoxW { stroke [] 0 setdash exch hpt sub exch vpt add M
- + 0 vpt2 neg V hpt2 0 V 0 vpt2 V
- + hpt2 neg 0 V Opaque stroke } def
- +/TriUW { stroke [] 0 setdash vpt 1.12 mul add M
- + hpt neg vpt -1.62 mul V
- + hpt 2 mul 0 V
- + hpt neg vpt 1.62 mul V Opaque stroke } def
- +/TriDW { stroke [] 0 setdash vpt 1.12 mul sub M
- + hpt neg vpt 1.62 mul V
- + hpt 2 mul 0 V
- + hpt neg vpt -1.62 mul V Opaque stroke } def
- +/PentW { stroke [] 0 setdash gsave
- + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat
- + Opaque stroke grestore } def
- +/CircW { stroke [] 0 setdash
- + hpt 0 360 arc Opaque stroke } def
- +/BoxFill { gsave Rec 1 setgray fill grestore } def
- +/BoxColFill {
- + gsave Rec
- + /Fillden exch def
- + currentrgbcolor
- + /ColB exch def /ColG exch def /ColR exch def
- + /ColR ColR Fillden mul Fillden sub 1 add def
- + /ColG ColG Fillden mul Fillden sub 1 add def
- + /ColB ColB Fillden mul Fillden sub 1 add def
- + ColR ColG ColB setrgbcolor
- + fill grestore } def
- +%
- +% PostScript Level 1 Pattern Fill routine
- +% Usage: x y w h s a XX PatternFill
- +% x,y = lower left corner of box to be filled
- +% w,h = width and height of box
- +% a = angle in degrees between lines and x-axis
- +% XX = 0/1 for no/yes cross-hatch
- +%
- +/PatternFill { gsave /PFa [ 9 2 roll ] def
- + PFa 0 get PFa 2 get 2 div add PFa 1 get PFa 3 get 2 div add translate
- + PFa 2 get -2 div PFa 3 get -2 div PFa 2 get PFa 3 get Rec
- + gsave 1 setgray fill grestore clip
- + currentlinewidth 0.5 mul setlinewidth
- + /PFs PFa 2 get dup mul PFa 3 get dup mul add sqrt def
- + 0 0 M PFa 5 get rotate PFs -2 div dup translate
- + 0 1 PFs PFa 4 get div 1 add floor cvi
- + { PFa 4 get mul 0 M 0 PFs V } for
- + 0 PFa 6 get ne {
- + 0 1 PFs PFa 4 get div 1 add floor cvi
- + { PFa 4 get mul 0 2 1 roll M PFs 0 V } for
- + } if
- + stroke grestore } def
- +%
- +/Symbol-Oblique /Symbol findfont [1 0 .167 1 0 0] makefont
- +dup length dict begin {1 index /FID eq {pop pop} {def} ifelse} forall
- +currentdict end definefont pop
- +end
- +%%EndProlog
- +gnudict begin
- +gsave
- +50 50 translate
- +0.050 0.050 scale
- +0 setgray
- +newpath
- +(Helvetica) findfont 140 scalefont setfont
- +1.000 UL
- +LTb
- +630 420 M
- +63 0 V
- +6269 0 R
- +-63 0 V
- +546 420 M
- +gsave 0 setgray
- +( 0) Rshow
- +grestore
- +1.000 UL
- +LTb
- +630 1470 M
- +63 0 V
- +6269 0 R
- +-63 0 V
- +-6353 0 R
- +gsave 0 setgray
- +( 5) Rshow
- +grestore
- +1.000 UL
- +LTb
- +630 2520 M
- +63 0 V
- +6269 0 R
- +-63 0 V
- +-6353 0 R
- +gsave 0 setgray
- +( 10) Rshow
- +grestore
- +1.000 UL
- +LTb
- +630 3570 M
- +63 0 V
- +6269 0 R
- +-63 0 V
- +-6353 0 R
- +gsave 0 setgray
- +( 15) Rshow
- +grestore
- +1.000 UL
- +LTb
- +630 4620 M
- +63 0 V
- +6269 0 R
- +-63 0 V
- +-6353 0 R
- +gsave 0 setgray
- +( 20) Rshow
- +grestore
- +1.000 UL
- +LTb
- +630 420 M
- +0 63 V
- +0 4137 R
- +0 -63 V
- +630 280 M
- +gsave 0 setgray
- +( 0) Cshow
- +grestore
- +1.000 UL
- +LTb
- +1685 420 M
- +0 63 V
- +0 4137 R
- +0 -63 V
- +0 -4277 R
- +gsave 0 setgray
- +( 0.05) Cshow
- +grestore
- +1.000 UL
- +LTb
- +2741 420 M
- +0 63 V
- +0 4137 R
- +0 -63 V
- +0 -4277 R
- +gsave 0 setgray
- +( 0.1) Cshow
- +grestore
- +1.000 UL
- +LTb
- +3796 420 M
- +0 63 V
- +0 4137 R
- +0 -63 V
- +0 -4277 R
- +gsave 0 setgray
- +( 0.15) Cshow
- +grestore
- +1.000 UL
- +LTb
- +4851 420 M
- +0 63 V
- +0 4137 R
- +0 -63 V
- +0 -4277 R
- +gsave 0 setgray
- +( 0.2) Cshow
- +grestore
- +1.000 UL
- +LTb
- +5907 420 M
- +0 63 V
- +0 4137 R
- +0 -63 V
- +0 -4277 R
- +gsave 0 setgray
- +( 0.25) Cshow
- +grestore
- +1.000 UL
- +LTb
- +6962 420 M
- +0 63 V
- +0 4137 R
- +0 -63 V
- +0 -4277 R
- +gsave 0 setgray
- +( 0.3) Cshow
- +grestore
- +1.000 UL
- +LTb
- +1.000 UL
- +LTb
- +630 420 M
- +6332 0 V
- +0 4200 V
- +-6332 0 V
- +630 420 L
- +LTb
- +140 2520 M
- +gsave 0 setgray
- +currentpoint gsave translate 90 rotate 0 0 M
- +(Datarate (Mbps)) Cshow
- +grestore
- +grestore
- +LTb
- +3796 70 M
- +gsave 0 setgray
- +(Cyclic prefix) Cshow
- +grestore
- +LTb
- +3796 4830 M
- +gsave 0 setgray
- +(Exprerimental datarate) Cshow
- +grestore
- +1.000 UP
- +1.000 UP
- +1.000 UL
- +LT0
- +LTb
- +6311 4487 M
- +gsave 0 setgray
- +(BPSK_1_2) Rshow
- +grestore
- +LT0
- +6395 4487 M
- +399 0 V
- +630 766 M
- +660 -11 V
- +659 -12 V
- +3268 720 L
- +5907 685 L
- +630 766 Pls
- +1290 755 Pls
- +1949 743 Pls
- +3268 720 Pls
- +5907 685 Pls
- +6594 4487 Pls
- +1.000 UP
- +1.000 UL
- +LT1
- +LTb
- +6311 4347 M
- +gsave 0 setgray
- +(QPSK_1_2) Rshow
- +grestore
- +LT1
- +6395 4347 M
- +399 0 V
- +630 1148 M
- +660 -24 V
- +659 -23 V
- +1319 -44 V
- +5907 985 L
- +630 1148 Crs
- +1290 1124 Crs
- +1949 1101 Crs
- +3268 1057 Crs
- +5907 985 Crs
- +6594 4347 Crs
- +1.000 UP
- +1.000 UL
- +LT2
- +LTb
- +6311 4207 M
- +gsave 0 setgray
- +(QPSK_3_4) Rshow
- +grestore
- +LT2
- +6395 4207 M
- +399 0 V
- +630 1527 M
- +660 -35 V
- +659 -36 V
- +1319 -67 V
- +5907 1279 L
- +630 1527 Star
- +1290 1492 Star
- +1949 1456 Star
- +3268 1389 Star
- +5907 1279 Star
- +6594 4207 Star
- +1.000 UP
- +1.000 UL
- +LT3
- +LTb
- +6311 4067 M
- +gsave 0 setgray
- +(16QAM_1_2) Rshow
- +grestore
- +LT3
- +6395 4067 M
- +399 0 V
- +630 1896 M
- +660 -48 V
- +659 -48 V
- +1319 -88 V
- +5907 1565 L
- +630 1896 Box
- +1290 1848 Box
- +1949 1800 Box
- +3268 1712 Box
- +5907 1565 Box
- +6594 4067 Box
- +1.000 UP
- +1.000 UL
- +LT4
- +LTb
- +6311 3927 M
- +gsave 0 setgray
- +(16QAM_3_4) Rshow
- +grestore
- +LT4
- +6395 3927 M
- +399 0 V
- +630 2633 M
- +660 -71 V
- +659 -72 V
- +3268 2357 L
- +5907 2137 L
- +630 2633 BoxF
- +1290 2562 BoxF
- +1949 2490 BoxF
- +3268 2357 BoxF
- +5907 2137 BoxF
- +6594 3927 BoxF
- +1.000 UP
- +1.000 UL
- +LT5
- +LTb
- +6311 3787 M
- +gsave 0 setgray
- +(64QAM_2_3) Rshow
- +grestore
- +LT5
- +6395 3787 M
- +399 0 V
- +630 3283 M
- +660 -92 V
- +659 -93 V
- +3268 2927 L
- +5907 2642 L
- +630 3283 Circle
- +1290 3191 Circle
- +1949 3098 Circle
- +3268 2927 Circle
- +5907 2642 Circle
- +6594 3787 Circle
- +1.000 UP
- +1.000 UL
- +LT6
- +LTb
- +6311 3647 M
- +gsave 0 setgray
- +(64QAM_3_4) Rshow
- +grestore
- +LT6
- +6395 3647 M
- +399 0 V
- +630 3666 M
- +660 -105 V
- +659 -105 V
- +3268 3261 L
- +5907 2937 L
- +630 3666 CircleF
- +1290 3561 CircleF
- +1949 3456 CircleF
- +3268 3261 CircleF
- +5907 2937 CircleF
- +6594 3647 CircleF
- +1.000 UL
- +LTb
- +630 420 M
- +6332 0 V
- +0 4200 V
- +-6332 0 V
- +630 420 L
- +1.000 UP
- +stroke
- +grestore
- +end
- +showpage
- +%%Trailer
- +%%DocumentFonts: Helvetica
- diff -Naur ns-2.29-org/tcl/wimax/datarate/datarate.tcl ns-2.29/tcl/wimax/datarate/datarate.tcl
- --- ns-2.29-org/tcl/wimax/datarate/datarate.tcl 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/tcl/wimax/datarate/datarate.tcl 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,189 @@
- +# Test script to evaluate datarate in 802.16 networks.
- +# @author rouil
- +# Scenario: Communication between MN and Sink Node with MN attached to BS.
- +
- +#
- +# Topology scenario:
- +#
- +#
- +# |-----|
- +# | MN0 | ; 1.0.1
- +# |-----|
- +#
- +#
- +# (^)
- +# |
- +# |--------------|
- +# | Base Station | ; 1.0.0
- +# |--------------|
- +# |
- +# |
- +# |-----------|
- +# | Sink node | ; 0.0.0
- +# |-----------|
- +#
- +
- +#check input parameters
- +if {$argc != 2} {
- + puts ""
- + puts "Wrong Number of Arguments! 2 arguments for this script"
- + puts "Usage: ns datarate.tcl modulation cyclic_prefix "
- + puts "modulation: OFDM_BPSK_1_2, OFDM_QPSK_1_2, OFDM_QPSK_3_4"
- + puts " OFDM_16QAM_1_2, OFDM_16QAM_3_4, OFDM_64QAM_2_3, OFDM_64QAM_3_4"
- + puts "cyclic_prefix: 0.25, 0.125, 0.0625, 0.03125"
- + exit
- +}
- +
- +# set global variables
- +set output_dir .
- +set traffic_start 2
- +set traffic_stop 7
- +set simulation_stop 8
- +
- +# Configure Wimax
- +Mac/802_16 set debug_ 0
- +Mac/802_16 set frame_duration_ 0.020
- +
- +#define coverage area for base station: 20m coverage
- +Phy/WirelessPhy/OFDM set g_ [lindex $argv 1]
- +Phy/WirelessPhy set Pt_ 0.025
- +Phy/WirelessPhy set RXThresh_ 2.025e-12 ;# 500m radius
- +Phy/WirelessPhy set CSThresh_ [expr 0.9*[Phy/WirelessPhy set RXThresh_]]
- +
- +# Parameter for wireless nodes
- +set opt(chan) Channel/WirelessChannel ;# channel type
- +set opt(prop) Propagation/TwoRayGround ;# radio-propagation model
- +set opt(netif) Phy/WirelessPhy/OFDM ;# network interface type
- +set opt(mac) Mac/802_16 ;# MAC type
- +set opt(ifq) Queue/DropTail/PriQueue ;# interface queue type
- +set opt(ll) LL ;# link layer type
- +set opt(ant) Antenna/OmniAntenna ;# antenna model
- +set opt(ifqlen) 50 ;# max packet in ifq
- +set opt(adhocRouting) DSDV ;# routing protocol
- +
- +set opt(x) 1100 ;# X dimension of the topography
- +set opt(y) 1100 ;# Y dimension of the topography
- +
- +#defines function for flushing and closing files
- +proc finish {} {
- + global ns tf output_dir nb_mn
- + $ns flush-trace
- + close $tf
- + exit 0
- +}
- +
- +#create the simulator
- +set ns [new Simulator]
- +$ns use-newtrace
- +
- +#create the topography
- +set topo [new Topography]
- +$topo load_flatgrid $opt(x) $opt(y)
- +#puts "Topology created"
- +
- +#open file for trace
- +set tf [open $output_dir/out.res w]
- +$ns trace-all $tf
- +#puts "Output file configured"
- +
- +# set up for hierarchical routing (needed for routing over a basestation)
- +$ns node-config -addressType hierarchical
- +AddrParams set domain_num_ 2 ;# domain number
- +lappend cluster_num 1 1 ;# cluster number for each domain
- +AddrParams set cluster_num_ $cluster_num
- +lappend eilastlevel 1 2 ;# number of nodes for each cluster (1 for sink and one for mobile node + base station
- +AddrParams set nodes_num_ $eilastlevel
- +puts "Configuration of hierarchical addressing done"
- +
- +# Create God
- +create-god 2
- +
- +#creates the sink node in first address space.
- +set sinkNode [$ns node 0.0.0]
- +puts "sink node created"
- +
- +#creates the Access Point (Base station)
- +$ns node-config -adhocRouting $opt(adhocRouting)
- + -llType $opt(ll)
- + -macType $opt(mac)
- + -ifqType $opt(ifq)
- + -ifqLen $opt(ifqlen)
- + -antType $opt(ant)
- + -propType $opt(prop)
- + -phyType $opt(netif)
- + -channel [new $opt(chan)]
- + -topoInstance $topo
- + -wiredRouting ON
- + -agentTrace ON
- + -routerTrace ON
- + -macTrace ON
- + -movementTrace OFF
- +#puts "Configuration of base station"
- +
- +set bstation [$ns node 1.0.0]
- +$bstation random-motion 0
- +#provide some co-ord (fixed) to base station node
- +$bstation set X_ 550.0
- +$bstation set Y_ 550.0
- +$bstation set Z_ 0.0
- +set clas [new SDUClassifier/Dest]
- +[$bstation set mac_(0)] add-classifier $clas
- +#set the scheduler for the node. Must be changed to -shed [new $opt(sched)]
- +set bs_sched [new WimaxScheduler/BS]
- +$bs_sched set-default-modulation [lindex $argv 0] ;#OFDM_BPSK_1_2
- +[$bstation set mac_(0)] set-scheduler $bs_sched
- +[$bstation set mac_(0)] set-channel 0
- +puts "Base-Station node created"
- +
- +# creation of the mobile nodes
- +$ns node-config -wiredRouting OFF
- + -macTrace ON ;# Mobile nodes cannot do routing.
- +
- +set wl_node [$ns node 1.0.1] ;# create the node with given @.
- +$wl_node random-motion 0 ;# disable random motion
- +$wl_node base-station [AddrParams addr2id [$bstation node-addr]] ;#attach mn to basestation
- +#compute position of the node
- +$wl_node set X_ 400.0
- +$wl_node set Y_ 550.0
- +$wl_node set Z_ 0.0
- +puts "wireless node created ..."
- +
- +set clas [new SDUClassifier/Dest]
- +[$wl_node set mac_(0)] add-classifier $clas
- +#set the scheduler for the node. Must be changed to -shed [new $opt(sched)]
- +set ss_sched [new WimaxScheduler/SS]
- +[$wl_node set mac_(0)] set-scheduler $ss_sched
- +[$wl_node set mac_(0)] set-channel 0
- +
- +#create source traffic
- +#Create a UDP agent and attach it to node n0
- +set udp [new Agent/UDP]
- +$udp set packetSize_ 1500
- +$ns attach-agent $wl_node $udp
- +
- +# Create a CBR traffic source and attach it to udp0
- +set cbr [new Application/Traffic/CBR]
- +$cbr set packetSize_ 1500
- +$cbr set interval_ 0.0005
- +$cbr attach-agent $udp
- +
- +#create an sink into the sink node
- +
- +# Create the Null agent to sink traffic
- +set null [new Agent/Null]
- +$ns attach-agent $sinkNode $null
- +
- +# Attach the 2 agents
- +$ns connect $udp $null
- +
- +# create the link between sink node and base station
- +$ns duplex-link $sinkNode $bstation 100Mb 1ms DropTail
- +
- +#Schedule start/stop of traffic
- +$ns at $traffic_start "$cbr start"
- +$ns at $traffic_stop "$cbr stop"
- +
- +$ns at $simulation_stop "finish"
- +puts "Starts simulation"
- +$ns run
- +puts "Simulation done."
- diff -Naur ns-2.29-org/tcl/wimax/datarate/plot-datarate ns-2.29/tcl/wimax/datarate/plot-datarate
- --- ns-2.29-org/tcl/wimax/datarate/plot-datarate 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/tcl/wimax/datarate/plot-datarate 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,18 @@
- +reset
- +set terminal post eps
- +set output "datarate802_16.eps"
- +set nogrid
- +#set logscale y
- +set xlabel "Cyclic prefix"
- +set ylabel "Datarate (Mbps)"
- +set xrange [0:0.3]
- +set yrange [0:20]
- +#set key 45,0.45
- +set title "Exprerimental datarate"
- +plot "res_datarate/resultOFDM_BPSK_1_2.dat" using 2:($3/(1024*1024)) title "BPSK_1_2" with lp,
- +"res_datarate/resultOFDM_QPSK_1_2.dat" using 2:($3/(1024*1024)) title "QPSK_1_2" with lp,
- +"res_datarate/resultOFDM_QPSK_3_4.dat" using 2:($3/(1024*1024)) title "QPSK_3_4" with lp,
- +"res_datarate/resultOFDM_16QAM_1_2.dat" using 2:($3/(1024*1024)) title "16QAM_1_2" with lp,
- +"res_datarate/resultOFDM_16QAM_3_4.dat" using 2:($3/(1024*1024)) title "16QAM_3_4" with lp,
- +"res_datarate/resultOFDM_64QAM_2_3.dat" using 2:($3/(1024*1024)) title "64QAM_2_3" with lp,
- +"res_datarate/resultOFDM_64QAM_3_4.dat" using 2:($3/(1024*1024)) title "64QAM_3_4" with lp
- diff -Naur ns-2.29-org/tcl/wimax/l2handover.tcl ns-2.29/tcl/wimax/l2handover.tcl
- --- ns-2.29-org/tcl/wimax/l2handover.tcl 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/tcl/wimax/l2handover.tcl 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,205 @@
- +# Script showing a layer 2 handover in 802.16
- +# @author rouil
- +# Scenario: Communication between MN and Sink Node with MN attached to BS.
- +# Notes:- In order to perform layer 2 handover, the BSs must share the same channel
- +# - Additional mechanisms are required in order to continue a communication after a layer 2 handover
- +# This is achieved by updating the MN address to simulate layer 3 handovers and traffic redirection.
- +# We will provide the code as part of our implementation of IEEE 802.21.
- +#
- +
- +#
- +# Topology scenario:
- +#
- +#
- +# |-----|
- +# | MN0 | ; 1.0.1
- +# |-----|
- +#
- +#
- +# (^) (^)
- +# | |
- +# |--------------| |--------------|
- +# | Base Station | ; 1.0.0 | Base Station |
- +# |--------------| |--------------|
- +# | |
- +# | |
- +# |-----------| |
- +# | Sink node |---------------------|
- +# |-----------| ; 0.0.0
- +#
- +
- +#check input parameters
- +if {$argc != 0} {
- + puts ""
- + puts "Wrong Number of Arguments! No arguments in this topology"
- + puts ""
- + exit
- +}
- +
- +# set global variables
- +set output_dir .
- +set traffic_start 5
- +set traffic_stop 15
- +set simulation_stop 60
- +
- +#define debug values
- +Mac/802_16 set debug_ 1
- +Mac/802_16 set t21_timeout_ 20 ;#max 10s
- +
- +#define coverage area for base station: 20m coverage
- +Phy/WirelessPhy set Pt_ 0.025
- +Phy/WirelessPhy set RXThresh_ 6.12277e-09
- +Phy/WirelessPhy set CSThresh_ [expr 0.9 *[Phy/WirelessPhy set RXThresh_]]
- +
- +# Parameter for wireless nodes
- +set opt(chan) Channel/WirelessChannel ;# channel type
- +set opt(prop) Propagation/TwoRayGround ;# radio-propagation model
- +set opt(netif) Phy/WirelessPhy/OFDM ;# network interface type
- +set opt(mac) Mac/802_16 ;# MAC type
- +set opt(ifq) Queue/DropTail/PriQueue ;# interface queue type
- +set opt(ll) LL ;# link layer type
- +set opt(ant) Antenna/OmniAntenna ;# antenna model
- +set opt(ifqlen) 50 ;# max packet in ifq
- +set opt(adhocRouting) DSDV ;# routing protocol
- +
- +set opt(x) 670 ;# X dimension of the topography
- +set opt(y) 670 ;# Y dimension of the topography
- +
- +#defines function for flushing and closing files
- +proc finish {} {
- + global ns tf output_dir nb_mn
- + $ns flush-trace
- + close $tf
- + exit 0
- +}
- +
- +#create the simulator
- +set ns [new Simulator]
- +$ns use-newtrace
- +
- +#create the topography
- +set topo [new Topography]
- +$topo load_flatgrid $opt(x) $opt(y)
- +
- +#open file for trace
- +set tf [open $output_dir/out.res w]
- +$ns trace-all $tf
- +
- +# set up for hierarchical routing (needed for routing over a basestation)
- +$ns node-config -addressType hierarchical
- +AddrParams set domain_num_ 3 ;# domain number
- +lappend cluster_num 1 1 1 ;# cluster number for each domain
- +AddrParams set cluster_num_ $cluster_num
- +lappend eilastlevel 1 2 2 ;# number of nodes for each cluster
- +AddrParams set nodes_num_ $eilastlevel
- +puts "Configuration of hierarchical addressing done"
- +
- +# Create God
- +create-god 3 ;# nb_mn + 2 (base station and sink node)
- +
- +#creates the sink node in first addressing space.
- +set sinkNode [$ns node 0.0.0]
- +puts "sink node created"
- +
- +#create common channel
- +set channel [new $opt(chan)]
- +
- +#creates the Access Point (Base station)
- +$ns node-config -adhocRouting $opt(adhocRouting)
- + -llType $opt(ll)
- + -macType $opt(mac)
- + -ifqType $opt(ifq)
- + -ifqLen $opt(ifqlen)
- + -antType $opt(ant)
- + -propType $opt(prop)
- + -phyType $opt(netif)
- + -channel $channel
- + -topoInstance $topo
- + -wiredRouting ON
- + -agentTrace ON
- + -routerTrace ON
- + -macTrace ON
- + -movementTrace OFF
- +#puts "Configuration of base station"
- +
- +set bstation [$ns node 1.0.0]
- +$bstation random-motion 0
- +#provide some co-ord (fixed) to base station node
- +$bstation set X_ 50.0
- +$bstation set Y_ 50.0
- +$bstation set Z_ 0.0
- +set clas [new SDUClassifier/Dest]
- +[$bstation set mac_(0)] add-classifier $clas
- +#set the scheduler for the node.
- +set bs_sched [new WimaxScheduler/BS]
- +[$bstation set mac_(0)] set-scheduler $bs_sched
- +[$bstation set mac_(0)] set-channel 0
- +puts "Base Station 1 created"
- +
- +set bstation2 [$ns node 2.0.0]
- +$bstation2 random-motion 0
- +#provide some co-ord (fixed) to base station node
- +$bstation2 set X_ 65.0
- +$bstation2 set Y_ 50.0
- +$bstation2 set Z_ 0.0
- +set clas2 [new SDUClassifier/Dest]
- +[$bstation2 set mac_(0)] add-classifier $clas2
- +#set the scheduler for the node.
- +set bs_sched2 [new WimaxScheduler/BS]
- +[$bstation2 set mac_(0)] set-scheduler $bs_sched2
- +[$bstation2 set mac_(0)] set-channel 1
- +puts "Base Station 2 created"
- +
- +# creation of the mobile nodes
- +$ns node-config -wiredRouting OFF
- + -macTrace ON ;# Mobile nodes cannot do routing.
- +
- +set wl_node [$ns node 1.0.1] ;# create the node with given @.
- +$wl_node random-motion 0 ;# disable random motion
- +$wl_node base-station [AddrParams addr2id [$bstation node-addr]] ;#attach mn to basestation
- +$wl_node set X_ 45.0
- +$wl_node set Y_ 50.0
- +$wl_node set Z_ 0.0
- +$ns at 0.0 "$wl_node setdest 70.0 50.0 2.0"
- +set clas [new SDUClassifier/Dest]
- +[$wl_node set mac_(0)] add-classifier $clas
- +#set the scheduler for the node. Must be changed to -shed [new $opt(sched)]
- +set ss_sched [new WimaxScheduler/SS]
- +[$wl_node set mac_(0)] set-scheduler $ss_sched
- +[$wl_node set mac_(0)] set-channel 0
- +puts "wireless node created ..." ;# debug info
- +#$ns at 6.5 "$ss_sched send-scan"
- +
- +#create source traffic
- +#Create a UDP agent and attach it to node n0
- +set udp [new Agent/UDP]
- +$udp set packetSize_ 1500
- +$ns attach-agent $wl_node $udp
- +
- +# Create a CBR traffic source and attach it to udp0
- +set cbr [new Application/Traffic/CBR]
- +$cbr set packetSize_ 1000
- +$cbr set interval_ 0.1
- +$cbr attach-agent $udp
- +
- +#create an sink into the sink node
- +
- +# Create the Null agent to sink traffic
- +set null [new Agent/Null]
- +$ns attach-agent $sinkNode $null
- +
- +# Attach the 2 agents
- +$ns connect $udp $null
- +
- +
- +# create the link between sink node and base station
- +$ns duplex-link $sinkNode $bstation 100Mb 1ms DropTail
- +
- +# Traffic scenario: here the all start talking at the same time
- +$ns at $traffic_start "$cbr start"
- +$ns at $traffic_stop "$cbr stop"
- +
- +$ns at $simulation_stop "finish"
- +puts "Running simulation"
- +$ns run
- +puts "Simulation done."
- diff -Naur ns-2.29-org/tcl/wimax/simple.tcl ns-2.29/tcl/wimax/simple.tcl
- --- ns-2.29-org/tcl/wimax/simple.tcl 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/tcl/wimax/simple.tcl 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,198 @@
- +# Test for IEEE 802.16 nodes.
- +# @author rouil
- +# Test file for wimax
- +# Scenario: Communication between MNs and Sink Node through 802.16 BS.
- +
- +#
- +# Topology scenario:
- +#
- +#
- +# |-----|
- +# | MN | ; 1.0.1
- +# |-----|
- +#
- +#
- +# (^)
- +# |
- +# |--------------|
- +# | Base Station | ; 1.0.0
- +# |--------------|
- +# |
- +# |
- +# |-----------|
- +# | Sink node | ; 0.0.0
- +# |-----------|
- +#
- +
- +#check input parameters
- +if {$argc != 0} {
- + puts ""
- + puts "Wrong Number of Arguments! No arguments in this topology"
- + puts ""
- + exit (1)
- +}
- +
- +# set global variables
- +set nb_mn 50 ;# max number of mobile node
- +set packet_size 1500 ;# packet size in bytes at CBR applications
- +set gap_size 1 ;#compute gap size between packets
- +puts "gap size=$gap_size"
- +set traffic_start 100
- +set traffic_stop 200
- +set simulation_stop 300
- +
- +#define debug values
- +Mac/802_16 set debug_ 0
- +
- +#define coverage area for base station
- +Phy/WirelessPhy set Pt_ 0.025
- +Phy/WirelessPhy set RXThresh_ 2.025e-12 ;#500m radius
- +Phy/WirelessPhy set CSThresh_ [expr 0.9*[Phy/WirelessPhy set RXThresh_]]
- +
- +# Parameter for wireless nodes
- +set opt(chan) Channel/WirelessChannel ;# channel type
- +set opt(prop) Propagation/TwoRayGround ;# radio-propagation model
- +set opt(netif) Phy/WirelessPhy/OFDM ;# network interface type
- +set opt(mac) Mac/802_16 ;# MAC type
- +set opt(ifq) Queue/DropTail/PriQueue ;# interface queue type
- +set opt(ll) LL ;# link layer type
- +set opt(ant) Antenna/OmniAntenna ;# antenna model
- +set opt(ifqlen) 50 ;# max packet in ifq
- +set opt(adhocRouting) DSDV ;# routing protocol
- +
- +set opt(x) 1100 ;# X dimension of the topography
- +set opt(y) 1100 ;# Y dimension of the topography
- +
- +#defines function for flushing and closing files
- +proc finish {} {
- + global ns tf output_dir nb_mn
- + $ns flush-trace
- + close $tf
- + exit 0
- +}
- +
- +#create the simulator
- +set ns [new Simulator]
- +$ns use-newtrace
- +
- +#create the topography
- +set topo [new Topography]
- +$topo load_flatgrid $opt(x) $opt(y)
- +
- +#open file for trace
- +set tf [open out.res w]
- +$ns trace-all $tf
- +
- +# set up for hierarchical routing (needed for routing over a basestation)
- +#puts "start hierarchical addressing"
- +$ns node-config -addressType hierarchical
- +AddrParams set domain_num_ 2 ;# domain number
- +lappend cluster_num 1 1 ;# cluster number for each domain
- +AddrParams set cluster_num_ $cluster_num
- +lappend eilastlevel 1 [expr ($nb_mn+1)] ;# number of nodes for each cluster (1 for sink and one for mobile nodes + base station
- +AddrParams set nodes_num_ $eilastlevel
- +puts "Configuration of hierarchical addressing done"
- +
- +# Create God
- +create-god [expr ($nb_mn + 2)] ;# nb_mn + 2 (base station and sink node)
- +#puts "God node created"
- +
- +#creates the sink node in first addressing space.
- +set sinkNode [$ns node 0.0.0]
- +#provide some co-ord (fixed) to base station node
- +$sinkNode set X_ 50.0
- +$sinkNode set Y_ 50.0
- +$sinkNode set Z_ 0.0
- +#puts "sink node created"
- +
- +#creates the Access Point (Base station)
- +$ns node-config -adhocRouting $opt(adhocRouting)
- + -llType $opt(ll)
- + -macType $opt(mac)
- + -ifqType $opt(ifq)
- + -ifqLen $opt(ifqlen)
- + -antType $opt(ant)
- + -propType $opt(prop)
- + -phyType $opt(netif)
- + -channel [new $opt(chan)]
- + -topoInstance $topo
- + -wiredRouting ON
- + -agentTrace ON
- + -routerTrace ON
- + -macTrace ON
- + -movementTrace OFF
- +#puts "Configuration of base station"
- +
- +set bstation [$ns node 1.0.0]
- +$bstation random-motion 0
- +#puts "Base-Station node created"
- +#provide some co-ord (fixed) to base station node
- +$bstation set X_ 550.0
- +$bstation set Y_ 550.0
- +$bstation set Z_ 0.0
- +set clas [new SDUClassifier/Dest]
- +[$bstation set mac_(0)] add-classifier $clas
- +#set the scheduler for the node. Must be changed to -shed [new $opt(sched)]
- +set bs_sched [new WimaxScheduler/BS]
- +[$bstation set mac_(0)] set-scheduler $bs_sched
- +[$bstation set mac_(0)] set-channel 0
- +
- +# creation of the mobile nodes
- +$ns node-config -wiredRouting OFF
- + -macTrace ON ;# Mobile nodes cannot do routing.
- +for {set i 0} {$i < $nb_mn} {incr i} {
- + set wl_node_($i) [$ns node 1.0.[expr $i + 1]] ;# create the node with given @.
- + $wl_node_($i) random-motion 0 ;# disable random motion
- + $wl_node_($i) base-station [AddrParams addr2id [$bstation node-addr]] ;#attach mn to basestation
- + #compute position of the node
- + $wl_node_($i) set X_ [expr 340.0+$i]
- + #$ns at 4.0 "$wl_node_($i) set X_ 80"
- + #$ns at 6.0 "$wl_node_($i) set X_ 50"
- + $wl_node_($i) set Y_ 550.0
- + $wl_node_($i) set Z_ 0.0
- + $ns at 0 "$wl_node_($i) setdest 1060.0 550.0 1.0"
- + puts "wireless node $i created ..." ;# debug info
- +
- + set clas [new SDUClassifier/Dest]
- + [$wl_node_($i) set mac_(0)] add-classifier $clas
- + #set the scheduler for the node. Must be changed to -shed [new $opt(sched)]
- + set ss_sched [new WimaxScheduler/SS]
- + [$wl_node_($i) set mac_(0)] set-scheduler $ss_sched
- + [$wl_node_($i) set mac_(0)] set-channel 0
- +
- + #create source traffic
- + #Create a UDP agent and attach it to node n0
- + set udp_($i) [new Agent/UDP]
- + $udp_($i) set packetSize_ 1500
- + $ns attach-agent $wl_node_($i) $udp_($i)
- +
- + # Create a CBR traffic source and attach it to udp0
- + set cbr_($i) [new Application/Traffic/CBR]
- + $cbr_($i) set packetSize_ $packet_size
- + $cbr_($i) set interval_ $gap_size
- + $cbr_($i) attach-agent $udp_($i)
- +
- + #create an sink into the sink node
- +
- + # Create the Null agent to sink traffic
- + set null_($i) [new Agent/Null]
- + $ns attach-agent $sinkNode $null_($i)
- +
- + # Attach the 2 agents
- + $ns connect $udp_($i) $null_($i)
- +}
- +
- +# create the link between sink node and base station
- +$ns duplex-link $sinkNode $bstation 100Mb 1ms DropTail
- +
- +# Traffic scenario: here the all start talking at the same time
- +for {set i 0} {$i < $nb_mn} {incr i} {
- + $ns at $traffic_start "$cbr_($i) start"
- + $ns at $traffic_stop "$cbr_($i) stop"
- +}
- +
- +$ns at $simulation_stop "finish"
- +# Run the simulation
- +puts "Running simulation for $nb_mn mobile nodes..."
- +$ns run
- +puts "Simulation done."
- diff -Naur ns-2.29-org/wimax/connection.cc ns-2.29/wimax/connection.cc
- --- ns-2.29-org/wimax/connection.cc 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/connection.cc 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,175 @@
- +/* This software was developed at the National Institute of Standards and
- + * Technology by employees of the Federal Government in the course of
- + * their official duties. Pursuant to title 17 Section 105 of the United
- + * States Code this software is not subject to copyright protection and
- + * is in the public domain.
- + * NIST assumes no responsibility whatsoever for its use by other parties,
- + * and makes no guarantees, expressed or implied, about its quality,
- + * reliability, or any other characteristic.
- + * <BR>
- + * We would appreciate acknowledgement if the software is used.
- + * <BR>
- + * NIST ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND
- + * DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING
- + * FROM THE USE OF THIS SOFTWARE.
- + * </PRE></P>
- + * @author rouil
- + */
- +
- +#include "connection.h"
- +#include "connectionmanager.h"
- +#include "mac802_16.h"
- +
- +static int basicIndex = BASIC_CID_START;
- +static int primaryIndex = PRIMARY_CID_START;
- +static int transportIndex = TRANSPORT_SEC_CID_START;
- +static int multicastIndex = MULTICAST_CID_START;
- +
- +/**
- + * Constructor used by BS to automatically assign CIDs
- + * @param type The connection type.
- + */
- +Connection::Connection (ConnectionType_t type) : peer_(0),
- + frag_status_(FRAG_NOFRAG),
- + frag_nb_(0),
- + frag_byte_proc_(0),
- + frag_enable_(true)
- +{
- + switch (type) {
- + case CONN_INIT_RANGING:
- + cid_ = INITIAL_RANGING_CID;
- + break;
- + case CONN_AAS_INIT_RANGING:
- + cid_ = AAS_INIT_RANGIN_CID;
- + break;
- + case CONN_PADDING:
- + cid_ = PADDING_CID;
- + break;
- + case CONN_BROADCAST:
- + cid_ = BROADCAST_CID;
- + break;
- + case CONN_MULTICAST_POLLING:
- + cid_ = multicastIndex++;
- + assert (multicastIndex <= MULTICAST_CID_STOP);
- + break;
- + case CONN_BASIC:
- + cid_ = basicIndex++;
- + assert (basicIndex <= BASIC_CID_STOP);
- + break;
- + case CONN_PRIMARY:
- + cid_ = primaryIndex++;
- + assert (primaryIndex <= PRIMARY_CID_STOP);
- + break;
- + case CONN_SECONDARY:
- + case CONN_DATA:
- + cid_ = transportIndex++;
- + assert (transportIndex <= TRANSPORT_SEC_CID_STOP);
- + break;
- + default:
- + fprintf (stderr, "Unsupported connection typen");
- + exit (1);
- + }
- + type_ = type;
- + queue_ = new PacketQueue();
- +
- +}
- +
- +/**
- + * Constructor used by SSs when the CID is already known
- + * @param type The connection type
- + * @param cid The connection cid
- + */
- +Connection::Connection (ConnectionType_t type, int cid) : peer_(0),
- + frag_status_(FRAG_NOFRAG),
- + frag_nb_(0),
- + frag_byte_proc_(0),
- + frag_enable_(true)
- +{
- + cid_ = cid;
- + type_ = type;
- + queue_ = new PacketQueue();
- +}
- +
- +/**
- + * Destructor
- + */
- +Connection::~Connection ()
- +{
- + flush_queue ();
- +}
- +
- +/**
- + * Set the connection manager
- + * @param manager The Connection manager
- + */
- +void Connection::setManager (ConnectionManager *manager)
- +{
- + manager_ = manager;
- +}
- +
- +/**
- + * Enqueue the given packet
- + * @param p The packet to enqueue
- + */
- +void Connection::enqueue (Packet * p)
- +{
- + queue_->enque (p);
- +}
- +
- +/**
- + * Dequeue a packet from the queue
- + * @param p The packet to enqueue
- + */
- +Packet * Connection::dequeue ()
- +{
- + return queue_->deque ();
- +}
- +
- +/**
- + * Flush the queue and return the number of packets freed
- + * @return The number of packets flushed
- + */
- +int Connection::flush_queue()
- +{
- + int i=0;
- + Packet *p;
- + while ( (p=queue_->deque()) ) {
- + manager_->getMac()->drop(p, "CON");
- + i++;
- + }
- + return i;
- +}
- +
- +/**
- + * Return queue size in bytes
- +
- + */
- +int Connection::queueByteLength ()
- +{
- + return queue_->byteLength ();
- +}
- +
- +/**
- + * Return queue size in bytes
- +
- + */
- +int Connection::queueLength ()
- +{
- + return queue_->length ();
- +}
- +
- +/**
- + * Update the fragmentation information
- + * @param status The new fragmentation status
- + * @param index The new fragmentation index
- + * @param bytes The number of bytes
- + */
- +void Connection::updateFragmentation (fragment_status status, int index, int bytes)
- +{
- + frag_status_ = status;
- + frag_nb_ = index;
- + frag_byte_proc_ = bytes;
- +}
- +
- +
- +
- diff -Naur ns-2.29-org/wimax/connection.h ns-2.29/wimax/connection.h
- --- ns-2.29-org/wimax/connection.h 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/connection.h 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,286 @@
- +/* This software was developed at the National Institute of Standards and
- + * Technology by employees of the Federal Government in the course of
- + * their official duties. Pursuant to title 17 Section 105 of the United
- + * States Code this software is not subject to copyright protection and
- + * is in the public domain.
- + * NIST assumes no responsibility whatsoever for its use by other parties,
- + * and makes no guarantees, expressed or implied, about its quality,
- + * reliability, or any other characteristic.
- + * <BR>
- + * We would appreciate acknowledgement if the software is used.
- + * <BR>
- + * NIST ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND
- + * DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING
- + * FROM THE USE OF THIS SOFTWARE.
- + * </PRE></P>
- + * @author rouil
- + */
- +
- +#ifndef CONNECTION_H
- +#define CONNECTION_H
- +
- +#include "serviceflow.h"
- +#include "packet.h"
- +#include "queue.h"
- +#include "mac802_16pkt.h"
- +
- +/* CONSTANTS */
- +#define INITIAL_RANGING_CID 0x0000
- +#define BASIC_CID_START 0x0001
- +#define BASIC_CID_STOP 0x2000
- +#define PRIMARY_CID_START 0x2001
- +#define PRIMARY_CID_STOP 0x4000
- +#define TRANSPORT_SEC_CID_START 0x4001
- +#define TRANSPORT_SEC_CID_STOP 0xFEFE
- +#define AAS_INIT_RANGIN_CID 0xFEFF
- +#define MULTICAST_CID_START 0xFF00
- +#define MULTICAST_CID_STOP 0xFFFD
- +#define PADDING_CID 0xFFFE
- +#define BROADCAST_CID 0xFFFF
- +
- +/**
- + * Define the type of the connection
- + */
- +enum ConnectionType_t {
- + CONN_INIT_RANGING,
- + CONN_AAS_INIT_RANGING,
- + CONN_MULTICAST_POLLING,
- + CONN_PADDING,
- + CONN_BROADCAST,
- + CONN_BASIC,
- + CONN_PRIMARY,
- + CONN_SECONDARY,
- + CONN_DATA
- +};
- +
- +class PeerNode;
- +class ConnectionManager;
- +class Connection;
- +LIST_HEAD (connection, Connection);
- +
- +/**
- + * Class Connection
- + * The class supports LIST.
- + */
- +class Connection {
- + public:
- + /** constructor */
- + Connection (ConnectionType_t);
- +
- + /** constructor */
- + Connection (ConnectionType_t, int cid);
- +
- + /** destructor */
- + ~Connection ();
- +
- + /**
- + * Set the connection manager
- + * @param manager The Connection manager
- + */
- + void setManager (ConnectionManager *manager);
- +
- + /**
- + * Enqueue the given packet
- + * @param p The packet to enqueue
- + */
- + void enqueue (Packet * p);
- +
- + /**
- + * Set the service flow for this connection
- + * @param sflow The service flow for this connection
- + */
- + void setServiceFlow (ServiceFlow * sflow);
- +
- + /**
- + * Return the service flow for this connection
- + */
- + ServiceFlow * getServiceFlow ();
- +
- + /**
- + * Get the value of cid
- + * The connection id
- + * @return the value of cid
- + */
- + inline int get_cid ( ) { return cid_; }
- +
- + /**
- + * Get the value of category_
- + * The connection id
- + * @return the value of category_
- + */
- + inline ConnectionType_t get_category ( ) { return category_; }
- +
- + /**
- + * Set the value of category_
- + * The connection id
- + * @return the value of category_
- + */
- + inline void set_category (ConnectionType_t value ) { category_ = value; }
- +
- + /**
- + * Get the value of serviceflow_
- + * The service flow associated with the connection
- + * @return the value of serviceflow_
- + */
- + inline ServiceFlow * get_serviceflow ( ) { return serviceflow_; }
- +
- + /**
- + * Set the value of serviceflow_
- + * The service flow associated with the connection
- + * @return the value of serviceflow_
- + */
- + inline void set_serviceflow (ServiceFlow * value ) { serviceflow_ = value; }
- +
- + /**
- + * return the connection type
- + * @return The connection type
- + */
- + inline ConnectionType_t getType () { return type_; }
- +
- + /**
- + * Get the value of queue_
- + * The queue for this connection
- + * @return the value of queue_
- + */
- + inline PacketQueue * get_queue ( ) { return queue_; }
- +
- + /**
- + * Dequeue a packet from the queue
- + * @param p The packet to enqueue
- + */
- + Packet * dequeue ();
- +
- + /**
- + * Return queue size in bytes
- + * @return The queue size in bytes
- + */
- + int queueByteLength ();
- +
- + /**
- + * Return queue size in number of packets
- + * @return The number of packet in the queue
- + */
- + int queueLength ();
- +
- + /**
- + * Flush the queue
- + */
- + int flush_queue ();
- +
- + /**
- + * Enable/Disable fragmentation
- + */
- + void enable_fragmentation (bool enable) { frag_enable_ = enable; }
- +
- + /**
- + * Indicates if the connection supports fragmentation
- + */
- + bool isFragEnable () { return frag_enable_; }
- +
- + // Chain element to the list
- + inline void insert_entry(struct connection *head) {
- + LIST_INSERT_HEAD(head, this, link);
- + }
- +
- + // Return next element in the chained list
- + Connection* next_entry(void) const { return link.le_next; }
- +
- + // Remove the entry from the list
- + inline void remove_entry() {
- + LIST_REMOVE(this, link);
- + }
- +
- + /**
- + * Return the peer node for this connection
- + * @return the peer node for this connection
- + */
- + inline PeerNode * getPeerNode () { return peer_; }
- +
- + /**
- + * Set the peer node for this connection
- + * @param the peer node for this connection
- + */
- + inline void setPeerNode (PeerNode *peer) { peer_=peer; }
- +
- + /**
- + * Update the fragmentation information
- + * @param status The new fragmentation status
- + * @param index The new fragmentation index
- + * @param bytes The number of bytes
- + */
- + void updateFragmentation (fragment_status status, int index, int bytes);
- +
- + fragment_status getFragmentationStatus () { return frag_status_; }
- +
- + int getFragmentNumber () { return frag_nb_; }
- +
- + int getFragmentBytes () { return frag_byte_proc_; }
- +
- + protected:
- +
- + /**
- + * Pointer to next in the list
- + */
- + LIST_ENTRY(Connection) link;
- + //LIST_ENTRY(Connection); //for magic draw
- +
- +
- + private:
- + /**
- + * The connection manager
- + */
- + ConnectionManager* manager_;
- +
- + /**
- + * The connection id
- + */
- + int cid_;
- +
- + /**
- + * The category
- + */
- + ConnectionType_t category_;
- +
- + /**
- + * The service flow associated with the connection
- + */
- + ServiceFlow * serviceflow_;
- +
- + /**
- + * The queue for this connection
- + */
- + PacketQueue * queue_;
- +
- + /**
- + * The connection type
- + */
- + ConnectionType_t type_;
- +
- + /**
- + * Pointer to the peer node data
- + */
- + PeerNode *peer_;
- +
- + /**
- + * Fragmentation status
- + */
- + fragment_status frag_status_;
- +
- + /**
- + * Fragmentation number
- + */
- + int frag_nb_;
- +
- + /**
- + * Bytes already processed (i.e sent or received)
- + */
- + int frag_byte_proc_;
- +
- + /**
- + * Indicates if the connection can use fragmentation
- + */
- + bool frag_enable_;
- +
- +};
- +#endif //CONNECTION_H
- +
- diff -Naur ns-2.29-org/wimax/connectionmanager.cc ns-2.29/wimax/connectionmanager.cc
- --- ns-2.29-org/wimax/connectionmanager.cc 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/connectionmanager.cc 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,107 @@
- +/* This software was developed at the National Institute of Standards and
- + * Technology by employees of the Federal Government in the course of
- + * their official duties. Pursuant to title 17 Section 105 of the United
- + * States Code this software is not subject to copyright protection and
- + * is in the public domain.
- + * NIST assumes no responsibility whatsoever for its use by other parties,
- + * and makes no guarantees, expressed or implied, about its quality,
- + * reliability, or any other characteristic.
- + * <BR>
- + * We would appreciate acknowledgement if the software is used.
- + * <BR>
- + * NIST ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND
- + * DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING
- + * FROM THE USE OF THIS SOFTWARE.
- + * </PRE></P>
- + * @author rouil
- + */
- +
- +#include "connectionmanager.h"
- +#include "mac802_16.h"
- +
- +/**
- + * Create the manager for the given mac
- + * @param mac The Mac where the manager is located
- + */
- +ConnectionManager::ConnectionManager (Mac802_16 * mac)
- +{
- + assert (mac!=NULL);
- + mac_ = mac;
- +
- + //init list
- + LIST_INIT (&up_con_list_);
- + LIST_INIT (&down_con_list_);
- +}
- +
- +
- +/**
- + * Add a connection to the list
- + * @param con The connection to add
- + * @param incoming true if it is an uplink connection
- + */
- +void ConnectionManager::add_connection (Connection* con, bool uplink) {
- + assert (con!=NULL);
- + assert (!get_connection (con->get_cid(), uplink)); //check duplicate
- + mac_->debug ("At %f in %d adding %s connection %dn",
- + NOW, mac_->addr(), uplink?"uplink":"downlink", con->get_cid());
- + if (uplink)
- + con->insert_entry (&up_con_list_);
- + else
- + con->insert_entry (&down_con_list_);
- +
- + con->setManager(this);
- +}
- +
- +/**
- + * Remove a connection
- + * @param The connection to remove
- + */
- +void ConnectionManager::remove_connection (Connection* con) {
- + assert (con !=NULL);
- + mac_->debug ("At %f in %d removing connection %dn",
- + NOW, mac_->addr(), con->get_cid());
- + con->remove_entry ();
- +}
- +
- +/**
- + * Remove connection by CID, both directions.
- + * @param cid The connection id
- + */
- +void ConnectionManager::remove_connection (int cid)
- +{
- + Connection *con = get_connection (cid, true);
- + if (con)
- + remove_connection (con);
- + con = get_connection (cid, false);
- + if (con)
- + remove_connection (con);
- +}
- +
- +
- +/**
- + * Return the connection that has the given CID
- + * @param cid The connection ID
- + * @param uplink The direction
- + * @return the connection or NULL
- + */
- +Connection* ConnectionManager::get_connection (int cid, bool uplink) {
- + //search throught the list
- + for (Connection *n=uplink?up_con_list_.lh_first:down_con_list_.lh_first;
- + n; n=n->next_entry()) {
- + if (n->get_cid ()==cid)
- + return n;
- + }
- + return NULL;
- +}
- +
- +/**
- + * Flush the queues. This can be called after switching BS.
- + */
- +void ConnectionManager::flush_queues () {
- + mac_->debug ("At %f in %d Flushing queuesn", NOW, mac_->addr());
- + for (Connection *n=down_con_list_.lh_first; n; n=n->next_entry()) {
- + int i = n->flush_queue();
- + mac_->debug ("tFreed %d packet in queue for connection %dn", i, n->get_cid());
- + }
- +}
- +
- diff -Naur ns-2.29-org/wimax/connectionmanager.h ns-2.29/wimax/connectionmanager.h
- --- ns-2.29-org/wimax/connectionmanager.h 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/connectionmanager.h 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,113 @@
- +/* This software was developed at the National Institute of Standards and
- + * Technology by employees of the Federal Government in the course of
- + * their official duties. Pursuant to title 17 Section 105 of the United
- + * States Code this software is not subject to copyright protection and
- + * is in the public domain.
- + * NIST assumes no responsibility whatsoever for its use by other parties,
- + * and makes no guarantees, expressed or implied, about its quality,
- + * reliability, or any other characteristic.
- + * <BR>
- + * We would appreciate acknowledgement if the software is used.
- + * <BR>
- + * NIST ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND
- + * DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING
- + * FROM THE USE OF THIS SOFTWARE.
- + * </PRE></P>
- + * @author rouil
- + */
- +
- +#ifndef CONNECTIONMANAGER_H
- +#define CONNECTIONMANAGER_H
- +
- +#include "connection.h"
- +
- +class Mac802_16;
- +
- +/**
- + * Class ConnectionManager
- + * The class handles the list of connections for a Mac 802.16
- + */
- +class ConnectionManager {
- + friend class Connection;
- + public:
- + /**
- + *
- + * @param mac The mac where the manager belongs
- + */
- + ConnectionManager (Mac802_16 * mac);
- +
- + /**
- + * Add a connection
- + * @param con The connection to add
- + * @param incoming true if it is an uplink connection
- + */
- + void add_connection (Connection* con, bool uplink);
- +
- + /**
- + * Remove the given connection
- + * @param connection Remove the given connection
- + */
- + void remove_connection (Connection* connection);
- +
- + /**
- + * Remove connection by CID, both directions.
- + * @param cid The connection id
- + */
- + void remove_connection (int cid);
- +
- + /**
- + * Return the connection with the given cid and direction
- + * @param cid The connection id
- + * @param incoming specifies the direction of the connection
- + */
- + Connection* get_connection (int cid, bool uplink);
- +
- + /**
- + * Return the head of the incoming connection list
- + */
- + Connection* get_up_connection () { return up_con_list_.lh_first; }
- +
- + /**
- + * Return the head of the outgoing connection list
- + */
- + Connection* get_down_connection () { return down_con_list_.lh_first; }
- +
- +
- + /**
- + * Flush the queues. This can be called after switching BS.
- + */
- + void flush_queues ();
- +
- + protected:
- + /**
- + * Get the value of mac_
- + * The Mac where this object is located
- + * @return the value of mac_
- + */
- + inline Mac802_16 * getMac ( ) { return mac_; }
- +
- + private:
- + /**
- + * The list of available connections
- + */
- + Connection* connections_;
- +
- + /**
- + * The Mac where this object is located
- + */
- + Mac802_16 * mac_;
- +
- + /**
- + * The list of uplink connections
- + */
- + struct connection up_con_list_;
- +
- + /**
- + * The list of downlink connections
- + */
- + struct connection down_con_list_;
- +
- +
- +};
- +#endif //CONNECTIONMANAGER_H
- +
- diff -Naur ns-2.29-org/wimax/destclassifier.cc ns-2.29/wimax/destclassifier.cc
- --- ns-2.29-org/wimax/destclassifier.cc 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/destclassifier.cc 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,93 @@
- +/* This software was developed at the National Institute of Standards and
- + * Technology by employees of the Federal Government in the course of
- + * their official duties. Pursuant to title 17 Section 105 of the United
- + * States Code this software is not subject to copyright protection and
- + * is in the public domain.
- + * NIST assumes no responsibility whatsoever for its use by other parties,
- + * and makes no guarantees, expressed or implied, about its quality,
- + * reliability, or any other characteristic.
- + * <BR>
- + * We would appreciate acknowledgement if the software is used.
- + * <BR>
- + * NIST ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND
- + * DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING
- + * FROM THE USE OF THIS SOFTWARE.
- + * </PRE></P>
- + * @author rouil
- + */
- +
- +#include "destclassifier.h"
- +#include "mac802_16.h"
- +#include "scheduling/wimaxscheduler.h"
- +
- +/**
- + * TCL Hooks for the simulator for classifier
- + */
- +static class DestClassifierClass : public TclClass {
- +public:
- + DestClassifierClass() : TclClass("SDUClassifier/Dest") {}
- + TclObject* create(int, const char*const*) {
- + return (new DestClassifier());
- +
- + }
- +} class_destclassifier;
- +
- +/**
- + * Create a classifier in the given mac
- + * Constructor to be used by TCL
- + */
- +DestClassifier::DestClassifier (): SDUClassifier () {
- +
- +}
- +
- +
- +/**
- + * Classify a packet and return the CID to use (or -1 if unknown)
- + * @param p The packet to classify
- + * @return The CID or -1
- + */
- +int DestClassifier::classify (Packet * p)
- +{
- + struct hdr_mac *dh = HDR_MAC(p);
- + int dst = dh->macDA();
- + mac_->debug ("At %f in Mac %d DestClassifier classifying packet for %d(size=%d, type=%s)n",
- + NOW, mac_->addr(), dst, HDR_CMN(p)->size(), packet_info.name(HDR_CMN(p)->ptype()));
- + //here we look at the list of peer nodes until we find the one with
- + //the same destination address. Then we return its data communication
- +
- + //if broadcast, then send to broadcast CID
- + if (dst == -1) {
- + if (mac_->getScheduler()->getNodeType ()==STA_BS)
- + return BROADCAST_CID;
- + else {
- + //I am a MN, check if I am connected
- + PeerNode *n = mac_->getPeerNode_head ();
- + //i should classify depending on the packet type.TBD
- + if (n && n->getSecondary())
- + return n->getSecondary()->get_cid();
- + }
- + }
- +
- + for (PeerNode *n = mac_->getPeerNode_head (); n ; n=n->next_entry()) {
- + //printf ("Checking peer %d for %dn", n->getPeerNode(), dst);
- + if (dst == n->getPeerNode ()) {
- + switch (HDR_CMN(p)->ptype()) {
- + case PT_ARP:
- +#ifdef USE_802_21
- + case PT_RRED:
- + case PT_RADS:
- + case PT_RSOL:
- +#endif
- + if (n->getSecondary())
- + return n->getSecondary()->get_cid();
- + break;
- + default:
- + if (n->getOutData())
- + return n->getOutData()->get_cid();
- + else //this node is not ready to send data
- + break;
- + }
- + }
- + }
- + return -1;
- +}
- diff -Naur ns-2.29-org/wimax/destclassifier.h ns-2.29/wimax/destclassifier.h
- --- ns-2.29-org/wimax/destclassifier.h 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/destclassifier.h 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,60 @@
- +/* This software was developed at the National Institute of Standards and
- + * Technology by employees of the Federal Government in the course of
- + * their official duties. Pursuant to title 17 Section 105 of the United
- + * States Code this software is not subject to copyright protection and
- + * is in the public domain.
- + * NIST assumes no responsibility whatsoever for its use by other parties,
- + * and makes no guarantees, expressed or implied, about its quality,
- + * reliability, or any other characteristic.
- + * <BR>
- + * We would appreciate acknowledgement if the software is used.
- + * <BR>
- + * NIST ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND
- + * DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING
- + * FROM THE USE OF THIS SOFTWARE.
- + * </PRE></P>
- + * @author rouil
- + */
- +
- +#ifndef DESTCLASSIFIER_H
- +#define DESTCLASSIFIER_H
- +
- +#include "sduclassifier.h"
- +
- +/**
- + * This class classifies the packet based on the destination address
- + */
- +class DestClassifier : public SDUClassifier
- +{
- + public:
- +
- + /**
- + * Create a classifier in the given mac
- + */
- + DestClassifier ();
- +
- + /**
- + * Create a classifier in the given mac
- + * @param mac The mac where it is located
- + */
- + DestClassifier (Mac802_16 *mac);
- +
- + /**
- + * Create a classifier in the given mac
- + * @param mac The mac where it is located
- + * @param priority The classifier's priority
- + */
- + DestClassifier (Mac802_16 *mac, int priority_);
- +
- + /**
- + * Classify a packet and return the CID to use (or -1 if unknown)
- + * @param p The packet to classify
- + * @return The CID or -1
- + */
- + int classify (Packet * p);
- +
- + protected:
- +
- +};
- +
- +#endif
- diff -Naur ns-2.29-org/wimax/mac802_16.cc ns-2.29/wimax/mac802_16.cc
- --- ns-2.29-org/wimax/mac802_16.cc 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/mac802_16.cc 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,1168 @@
- +/* This software was developed at the National Institute of Standards and
- + * Technology by employees of the Federal Government in the course of
- + * their official duties. Pursuant to title 17 Section 105 of the United
- + * States Code this software is not subject to copyright protection and
- + * is in the public domain.
- + * NIST assumes no responsibility whatsoever for its use by other parties,
- + * and makes no guarantees, expressed or implied, about its quality,
- + * reliability, or any other characteristic.
- + * <BR>
- + * We would appreciate acknowledgement if the software is used.
- + * <BR>
- + * NIST ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND
- + * DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING
- + * FROM THE USE OF THIS SOFTWARE.
- + * </PRE></P>
- + * @author rouil
- + */
- +
- +#include "mac802_16.h"
- +#include "scheduling/wimaxscheduler.h"
- +#include "scheduling/ssscheduler.h" //TBR
- +//we use mac 802_11 for trace
- +#include "mac-802_11.h"
- +
- +/* Defines frequencies for 3.5 GHz band and 7 Mhz freqency bandwidth */
- +/* Will be removed when a dynamic way is added */
- +static const int nbFreq = 5;
- +static const double frequencies[] = { 3.486e+9, 3.493e+9, 3.5e+9, 3.507e+9, 3.514e+9};
- +
- +
- +int hdr_mac802_16::offset_;
- +/**
- + * TCL Hooks for the simulator for wimax packets
- + */
- +static class Mac802_16HeaderClass : public PacketHeaderClass
- +{
- +public:
- + Mac802_16HeaderClass() : PacketHeaderClass("PacketHeader/802_16",
- + sizeof(hdr_mac802_16))
- + {
- + bind_offset(&hdr_mac802_16::offset_);
- + }
- +} class_hdr_mac802_16;
- +
- +/**
- + * TCL Hooks for the simulator for wimax mac
- + */
- +static class Mac802_16Class : public TclClass {
- +public:
- + Mac802_16Class() : TclClass("Mac/802_16") {}
- + TclObject* create(int, const char*const*) {
- + return (new Mac802_16());
- +
- + }
- +} class_mac802_16;
- +
- +Phy802_16MIB::Phy802_16MIB(Mac802_16 *parent)
- +{
- + parent->bind ("channel_", &channel );
- + parent->bind ("fbandwidth_", &fbandwidth );
- + parent->bind ("ttg_", &ttg );
- + parent->bind ("rtg_", &rtg );
- +}
- +
- +Mac802_16MIB::Mac802_16MIB(Mac802_16 *parent)
- +{
- + parent->bind ("queue_length_", &queue_length );
- + parent->bind ("frame_duration_", &frame_duration );
- + parent->bind ("dcd_interval_", &dcd_interval );
- + parent->bind ("ucd_interval_", &ucd_interval );
- + parent->bind ("init_rng_interval_", &init_rng_interval );
- + parent->bind ("lost_dlmap_interval_", &lost_dlmap_interval );
- + parent->bind ("lost_ulmap_interval_", &lost_ulmap_interval );
- + parent->bind ("t1_timeout_", &t1_timeout );
- + parent->bind ("t2_timeout_", &t2_timeout );
- + parent->bind ("t3_timeout_", &t3_timeout );
- + parent->bind ("t6_timeout_", &t6_timeout );
- + parent->bind ("t12_timeout_", &t12_timeout );
- + parent->bind ("t16_timeout_", &t16_timeout );
- + parent->bind ("t17_timeout_", &t17_timeout );
- + parent->bind ("t21_timeout_", &t21_timeout );
- + parent->bind ("contention_rng_retry_", &contention_rng_retry );
- + parent->bind ("invited_rng_retry_", &invited_rng_retry );
- + parent->bind ("request_retry_", &request_retry );
- + parent->bind ("reg_req_retry_", ®_req_retry );
- + parent->bind ("tproc_", &tproc );
- + parent->bind ("dsx_req_retry_", &dsx_req_retry );
- + parent->bind ("dsx_rsp_retry_", &dsx_rsp_retry );
- +
- + parent->bind ("rng_backoff_start_", &rng_backoff_start);
- + parent->bind ("rng_backoff_stop_", &rng_backoff_stop);
- + parent->bind ("bw_backoff_start_", &bw_backoff_start);
- + parent->bind ("bw_backoff_stop_", &bw_backoff_stop);
- +
- + //mobility extension
- + parent->bind ("scan_duration_", &scan_duration );
- + parent->bind ("interleaving_interval_", &interleaving );
- + parent->bind ("scan_iteration_", &scan_iteration );
- + parent->bind ("t44_timeout_", &t44_timeout );
- + parent->bind ("max_dir_scan_time_", &max_dir_scan_time );
- + parent->bind ("nbr_adv_interval_", &nbr_adv_interval );
- + parent->bind ("scan_req_retry_", &scan_req_retry );
- +
- + parent->bind ("client_timeout_", &client_timeout );
- + parent->bind ("rxp_avg_alpha_", &rxp_avg_alpha);
- + parent->bind ("lgd_factor_", &lgd_factor_);
- +}
- +
- +/**
- + * Creates a Mac 802.16
- + */
- +Mac802_16::Mac802_16() : Mac (), macmib_(this), phymib_(this), rxTimer_(this)
- +{
- + //init variable
- + LIST_INIT(&classifier_list_);
- + peer_list_ = (struct peerNode *) malloc (sizeof(struct peerNode));
- + LIST_INIT(peer_list_);
- +
- + collision_ = false;
- + pktRx_ = NULL;
- + pktBuf_ = NULL;
- +
- + connectionManager_ = new ConnectionManager (this);
- + scheduler_ = NULL;
- + /* the following will be replaced by dynamic adding of service flow */
- + serviceFlowHandler_ = new ServiceFlowHandler ();
- + serviceFlowHandler_->setMac (this);
- + bs_id_ = BS_NOT_CONNECTED;
- + type_ = STA_UNKNOWN;
- + frame_number_ = 0;
- + state_ = MAC802_16_DISCONNECTED;
- + notify_upper_ = true;
- +
- + last_tx_time_ = 0;
- + last_tx_duration_ = 0;
- +
- + Tcl& tcl = Tcl::instance();
- + tcl.evalf ("Phy/WirelessPhy set RXThresh_");
- + macmib_.RXThreshold_ = atof (tcl.result());
- +
- +
- + /* Initialize Stats variables */
- + bind_bool ("print_stats_", &print_stats_);
- + last_tx_delay_ = 0;
- + double tmp;
- + bind ("delay_avg_alpha_", &tmp);
- + delay_watch_.set_alpha(tmp);
- + bind ("jitter_avg_alpha_", &tmp);
- + jitter_watch_.set_alpha(tmp);
- + bind ("loss_avg_alpha_", &tmp);
- + loss_watch_.set_alpha(tmp);
- + bind ("throughput_avg_alpha_", &tmp);
- + rx_data_watch_.set_alpha(tmp);
- + rx_data_watch_.set_pos_gradient (false);
- + rx_traffic_watch_.set_alpha(tmp);
- + rx_traffic_watch_.set_pos_gradient (false);
- + tx_data_watch_.set_alpha(tmp);
- + tx_data_watch_.set_pos_gradient (false);
- + tx_traffic_watch_.set_alpha(tmp);
- + tx_traffic_watch_.set_pos_gradient (false);
- + bind ("throughput_delay_", &tmp);
- + rx_data_watch_.set_delay (tmp);
- + rx_traffic_watch_.set_delay (tmp);
- + tx_data_watch_.set_delay (tmp);
- + tx_traffic_watch_.set_delay (tmp);
- + //timers for stats
- + rx_data_timer_ = new StatTimer (this, &rx_data_watch_);
- + rx_traffic_timer_ = new StatTimer (this, &rx_traffic_watch_);
- + tx_data_timer_ = new StatTimer (this, &tx_data_watch_);
- + tx_traffic_timer_ = new StatTimer (this, &tx_traffic_watch_);
- +
- +}
- +
- +/*
- + * Interface with the TCL script
- + * @param argc The number of parameter
- + * @param argv The list of parameters
- + */
- +int Mac802_16::command(int argc, const char*const* argv)
- +{
- + if (argc == 2) {
- + if (strcmp(argv[1], "dump-classifiers") == 0) {
- + for (SDUClassifier *n=classifier_list_.lh_first;n;n=n->next_entry()) {
- + //printf ("Classifier %x priority=%dn", (int)n, n->getPriority());
- + }
- + return TCL_OK;
- + }
- + }
- + else if (argc == 3) {
- + /*
- + if (strcmp(argv[1], "set-bs") == 0) {
- + bs_id_ = atoi (argv[2]);
- + }
- + else*/
- + if (strcmp(argv[1], "add-classifier") == 0) {
- + SDUClassifier *clas = (SDUClassifier*) TclObject::lookup(argv[2]);
- + if (clas == 0)
- + return TCL_ERROR;
- + //add classifier to the list
- + addClassifier (clas);
- + return TCL_OK;
- + } else if (strcmp(argv[1], "set-scheduler") == 0) {
- + scheduler_ = (WimaxScheduler*) TclObject::lookup(argv[2]);
- + if (scheduler_ == 0)
- + return TCL_ERROR;
- + scheduler_->setMac (this); //register the mac
- + setStationType (scheduler_->getNodeType()); //get the node type (BS or MN)
- + return TCL_OK;
- + } else if (strcmp(argv[1], "set-servicehandler") == 0) {
- + serviceFlowHandler_ = (ServiceFlowHandler*) TclObject::lookup(argv[2]);
- + if (serviceFlowHandler_ == 0)
- + return TCL_ERROR;
- + serviceFlowHandler_->setMac (this);
- + return TCL_OK;
- + } else if (strcmp(argv[1], "set-channel") == 0) {
- + assert (netif_); //to make sure we can update the phy
- + phymib_.channel = atoi (argv[2]);
- + double tmp = frequencies[phymib_.channel];
- + getPhy ()->setFrequency (tmp);
- + return TCL_OK;
- + }
- + }
- + return Mac::command(argc, argv);
- +}
- +
- +/**
- + * Set the type of STA. This will be called when adding the scheduler
- + * It is used to create the default connections
- + * @param type The station type
- + */
- +void Mac802_16::setStationType (station_type_t type)
- +{
- + assert (type_ == STA_UNKNOWN && type != STA_UNKNOWN);
- + type_ = type;
- +
- + init_default_connections ();
- +}
- +
- +/**
- + * Initialize default connections
- + */
- +void Mac802_16::init_default_connections ()
- +{
- + Connection * con;
- +
- + //create initial ranging and padding connection
- + con = new Connection (CONN_INIT_RANGING);
- + connectionManager_->add_connection (con, true); //uplink
- + con = new Connection (CONN_INIT_RANGING);
- + connectionManager_->add_connection (con, false); //downlink
- + con = new Connection (CONN_PADDING);
- + connectionManager_->add_connection (con, true);
- + con = new Connection (CONN_PADDING);
- + connectionManager_->add_connection (con, false);
- +
- + if (type_ == STA_BS) {
- + //the BS is always connected
- + setMacState (MAC802_16_CONNECTED);
- + //we need to create a Broadcast connection and AAS init ranging CIDs
- + con = new Connection (CONN_BROADCAST);
- + connectionManager_->add_connection (con, false);
- + con = new Connection (CONN_AAS_INIT_RANGING);
- + connectionManager_->add_connection (con, true);
- + } else if (type_ == STA_MN) {
- + //create connection to receive broadcast packets from BS
- + con = new Connection (CONN_BROADCAST);
- + connectionManager_->add_connection (con, false);
- + }
- +}
- +
- +/**
- + * Return the peer node that has the given address
- + * @param index The address of the peer
- + * @return The peer node that has the given address
- + */
- +PeerNode* Mac802_16::getPeerNode (int index)
- +{
- + for (PeerNode *p=peer_list_->lh_first;p;p=p->next_entry()) {
- + if (p->getPeerNode ()==index)
- + return p;
- + }
- + return NULL;
- +}
- +
- +/**
- + * Add the peer node
- + * @param The peer node to add
- + */
- +void Mac802_16::addPeerNode (PeerNode *node)
- +{
- + node->insert_entry (peer_list_);
- + //update Rx time so for default value
- + node->setRxTime(NOW);
- + node->getStatWatch()->set_alpha(macmib_.rxp_avg_alpha);
- +}
- +
- +/**
- + * Remove the peer node
- + * @param The peer node to remove
- + */
- +void Mac802_16::removePeerNode (PeerNode *peer)
- +{
- + if (peer->getBasic()) {
- + getCManager()->remove_connection (peer->getBasic()->get_cid());
- + delete (peer->getBasic());
- + }
- + if (peer->getPrimary()) {
- + getCManager()->remove_connection (peer->getPrimary()->get_cid());
- + delete (peer->getPrimary());
- + }
- + if (peer->getSecondary()) {
- + getCManager()->remove_connection (peer->getSecondary()->get_cid());
- + delete (peer->getSecondary());
- + }
- + if (peer->getInData()) {
- + getCManager()->remove_connection (peer->getInData()->get_cid());
- + delete (peer->getInData());
- + }
- + if (peer->getOutData()) {
- + getCManager()->remove_connection (peer->getOutData()->get_cid());
- + delete (peer->getOutData());
- + }
- + peer->remove_entry ();
- + delete (peer);
- +}
- +
- +/**
- + * Set the mac state
- + * @param state The new mac state
- + */
- +void Mac802_16::setMacState (Mac802_16State state)
- +{
- + state_ = state;
- +}
- +
- +/**
- + * Return the mac state
- + * @return The new mac state
- + */
- +Mac802_16State Mac802_16::getMacState ()
- +{
- + return state_;
- +}
- +
- +/**
- + * Return the PHY layer
- + * @return The PHY layer
- + */
- +OFDMPhy* Mac802_16::getPhy () {
- + return (OFDMPhy*) netif_;
- +}
- +
- +/**
- + * Change the channel
- + * @param channel The new channel
- + */
- +void Mac802_16::setChannel (int channel)
- +{
- + assert (channel < nbFreq);
- + phymib_.channel = channel;
- + double tmp = frequencies[phymib_.channel];
- + getPhy ()->setFrequency (tmp);
- +}
- +
- +/**
- + * Return the channel number for the given frequency
- + * @param freq The frequency
- + * @return The channel number of -1 if the frequency does not match
- + */
- +int Mac802_16::getChannel (double freq)
- +{
- + for (int i = 0 ; i < nbFreq ; i++) {
- + if (frequencies[i]==freq)
- + return i;
- + }
- + return -1;
- +}
- +
- +/**
- + * Return the channel index
- + * @return The channel
- + */
- +int Mac802_16::getChannel ()
- +{
- + return phymib_.channel;
- +}
- +
- +/**
- + * Set the channel to the next from the list
- + * Used at initialisation and when loosing signal
- + */
- +void Mac802_16::nextChannel ()
- +{
- + debug ("At %f in Mac %d Going to channel %dn", NOW, index_, (phymib_.channel+1)%nbFreq);
- + setChannel ((phymib_.channel+1)%nbFreq);
- +}
- +
- +/**
- + * Add a flow
- + * @param qos The QoS required
- + * @param handler The entity that requires to add a flow
- + */
- +void Mac802_16::addFlow (ServiceFlowQoS * qos, void * handler)
- +{
- +
- +}
- +
- +/**
- + * Backup the state of the Mac
- + */
- +state_info* Mac802_16::backup_state ()
- +{
- + state_info *backup_state = (state_info*) malloc (sizeof (state_info));
- + backup_state->bs_id = bs_id_;
- + backup_state->state = state_;
- + backup_state->frameduration = getFrameDuration();
- + backup_state->frame_number = frame_number_;
- + backup_state->channel = getChannel();
- + backup_state->connectionManager = connectionManager_;
- + connectionManager_ = new ConnectionManager (this);
- + init_default_connections ();
- + backup_state->serviceFlowHandler = serviceFlowHandler_;
- + serviceFlowHandler_ = new ServiceFlowHandler();
- + backup_state->peer_list = peer_list_;
- + peer_list_ = (struct peerNode *) malloc (sizeof(struct peerNode));
- + LIST_INIT(peer_list_);
- + return backup_state;
- +}
- +
- +/**
- + * Restore the state of the Mac
- + */
- +void Mac802_16::restore_state (state_info *backup_state)
- +{
- + bs_id_ = backup_state->bs_id;
- + state_ = backup_state->state;
- + setFrameDuration(backup_state->frameduration);
- + frame_number_ = backup_state->frame_number;
- + setChannel (backup_state->channel);
- + delete (connectionManager_);
- + connectionManager_ = backup_state->connectionManager;
- + delete (serviceFlowHandler_);
- + serviceFlowHandler_ = backup_state->serviceFlowHandler;
- + while (getPeerNode_head()!=NULL) {
- + removePeerNode (getPeerNode_head());
- + }
- + peer_list_ = backup_state->peer_list;
- +}
- +
- +/**
- + * Set the variable used to find out if upper layers
- + * must be notified to send packets. During scanning we
- + * do not want upper layers to send packet to the mac.
- + */
- +void Mac802_16::setNotify_upper (bool notify) {
- + notify_upper_ = notify;
- + if (notify_upper_ && pktBuf_) {
- + sendDown (pktBuf_);
- + pktBuf_ = NULL;
- + }
- +}
- +
- +/**** Packet processing methods ****/
- +
- +/*
- + * Process packets going out
- + * @param p The packet to send out
- + */
- +void Mac802_16::sendDown(Packet *p)
- +{
- + //We first send it through the CS
- + int cid = -1;
- +
- + if (!notify_upper_) {
- + assert (!pktBuf_);
- + pktBuf_ = p;
- + return;
- + }
- +
- + for (SDUClassifier *n=classifier_list_.lh_first; n && cid==-1; n=n->next_entry()) {
- + cid = n->classify (p);
- + }
- +
- + if (cid == -1) {
- + debug ("At %f in Mac %d drop packet because no classification were foundn",
- + NOW, index_);
- + drop(p, "CID");
- + //Packet::free (p);
- + } else {
- + //enqueue the packet
- + Connection *connection = connectionManager_->get_connection (cid, type_ == STA_MN);
- + if (connection == NULL) {
- + debug ("Warning: At %f in Mac %d connection with cid = %d does not exist. Please check classifiersn",
- + NOW, index_, cid);
- + //Packet::free (p);
- + update_watch (&loss_watch_, 1);
- + drop(p, "CID");
- + }
- + else {
- + if (connection->queueLength ()==macmib_.queue_length) {
- + //queue full
- + update_watch (&loss_watch_, 1);
- + drop (p, "QWI");
- + } else {
- + //update mac header information
- + //set header information
- + hdr_mac802_16 *wimaxHdr = HDR_MAC802_16(p);
- + wimaxHdr->header.ht = 0;
- + wimaxHdr->header.ec = 1;
- + wimaxHdr->header.type = 0; //no subheader
- + wimaxHdr->header.ci = 0;
- + wimaxHdr->header.eks = 0;
- + wimaxHdr->header.cid = cid; //default
- + wimaxHdr->header.hcs = 0;
- + HDR_CMN(p)->size() += HDR_MAC802_16_SIZE;
- + HDR_CMN(p)->timestamp() = NOW; //set timestamp for delay
- + connection ->enqueue (p);
- + //printf ("At %f in Mac %d Enqueue packet to cid=%d queue size=%d(max=%d)n", NOW, index_, cid,connection->queueLength (), macmib_.queue_length);
- + }
- + }
- + }
- +
- + //inform upper layer that it can send another packet
- + //if (notify_upper_)
- + resume (NULL);
- +}
- +
- +/*
- + * Transmit a packet to the physical layer
- + * @param p The packet to send out
- + */
- +void Mac802_16::transmit(Packet *p)
- +{
- + if (NOW < last_tx_time_+last_tx_duration_) {
- + //still sending
- + //printf ("MAC is already transmitting. Drop packet.n");
- + Packet::free (p);
- + return;
- + }
- +
- + struct hdr_cmn *ch = HDR_CMN(p);
- + /*
- + debug ("At %f in Mac %d sending packet (type=%s, size=%d) ", NOW, index_, packet_info.name(ch->ptype()), ch->size());
- + if (ch->ptype()==PT_MAC) {
- + if (HDR_MAC802_16(p)->header.ht == 0)
- + debug ("mngt=%dn", ((mac802_16_dl_map_frame*) p->accessdata())->type);
- + else
- + debug ("bwreqn");
- + } else {
- + debug ("n");
- + }
- + */
- + //update stats for delay and jitter
- + double delay = NOW-ch->timestamp();
- + update_watch (&delay_watch_, delay);
- + double jitter = fabs (delay - last_tx_delay_);
- + update_watch (&jitter_watch_, jitter);
- + last_tx_delay_ = delay;
- + if (ch->ptype()!=PT_MAC) {
- + update_throughput (&tx_data_watch_, 8*ch->size());
- + }
- + update_throughput (&tx_traffic_watch_, 8*ch->size());
- +
- + last_tx_time_ = NOW;
- + last_tx_duration_ = ch->txtime();
- + downtarget_->recv (p, (Handler*)NULL);
- +}
- +
- +/*
- + * Process incoming packets
- + * @param p The incoming packet
- + */
- +void Mac802_16::sendUp (Packet *p)
- +{
- + struct hdr_cmn *ch = HDR_CMN(p);
- +
- +#ifdef DEBUG_WIMAX
- + debug ("At %f in Mac %d receive first bit..over at %f(txtime=%f) (type=%s) ", NOW, index_, NOW+ch->txtime(),ch->txtime(), packet_info.name(ch->ptype()));
- + if (ch->ptype()==PT_MAC) {
- + if (HDR_MAC802_16(p)->header.ht == 0)
- + debug ("mngt=%dn", ((mac802_16_dl_map_frame*) p->accessdata())->type);
- + else
- + debug ("bwreqn");
- + } else {
- + debug ("n");
- + }
- +#endif
- +
- + if (pktRx_ !=NULL) {
- + /*
- + * If the power of the incoming packet is smaller than the
- + * power of the packet currently being received by at least
- + * the capture threshold, then we ignore the new packet.
- + */
- + if(pktRx_->txinfo_.RxPr / p->txinfo_.RxPr >= p->txinfo_.CPThresh) {
- + Packet::free(p);
- + } else {
- + /*
- + * Since a collision has occurred, figure out
- + * which packet that caused the collision will
- + * "last" the longest. Make this packet,
- + * pktRx_ and reset the Recv Timer if necessary.
- + */
- + if(txtime(p) > rxTimer_.expire()) {
- + rxTimer_.stop();
- + //printf ("t drop pktRx..collisionn");
- + drop(pktRx_, "COL");
- + update_watch (&loss_watch_, 1);
- + pktRx_ = p;
- + //mark the packet with error
- + ch->error() = 1;
- + collision_ = true;
- + rxTimer_.start(ch->txtime()-0.000000001);
- + }
- + else {
- + //printf ("t drop new packet..collisionn");
- + drop(p, "COL");
- + //mark the packet with error
- + HDR_CMN(pktRx_)->error() = 1;
- + collision_ = true;
- + }
- + }
- + return;
- + }
- + assert (pktRx_==NULL);
- + assert (rxTimer_.busy()==0);
- + pktRx_ = p;
- + //create a timer to wait for the end of reception
- + //since the packets are received by burst, the beginning of the new packet
- + //is the same time as the end of this packet..we process this packet 1ns
- + //earlier to make room for the new packet.
- + rxTimer_.start(ch->txtime()-0.000000001);
- +}
- +
- +/**
- + * Process the fully received packet
- + */
- +void Mac802_16::receive ()
- +{
- + assert (pktRx_);
- + struct hdr_cmn *ch = HDR_CMN(pktRx_);
- +
- +#ifdef DEBUG_WIMAX
- + printf ("At %f in Mac %d packet received (type=%s) ", NOW, index_, packet_info.name(ch->ptype()));
- + if (ch->ptype()==PT_MAC) {
- + if (HDR_MAC802_16(pktRx_)->header.ht == 0)
- + printf ("mngt=%dn", ((mac802_16_dl_map_frame*) pktRx_->accessdata())->type);
- + else
- + printf ("bwreqn");
- + } else {
- + printf ("n");
- + }
- +#endif
- +
- +
- + //drop the packet if corrupted
- + if (ch->error()) {
- + if (collision_) {
- + //printf ("t drop new pktRx..collisionn");
- + drop (pktRx_, "COL");
- + collision_ = false;
- + } else {
- + //error in the packet, the Mac does not process
- + Packet::free(pktRx_);
- + }
- + //update drop stat
- + update_watch (&loss_watch_, 1);
- + pktRx_ = NULL;
- + return;
- + }
- +
- + //process packet
- + hdr_mac802_16 *wimaxHdr = HDR_MAC802_16(pktRx_);
- + gen_mac_header_t header = wimaxHdr->header;
- + int cid = header.cid;
- + Connection *con = connectionManager_->get_connection (cid, type_==STA_BS);
- + mac802_16_dl_map_frame *frame;
- +
- + if (con == NULL) {
- + //This packet is not for us
- + //printf ("At %f in Mac %d Connection nulln", NOW, index_);
- + update_watch (&loss_watch_, 1);
- + Packet::free(pktRx_);
- + pktRx_=NULL;
- + return;
- + }
- + //printf ("CID=%dn", cid);
- +
- + //update rx time of last packet received
- + PeerNode *peer;
- + if (type_ == STA_MN)
- + peer = getPeerNode_head(); //MN only has one peer
- + else
- + peer = con->getPeerNode(); //BS can have multiple peers
- +
- + if (peer) {
- + peer->setRxTime (NOW);
- +
- + //collect receive signal strength stats
- + peer->getStatWatch()->update(10*log10(pktRx_->txinfo_.RxPr*1e3));
- + //debug ("At %f in Mac %d weighted RXThresh: %e rxp average %en", NOW, index_, macmib_.lgd_factor_*macmib_.RXThreshold_, pow(10,peer->getStatWatch()->average()/10)/1e3);
- + double avg_w = pow(10,(peer->getStatWatch()->average()/10))/1e3;
- +
- + if ( avg_w < (macmib_.lgd_factor_*macmib_.RXThreshold_)) {
- + if (!peer->isGoingDown () && type_ == STA_MN && state_==MAC802_16_CONNECTED) {
- + ((SSscheduler*) scheduler_)->send_scan_request ();
- + }
- + peer->setGoingDown (true);
- + debug ("At %f Mac %d link going down triggern", NOW, index_);
- +#ifdef USE_802_21
- + double probability = 1;
- + if(type_ == STA_MN) {
- + Mac::send_link_going_down (addr(), getPeerNode_head()->getPeerNode(), -1, (int)(100*probability), eventId_++);
- + } else {
- + Mac::send_link_going_down (peer->getPeerNode(), addr(), -1, (int)(100*probability), eventId_++);
- + }
- +#endif
- + }
- + else {
- + if (peer->isGoingDown()) {
- +#ifdef USE_802_21
- + Mac::send_link_rollback (addr(), eventId_-1);
- +#endif
- + peer->setGoingDown (false);
- + }
- + }
- + }
- +
- + //process reassembly
- + if (wimaxHdr->frag_subheader) {
- + bool drop_pkt = true;
- + //printf ("Frag type = %dn",wimaxHdr->fc & 0x3);
- + switch (wimaxHdr->fc & 0x3) {
- + case FRAG_NOFRAG:
- + if (con->getFragmentationStatus()!=FRAG_NOFRAG)
- + con->updateFragmentation (FRAG_NOFRAG, 0, 0); //reset
- + drop_pkt = false;
- + break;
- + case FRAG_FIRST:
- + //when it is the first fragment, it does not matter if we previously
- + //received other fragments, since we reset the information
- + assert (wimaxHdr->fsn == 0);
- + //printf ("tReceived first fragmentn");
- + con->updateFragmentation (FRAG_FIRST, 0, ch->size()-(HDR_MAC802_16_SIZE+HDR_MAC802_16_FRAGSUB_SIZE));
- + break;
- + case FRAG_CONT:
- + if ( (con->getFragmentationStatus()!=FRAG_FIRST
- + && con->getFragmentationStatus()!=FRAG_CONT)
- + || ((wimaxHdr->fsn&0x7) != (con->getFragmentNumber ()+1)%8) ) {
- + con->updateFragmentation (FRAG_NOFRAG, 0, 0); //reset
- + } else {
- + //printf ("tReceived cont fragmentn");
- + con->updateFragmentation (FRAG_CONT, wimaxHdr->fsn&0x7, con->getFragmentBytes()+ch->size()-(HDR_MAC802_16_SIZE+HDR_MAC802_16_FRAGSUB_SIZE));
- + }
- + break;
- + case FRAG_LAST:
- + if ( (con->getFragmentationStatus()==FRAG_FIRST
- + || con->getFragmentationStatus()==FRAG_CONT)
- + && ((wimaxHdr->fsn&0x7) == (con->getFragmentNumber ()+1)%8) ) {
- + //printf ("tReceived last fragmentn");
- + ch->size() += con->getFragmentBytes()-HDR_MAC802_16_FRAGSUB_SIZE;
- + drop_pkt = false;
- + } else {
- + //printf ("Error with last frag seq=%d (expected=%d)n", wimaxHdr->fsn&0x7, (con->getFragmentNumber ()+1)%8);
- + }
- + con->updateFragmentation (FRAG_NOFRAG, 0, 0); //reset
- + break;
- + default:
- + fprintf (stderr,"Error, unknown fragmentation typen");
- + exit (-1);
- + }
- + //if we got an error, or it is a fragment that is not the last, free the packet
- + if (drop_pkt) {
- + //update drop stat
- + update_watch (&loss_watch_, 1);
- + Packet::free(pktRx_);
- + pktRx_=NULL;
- + return;
- + }
- + }
- +
- + switch (con->getType()) {
- + case CONN_INIT_RANGING:
- + scheduler_->process (pktRx_);
- + break;
- + case CONN_AAS_INIT_RANGING:
- + break;
- + case CONN_MULTICAST_POLLING:
- + break;
- + case CONN_PADDING:
- + //padding is sent by a SS that does not have data
- + //to send is required to send a signal.
- + //TBD: Find the SS that sent the padding
- + scheduler_->process (pktRx_);
- + break;
- + case CONN_BROADCAST:
- + if (HDR_CMN(pktRx_)->ptype()==PT_MAC)
- + scheduler_->process (pktRx_);
- + else {
- + //Richard: only send to upper layer if connected
- + if (state_ == MAC802_16_CONNECTED)
- + goto send_upper;
- + else {
- + //update drop stat, could be used to detect deconnection
- + update_watch (&loss_watch_, 1);
- + Packet::free(pktRx_);
- + pktRx_=NULL;
- + return;
- + }
- + }
- + break;
- + case CONN_BASIC:
- + scheduler_->process (pktRx_);
- + break;
- + case CONN_PRIMARY:
- + assert (HDR_CMN(pktRx_)->ptype()==PT_MAC);
- + //we cast to this frame because all management frame start with a type
- + if (wimaxHdr->header.ht==1) {
- + //bw request
- + scheduler_->process (pktRx_);
- + } else {
- + frame = (mac802_16_dl_map_frame*) pktRx_->accessdata();
- + switch (frame->type) {
- + case MAC_DSA_REQ:
- + case MAC_DSA_RSP:
- + case MAC_DSA_ACK:
- + serviceFlowHandler_->process (pktRx_);
- + break;
- + default:
- + scheduler_->process (pktRx_);
- + }
- + }
- + break;
- + case CONN_SECONDARY:
- + //fall through
- + case CONN_DATA:
- + //send to upper layer
- + goto send_upper;
- + break;
- + default:
- + fprintf (stderr,"Error: unknown connection typen");
- + exit (0);
- + }
- + goto sent_mac; //default jump
- +
- + send_upper:
- + update_throughput (&rx_data_watch_, 8*ch->size());
- + update_throughput (&rx_traffic_watch_, 8*ch->size());
- + ch->size() -= HDR_MAC802_16_SIZE;
- + uptarget_->recv(pktRx_, (Handler*) 0);
- + goto done;
- +
- + sent_mac:
- + update_throughput (&rx_traffic_watch_, 8*ch->size());
- + //fall through
- +
- + //should not free it here because we don't know if other modules
- + //kept a copy of it.
- + //Packet::free(pktRx_);
- + //update Rx stat
- + done:
- + update_watch (&loss_watch_, 0);
- + pktRx_=NULL;
- +}
- +
- +/**** Helper methods ****/
- +
- +/**
- + * Return the frame number
- + * @return the frame number
- + */
- +int Mac802_16::getFrameNumber () {
- + return frame_number_;
- +}
- +
- +/*
- + * Return the code for the frame duration
- + * @return the code for the frame duration
- + */
- +int Mac802_16::getFrameDurationCode () {
- + if (macmib_.frame_duration == 0.0025)
- + return 0;
- + else if (macmib_.frame_duration == 0.004)
- + return 1;
- + else if (macmib_.frame_duration == 0.005)
- + return 2;
- + else if (macmib_.frame_duration == 0.008)
- + return 3;
- + else if (macmib_.frame_duration == 0.01)
- + return 4;
- + else if (macmib_.frame_duration == 0.0125)
- + return 5;
- + else if (macmib_.frame_duration == 0.02)
- + return 6;
- + else {
- + fprintf (stderr, "Invalid frame duration %fn", macmib_.frame_duration);
- + exit (1);
- + }
- +}
- +
- +/*
- + * Set the frame duration using code
- + * @param code The frame duration code
- + */
- +void Mac802_16::setFrameDurationCode (int code)
- +{
- + switch (code) {
- + case 0:
- + macmib_.frame_duration = 0.0025;
- + break;
- + case 1:
- + macmib_.frame_duration = 0.004;
- + break;
- + case 2:
- + macmib_.frame_duration = 0.005;
- + break;
- + case 3:
- + macmib_.frame_duration = 0.008;
- + break;
- + case 4:
- + macmib_.frame_duration = 0.01;
- + break;
- + case 5:
- + macmib_.frame_duration = 0.0125;
- + break;
- + case 6:
- + macmib_.frame_duration = 0.02;
- + break;
- + default:
- + fprintf (stderr, "Invalid frame duration code %dn", code);
- + exit (1);
- + }
- +}
- +
- +
- +/**
- + * Return a packet
- + * @return a new packet
- + */
- +Packet *Mac802_16::getPacket ()
- +{
- + Packet *p = Packet::alloc ();
- +
- + hdr_mac802_16 *wimaxHdr= HDR_MAC802_16(p);
- +
- + //set header information
- + wimaxHdr->header.ht = 0;
- + wimaxHdr->header.ec = 1;
- + wimaxHdr->header.type = 0; //no subheader
- + wimaxHdr->header.ci = 0;
- + wimaxHdr->header.eks = 0;
- + wimaxHdr->header.cid = BROADCAST_CID; //default
- + wimaxHdr->header.hcs = 0;
- + HDR_CMN(p)->ptype() = PT_MAC;
- +
- + HDR_CMN(p)->size() = HDR_MAC802_16_SIZE;
- +
- + return p;
- +}
- +
- +/**** Internal methods ****/
- +
- +
- +/*
- + * Add a classifier
- + * @param clas The classifier to add
- + */
- +void Mac802_16::addClassifier (SDUClassifier *clas)
- +{
- + SDUClassifier *n=classifier_list_.lh_first;
- + SDUClassifier *prev=NULL;
- + int i = 0;
- + if (!n || (n->getPriority () >= clas->getPriority ())) {
- + //the first element
- + //debug ("Add first classifiern");
- + clas->insert_entry_head (&classifier_list_);
- + } else {
- + while ( n && (n->getPriority () < clas->getPriority ()) ) {
- + prev=n;
- + n=n->next_entry();
- + i++;
- + }
- + //debug ("insert entry at position %dn", i);
- + clas->insert_entry (prev);
- + }
- + //Register this mac with the classifier
- + clas->setMac (this);
- +}
- +
- +#ifdef USE_802_21
- +
- +/*
- + * Configure/Request configuration
- + * The upper layer sends a config object with the required
- + * new values for the parameters (or PARAMETER_UNKNOWN_VALUE).
- + * The MAC tries to set the values and return the new setting.
- + * For examples if a MAC does not support a parameter it will
- + * return PARAMETER_UNKNOWN_VALUE
- + * @param config The configuration object
- + */
- +void Mac802_16::link_configure (link_parameter_config_t* config)
- +{
- + assert (config);
- + config->bandwidth = 15000000; //TBD use phy (but depend on modulation)
- + config->type = LINK_802_16;
- + //we set the rest to PARAMETER_UNKNOWN_VALUE
- + config->ber = PARAMETER_UNKNOWN_VALUE;
- + config->delay = PARAMETER_UNKNOWN_VALUE;
- + config->macPoA = PARAMETER_UNKNOWN_VALUE;
- +}
- +
- +/*
- + * Disconnect from the PoA
- + */
- +void Mac802_16::link_disconnect ()
- +{
- + if (type_ == STA_MN) {
- + //force losing synchronization
- + ((SSscheduler*) scheduler_)->lost_synch ();
- + getPhy()->node_off();
- + }
- +}
- +
- +/*
- + * Connect to the PoA
- + */
- +void Mac802_16::link_connect (int poa)
- +{
- + if (type_ == STA_MN) {
- + getPhy()->node_on();
- + }
- +}
- +
- +/*
- + * Configure the threshold values for the given parameters
- + * @param numLinkParameter number of parameter configured
- + * @param linkThresholds list of parameters and thresholds
- + */
- +struct link_param_th_status * Mac802_16::link_configure_thresholds (int numLinkParameter, struct link_param_th *linkThresholds)
- +{
- + struct link_param_th_status *result = (struct link_param_th_status *) malloc(numLinkParameter * sizeof (struct link_param_th_status));
- + StatWatch *watch=NULL;
- + for (int i=0 ; i < numLinkParameter ; i++) {
- + result[i].parameter = linkThresholds[i].parameter;
- + result[i].status = 1; //accepted..default
- + switch (linkThresholds[i].parameter){
- + case LINK_PACKET_LOSS:
- + watch = &loss_watch_;
- + break;
- + case LINK_PACKET_DELAY:
- + watch = &delay_watch_;
- + break;
- + case LINK_PACKET_JITTER:
- + watch = &jitter_watch_;
- + break;
- + case LINK_RX_DATA_THROUGHPUT:
- + watch = &rx_data_watch_;
- + break;
- + case LINK_RX_TRAFFIC_THROUGHPUT:
- + watch = &rx_traffic_watch_;
- + break;
- + case LINK_TX_DATA_THROUGHPUT:
- + watch = &tx_data_watch_;
- + break;
- + case LINK_TX_TRAFFIC_THROUGHPUT:
- + watch = &tx_traffic_watch_;
- + break;
- + default:
- + fprintf (stderr, "Parameter type not supported %dn", linkThresholds[i].parameter);
- + result[i].status = 0; //rejected
- + }
- + watch->set_thresholds (linkThresholds[i].initActionTh.data_d,
- + linkThresholds[i].rollbackActionTh.data_d ,
- + linkThresholds[i].exectActionTh.data_d);
- + }
- + return result;
- +}
- +
- +#endif
- +
- +/**
- + * Update the given timer and check if thresholds are crossed
- + * @param watch the stat watch to update
- + * @param value the stat value
- + */
- +void Mac802_16::update_watch (StatWatch *watch, double value)
- +{
- + char *name;
- +
- +#ifdef USE_802_21 //Switch to activate when using 802.21 modules (external package)
- + threshold_action_t action = watch->update (value);
- +
- + if (action != NO_ACTION_TH) {
- + link_parameter_t param;
- + union param_value old_value, new_value;
- +
- + if (watch == &loss_watch_) {
- + param = LINK_PACKET_LOSS;
- + } else if (watch == &delay_watch_) {
- + param = LINK_PACKET_DELAY;
- + } else if (watch == &jitter_watch_) {
- + param = LINK_PACKET_JITTER;
- + }
- + old_value.data_d = watch->old_average();
- + new_value.data_d = watch->average();
- + send_link_parameter_change (addr(), param, old_value, new_value);
- + }
- +#endif
- +
- + if (watch == &loss_watch_) {
- + name = "loss";
- + } else if (watch == &delay_watch_) {
- + name = "delay";
- + } else if (watch == &jitter_watch_) {
- + name = "jitter";
- + } else {
- + name = "other";
- + }
- + if (print_stats_)
- + printf ("At %f in Mac %d, updating stats %s: %fn", NOW, addr(), name, watch->average());
- +}
- +
- +/**
- + * Update the given timer and check if thresholds are crossed
- + * @param watch the stat watch to update
- + * @param value the stat value
- + */
- +void Mac802_16::update_throughput (ThroughputWatch *watch, double size)
- +{
- + char *name;
- +
- +#ifdef USE_802_21 //Switch to activate when using 802.21 modules (external package)
- + threshold_action_t action = watch->update (size, NOW);
- + if (action != NO_ACTION_TH) {
- + link_parameter_t param;
- + union param_value old_value, new_value;
- + if (watch == &rx_data_watch_) {
- + param = LINK_RX_DATA_THROUGHPUT;
- + } else if (watch == &rx_traffic_watch_) {
- + param = LINK_RX_TRAFFIC_THROUGHPUT;
- + } else if (watch == &tx_data_watch_) {
- + param = LINK_TX_DATA_THROUGHPUT;
- + } else if (watch == &tx_traffic_watch_) {
- + param = LINK_TX_TRAFFIC_THROUGHPUT;
- + }
- + old_value.data_d = watch->old_average();
- + new_value.data_d = watch->average();
- + send_link_parameter_change (addr(), param, old_value, new_value);
- + }
- +#endif
- +
- + if (watch == &rx_data_watch_) {
- + name = "rx_data";
- + rx_data_timer_->resched (watch->get_timer_interval());
- + } else if (watch == &rx_traffic_watch_) {
- + rx_traffic_timer_->resched (watch->get_timer_interval());
- + name = "rx_traffic";
- + } else if (watch == &tx_data_watch_) {
- + tx_data_timer_->resched (watch->get_timer_interval());
- + name = "tx_data";
- + } else if (watch == &tx_traffic_watch_) {
- + tx_traffic_timer_->resched (watch->get_timer_interval());
- + name = "tx_traffic";
- + }
- +
- + if (print_stats_)
- + printf ("At %f in Mac %d, updating stats %s: %fn", NOW, addr(), name, watch->average());
- +}
- diff -Naur ns-2.29-org/wimax/mac802_16.h ns-2.29/wimax/mac802_16.h
- --- ns-2.29-org/wimax/mac802_16.h 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/mac802_16.h 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,591 @@
- +/* This software was developed at the National Institute of Standards and
- + * Technology by employees of the Federal Government in the course of
- + * their official duties. Pursuant to title 17 Section 105 of the United
- + * States Code this software is not subject to copyright protection and
- + * is in the public domain.
- + * NIST assumes no responsibility whatsoever for its use by other parties,
- + * and makes no guarantees, expressed or implied, about its quality,
- + * reliability, or any other characteristic.
- + * <BR>
- + * We would appreciate acknowledgement if the software is used.
- + * <BR>
- + * NIST ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND
- + * DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING
- + * FROM THE USE OF THIS SOFTWARE.
- + * </PRE></P>
- + * @author rouil
- + */
- +
- +#ifndef MAC802_16_H
- +#define MAC802_16_H
- +
- +#include "sduclassifier.h"
- +#include "connectionmanager.h"
- +#include "serviceflowhandler.h"
- +#include "serviceflowqos.h"
- +#include "peernode.h"
- +#include "mac.h"
- +#include "mac802_16pkt.h"
- +#include "mac802_16timer.h"
- +
- +//Define new debug function for cleaner code
- +#ifdef DEBUG_WIMAX
- +#define debug2 printf
- +#else
- +#define debug2(arg1,...)
- +#endif
- +
- +#define BS_NOT_CONNECTED -1 //bs_id when MN is not connected
- +
- +#define DL_PREAMBLE 3 //preamble+fch
- +#define INIT_RNG_PREAMBLE 2
- +#define BW_REQ_PREAMBLE 1
- +
- +
- +/** Defines different types of nodes */
- +enum station_type_t {
- + STA_UNKNOWN,
- + STA_MN,
- + STA_BS
- +};
- +
- +/** Defines the state of the MAC */
- +enum Mac802_16State {
- + MAC802_16_DISCONNECTED,
- + MAC802_16_WAIT_DL_SYNCH,
- + MAC802_16_WAIT_DL_SYNCH_DCD,
- + MAC802_16_UL_PARAM,
- + MAC802_16_RANGING,
- + MAC802_16_WAIT_RNG_RSP,
- + MAC802_16_REGISTER,
- + MAC802_16_SCANNING,
- + MAC802_16_CONNECTED
- +};
- +
- +/** Data structure to store MAC state */
- +struct state_info {
- + Mac802_16State state;
- + int bs_id;
- + double frameduration;
- + int frame_number;
- + int channel;
- + ConnectionManager * connectionManager;
- + ServiceFlowHandler * serviceFlowHandler;
- + struct peerNode *peer_list;
- +};
- +
- +/** Defines profiles */
- +struct phyprofile {
- + int nb_channel; //number of valid channel in the array
- + int current; //index of the channel currently used
- + double freq[]; //list of channel frequencies
- +};
- +
- +/** MAC MIB */
- +class Mac802_16MIB {
- + public:
- + Mac802_16MIB (Mac802_16 *parent);
- +
- + int queue_length;
- + double frame_duration;
- +
- + double dcd_interval;
- + double ucd_interval;
- + double init_rng_interval;
- + double lost_dlmap_interval;
- + double lost_ulmap_interval;
- +
- + double t1_timeout;
- + double t2_timeout;
- + double t3_timeout;
- + double t6_timeout;
- + double t12_timeout;
- + double t16_timeout;
- + double t17_timeout;
- + double t21_timeout;
- + double t44_timeout;
- +
- + u_int32_t contention_rng_retry;
- + u_int32_t invited_rng_retry;
- + u_int32_t request_retry;
- + u_int32_t reg_req_retry;
- + double tproc;
- + u_int32_t dsx_req_retry;
- + u_int32_t dsx_rsp_retry;
- +
- + u_int32_t rng_backoff_start;
- + u_int32_t rng_backoff_stop;
- + u_int32_t bw_backoff_start;
- + u_int32_t bw_backoff_stop;
- +
- + //mobility extension
- + u_int32_t scan_duration;
- + u_int32_t interleaving;
- + u_int32_t scan_iteration;
- + u_int32_t max_dir_scan_time;
- + double nbr_adv_interval;
- + u_int32_t scan_req_retry;
- +
- + //miscalleous
- + double rxp_avg_alpha; //for measurements
- + double lgd_factor_;
- + double RXThreshold_;
- + double client_timeout; //used to clear information on BS side
- +};
- +
- +/** PHY MIB */
- +class Phy802_16MIB {
- + public:
- + Phy802_16MIB (Mac802_16 *parent);
- +
- + int channel; //current channel
- + double fbandwidth;
- + u_int32_t ttg;
- + u_int32_t rtg;
- +};
- +
- +class WimaxScheduler;
- +class FrameMap;
- +class StatTimer;
- +/**
- + * Class implementing IEEE 802_16
- + */
- +class Mac802_16 : public Mac {
- +
- + friend class PeerNode;
- + friend class SDUClassifier;
- + friend class WimaxFrameTimer;
- + friend class FrameMap;
- + friend class WimaxScheduler;
- + friend class BSScheduler;
- + friend class SSscheduler;
- + friend class ServiceFlowHandler;
- + friend class Connection;
- + friend class StatTimer;
- + public:
- +
- + Mac802_16();
- +
- + /**
- + * Return the connection manager
- + * @return the connection manager
- + */
- + inline ConnectionManager * getCManager () { return connectionManager_; }
- +
- + /**
- + * Return The Service Flow handler
- + * @return The Service Flow handler
- + */
- + inline ServiceFlowHandler * getServiceHandler () { return serviceFlowHandler_; }
- +
- + /**
- + * Return the Scheduler
- + * @return the Scheduler
- + */
- + inline WimaxScheduler * getScheduler () { return scheduler_; }
- +
- + /**
- + * Return the frame duration (in s)
- + * @return the frame duration (in s)
- + */
- + double getFrameDuration () { return macmib_.frame_duration; }
- +
- + /**
- + * Set the frame duration
- + * @param duration The frame duration (in s)
- + */
- + void setFrameDuration (double duration) { macmib_.frame_duration = duration; }
- +
- + /**
- + * Return the current frame number
- + * @return the current frame number
- + */
- + int getFrameNumber ();
- +
- + /**
- + * Add a flow
- + * @param qos The QoS required
- + * @param handler The entity that requires to add a flow
- + */
- + void addFlow (ServiceFlowQoS * qos, void * handler);
- +
- + /**
- + * Return the head of the peer nodes list
- + * @return the head of the peer nodes list
- + */
- + PeerNode * getPeerNode_head () { return peer_list_->lh_first; }
- +
- + /**
- + * Return the peer node that has the given address
- + * @param index The address of the peer
- + * @return The peer node that has the given address
- + */
- + PeerNode *getPeerNode (int index);
- +
- + /**
- + * Add the peer node
- + * @param The peer node to add
- + */
- + void addPeerNode (PeerNode *node);
- +
- + /**
- + * Remove a peer node
- + * @param The peer node to remove
- + */
- + void removePeerNode (PeerNode *node);
- +
- + /**
- + * Interface with the TCL script
- + * @param argc The number of parameter
- + * @param argv The list of parameters
- + */
- + int command(int argc, const char*const* argv);
- +
- + /**
- + * Set the mac state
- + * @param state The new mac state
- + */
- + void setMacState (Mac802_16State state);
- +
- + /**
- + * Return the mac state
- + * @return The new mac state
- + */
- + Mac802_16State getMacState ();
- +
- + /**
- + * Change the channel
- + * @param channel The new channel
- + */
- + void setChannel (int channel);
- +
- + /**
- + * Return the channel index
- + * @return The channel
- + */
- + int getChannel ();
- +
- + /**
- + * Return the channel number for the given frequency
- + * @param freq The frequency
- + * @return The channel number of -1 if the frequency does not match
- + */
- + int getChannel (double freq);
- +
- + /**
- + * Set the channel to the next from the list
- + * Used at initialisation and when loosing signal
- + */
- + void nextChannel ();
- +
- + /**
- + * Process packets going out
- + * @param p The packet to transmit
- + */
- + void sendDown(Packet *p);
- +
- + /**
- + * Process packets going out
- + * @param p The packet to transmit
- + */
- + void transmit(Packet *p);
- +
- + /**
- + * Process incoming packets
- + * @param p The received packet
- + */
- + void sendUp(Packet *p);
- +
- + /**
- + * Process the packet after receiving last bit
- + */
- + void receive();
- +
- + /**
- + * Creates a snapshot of the MAC's state and reset it
- + * @return The snapshot of the MAC's state
- + */
- + state_info *backup_state ();
- +
- + /**
- + * Restore the state of the Mac
- + * @param state The state to restore
- + */
- + void restore_state (state_info *state);
- +
- + /**
- + * Set the variable used to find out if upper layers
- + * must be notified to send packets. During scanning we
- + * do not want upper layers to send packet to the mac.
- + * @param notify Value indicating if we want to receive packets
- + * from upper layers
- + */
- + void setNotify_upper (bool notify);
- +
- + /**
- + * Return the PHY layer
- + * @return The physical layer
- + */
- + OFDMPhy* getPhy ();
- +
- + /**
- + * The MAC MIB
- + */
- + Mac802_16MIB macmib_;
- +
- + /**
- + * The Physical layer MIB
- + */
- + Phy802_16MIB phymib_;
- +
- +#ifdef USE_802_21 //Switch to activate when using 802.21 modules (external package)
- + /*
- + * Configure/Request configuration
- + * The upper layer sends a config object with the required
- + * new values for the parameters (or PARAMETER_UNKNOWN_VALUE).
- + * The MAC tries to set the values and return the new setting.
- + * For examples if a MAC does not support a parameter it will
- + * return PARAMETER_UNKNOWN_VALUE
- + * @param config The configuration object
- + */
- + void link_configure (link_parameter_config_t* config);
- +
- + /*
- + * Configure the threshold values for the given parameters
- + * @param numLinkParameter number of parameter configured
- + * @param linkThresholds list of parameters and thresholds
- + */
- + struct link_param_th_status * link_configure_thresholds (int numLinkParameter, struct link_param_th *linkThresholds); //configure threshold
- +
- + /*
- + * Disconnect from the PoA
- + */
- + void link_disconnect ();
- +
- + /*
- + * Connect to the PoA
- + * @param poa The address of PoA
- + */
- + void link_connect (int poa);
- +
- +#endif
- +
- + protected:
- + /**
- + * Initialize default connection
- + */
- + void init_default_connections ();
- +
- + /**
- + * The packet scheduler
- + */
- + WimaxScheduler * scheduler_;
- +
- + /**
- + * Return a new allocated packet
- + * @return A newly allocated packet
- + */
- + Packet * getPacket();
- +
- + /*
- + * Return the code for the frame duration
- + * @return the code for the frame duration
- + */
- + int getFrameDurationCode ();
- +
- + /*
- + * Set the frame duration using code
- + * @param code The frame duration code
- + */
- + void setFrameDurationCode (int code);
- +
- + /**
- + * Current frame number
- + */
- + int frame_number_;
- +
- + /**
- + * Statistics for queueing delay
- + */
- + StatWatch delay_watch_;
- +
- + /**
- + * Delay for last packet
- + */
- + double last_tx_delay_;
- +
- + /**
- + * Statistics for delay jitter
- + */
- + StatWatch jitter_watch_;
- +
- + /**
- + * Stats for packet loss
- + */
- + StatWatch loss_watch_;
- +
- + /**
- + * Stats for incoming data throughput
- + */
- + ThroughputWatch rx_data_watch_;
- +
- + /**
- + * Stats for incoming traffic throughput (data+management)
- + */
- + ThroughputWatch rx_traffic_watch_;
- +
- +
- + /**
- + * Stats for outgoing data throughput
- + */
- + ThroughputWatch tx_data_watch_;
- +
- + /**
- + * Stats for outgoing traffic throughput (data+management)
- + */
- + ThroughputWatch tx_traffic_watch_;
- +
- + /**
- + * Timers to continuously poll stats in case it is not updated by
- + * sending or receiving packets
- + */
- + StatTimer *rx_data_timer_;
- + StatTimer *rx_traffic_timer_;
- + StatTimer *tx_data_timer_;
- + StatTimer *tx_traffic_timer_;
- +
- + /**
- + * Indicates if the stats must be printed
- + */
- + int print_stats_;
- +
- + /**
- + * Update the given timer and check if thresholds are crossed
- + * @param watch the stat watch to update
- + * @param value the stat value
- + */
- + void update_watch (StatWatch *watch, double value);
- +
- + /**
- + * Update the given timer and check if thresholds are crossed
- + * @param watch the stat watch to update
- + * @param size the size of packet received
- + */
- + void update_throughput (ThroughputWatch *watch, double size);
- +
- +#ifdef USE_802_21 //Switch to activate when using 802.21 modules (external package)
- + /**
- + * Poll the given stat variable to check status
- + * @param type The link parameter type
- + */
- + void poll_stat (link_parameter_t type);
- +#endif
- +
- + private:
- + /**
- + * The list of classifier
- + */
- + struct sduClassifier classifier_list_;
- +
- + /**
- + * List of connected peer nodes. Only one for SSs.
- + */
- + struct peerNode *peer_list_;
- +
- + /**
- + * The class to handle connections
- + */
- + ConnectionManager * connectionManager_;
- +
- + /**
- + * The module that handles flow requests
- + */
- + ServiceFlowHandler * serviceFlowHandler_;
- +
- + /**
- + * Packet being received
- + */
- + Packet *pktRx_;
- +
- + /**
- + * A packet buffer used to temporary store a packet
- + * received by upper layer. Used during scanning
- + */
- + Packet *pktBuf_;
- +
- + /**
- + * Add a classifier
- + */
- + void addClassifier (SDUClassifier *);
- +
- + /**
- + * Set the node type
- + * @param type The station type
- + */
- + void setStationType (station_type_t type);
- +
- + /*
- + * The type of station (MN or BS)
- + */