patch-wimax-prerelease-092206
上传用户:hzie11
上传日期:2013-10-07
资源大小:1487k
文件大小:477k
- + station_type_t type_;
- +
- + /*
- + * Address of the Base Station. If STA is BS then equal index_
- + */
- + int bs_id_;
- +
- + /*
- + * The state of the MAC
- + */
- + Mac802_16State state_;
- +
- + /**
- + * Receiving timer
- + */
- + WimaxRxTimer rxTimer_;
- +
- + /**
- + * Indicates if a collision occured
- + */
- + bool collision_;
- +
- + /**
- + * Indicate if upper layer must be notified to send more packets
- + */
- + bool notify_upper_;
- +
- + /**
- + * Last time a packet was sent
- + */
- + double last_tx_time_;
- +
- + /**
- + * Last transmission duration
- + */
- + double last_tx_duration_;
- +
- +};
- +
- +/** Class to poll stats */
- +class StatTimer : public TimerHandler {
- + public:
- + StatTimer (Mac802_16 *mac, ThroughputWatch *watch) : TimerHandler() {
- + mac_ = mac;
- + watch_ = watch;
- + timer_interval_ = 0.1; //default 100ms
- + resched (timer_interval_);
- + }
- + void expire (Event *) {
- + mac_->update_throughput (watch_, 0);
- + //double tmp = watch_->get_timer_interval();
- + //resched(tmp > 0? tmp: timer_interval_);
- + }
- + inline void set_timer_interval(double ti) { timer_interval_ = ti; }
- + private:
- + Mac802_16 *mac_;
- + ThroughputWatch *watch_;
- + double timer_interval_;
- +};
- +
- +#endif //MAC802_16_H
- +
- diff -Naur ns-2.29-org/wimax/mac802_16pkt.cc ns-2.29/wimax/mac802_16pkt.cc
- --- ns-2.29-org/wimax/mac802_16pkt.cc 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/mac802_16pkt.cc 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,171 @@
- +/* This class contains helpers for manipulating 802.16 messages
- + * and getting the packet size.
- + * 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_16pkt.h"
- +
- +/**
- + * Return the size of the MOB_NBR-ADV frame
- + * @param frame The frame
- + */
- +int Mac802_16pkt::getMOB_NBR_ADV_size(mac802_16_mob_nbr_adv_frame *frame)
- +{
- + int size = 4; //min size
- + if ((frame->skip_opt_field & 0x1) == 0)
- + size +=3; //add operator id
- +
- + for (int i = 0 ; i < frame->n_neighbors ; i++) {
- + size += 4; //min size for neighbor info
- + if (frame->nbr_info[i].phy_profile_id.FAindex & 0x1)
- + size++;
- + if (frame->nbr_info[i].phy_profile_id.bs_eirp & 0x1)
- + size++;
- + if ((frame->skip_opt_field & 0x2) == 0)
- + size +=3; //contain neighbor bs id
- + if ((frame->skip_opt_field & 0x4) == 0)
- + size ++; //contain HO process optimization
- + if ((frame->skip_opt_field & 0x8) == 0)
- + size ++; //contain neighbor bs id
- + if (frame->nbr_info[i].dcd_included)
- + size += 2+GET_DCD_SIZE (frame->nbr_info[i].dcd_settings.nb_prof);
- + if (frame->nbr_info[i].ucd_included)
- + size += 2+GET_UCD_SIZE (frame->nbr_info[i].ucd_settings.nb_prof);
- + if (frame->nbr_info[i].phy_included)
- + size += 2;
- + }
- +
- + return size;
- +}
- +
- +/**
- + * Return the size of the MOB_SCN-REQ
- + * @param frame The frame
- + */
- +int Mac802_16pkt::getMOB_SCN_REQ_size(mac802_16_mob_scn_req_frame *frame)
- +{
- + int size=6;
- +
- + if (frame->n_recommended_bs_index != 0)
- + size ++;
- + int tmp = 11*(frame->n_recommended_bs_index+frame->n_recommended_bs_full);
- + size += tmp/8;
- + if ((tmp%8)!=0)
- + size ++;
- +
- + return size;
- +}
- +
- +/**
- + * Return the size of the MOB_SCN-RSP
- + * @param frame The frame
- + */
- +int Mac802_16pkt::getMOB_SCN_RSP_size(mac802_16_mob_scn_rsp_frame *frame)
- +{
- + int size=6;
- +
- + if (frame->scan_duration!=0) {
- + size += 3;
- + if (frame->n_recommended_bs_index!=0)
- + size ++;
- + int tmp = 0;
- + for (int i = 0 ; i < frame->n_recommended_bs_index ; i++) {
- + tmp+=11;
- + if (frame->rec_bs_index[i].scanning_type==2 ||
- + frame->rec_bs_index[i].scanning_type==3)
- + tmp+=24;
- + }
- + for (int i = 0 ; i < frame->n_recommended_bs_index ; i++) {
- + tmp+=51;
- + if (frame->rec_bs_index[i].scanning_type==2 ||
- + frame->rec_bs_index[i].scanning_type==3)
- + tmp+=24;
- + }
- + size += tmp/8;
- + if ((tmp%8)!=0)
- + size ++;
- + }
- +
- + return size;
- +}
- +
- +/**
- + * Return the size of the MOB_MSHO-REQ
- + * @param frame The frame
- + */
- +int Mac802_16pkt::getMOB_MSHO_REQ_size(mac802_16_mob_msho_req_frame *frame)
- +{
- + int size=4;
- + int tmp, tmpB;
- +
- + tmp = 0;
- + tmpB = 0;
- +
- + if (frame->n_new_bs_index !=0)
- + size++;
- +
- + if (frame->report_metric & 0x1) tmp++;
- + if (frame->report_metric & 0x2) tmp++;
- + if (frame->report_metric & 0x4) tmp++;
- +
- + for (int i = 0 ; i < frame->n_new_bs_index ; i++) {
- + tmpB += 20 + 8*tmp;
- + if (frame->bs_index[i].arrival_time_diff_ind & 0x1)
- + tmpB += 4;
- + }
- + //n_new_bs_full
- + for (int i = 0 ; i < frame->n_new_bs_full ; i++) {
- + tmpB += 20 + 8*tmp;
- + if (frame->bs_full[i].arrival_time_diff_ind & 0x1)
- + tmpB += 4;
- + }
- + tmpB += 4;
- + //N_current
- + if (frame->report_metric & 0x8) tmp++;
- + for (int i = 0 ; i < frame->n_current_bs ; i++) {
- + tmpB += 4 + 8*tmp;
- + }
- + //increase size
- + size += tmp/8;
- + if ((tmp%8)!=0)
- + size ++; //includes padding
- +
- + return size;
- +}
- +
- +/**
- + * Return the size of the MOB_MSHO-REQ
- + * @param frame The frame
- + */
- +int Mac802_16pkt::getMOB_BSHO_RSP_size(mac802_16_mob_bsho_rsp_frame *frame)
- +{
- + int size=4;
- +
- + return size;
- +}
- +
- +/**
- + * Return the size of the MOB_HO-IND
- + * @param frame The frame
- + */
- +int Mac802_16pkt::getMOB_HO_IND_size(mac802_16_mob_ho_ind_frame *frame)
- +{
- + int size=4;
- +
- + return size;
- +}
- diff -Naur ns-2.29-org/wimax/mac802_16pkt.h ns-2.29/wimax/mac802_16pkt.h
- --- ns-2.29-org/wimax/mac802_16pkt.h 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/mac802_16pkt.h 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,908 @@
- +/* 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_16PKT_H
- +#define MAC802_16PKT_H
- +
- +#include "packet.h"
- +#include "ofdmphy.h"
- +
- +//#define HDR_MAC802_16(p) ((hdr_mac802_16 *)hdr_mac::access(p))
- +#define HDR_MAC802_16(p) (hdr_mac802_16::access(p))
- +#define HDR_MAC802_16_SIZE 6
- +#define HDR_MAC802_16_FRAGSUB_SIZE 2
- +
- +/** Define fragmentation encoding */
- +enum fragment_status {
- + FRAG_NOFRAG = 0,
- + FRAG_LAST,
- + FRAG_FIRST,
- + FRAG_CONT
- +};
- +
- +/** Define Mac management type */
- +enum mngmt_type {
- + MAC_UCD = 0,
- + MAC_DCD,
- + MAC_DL_MAP,
- + MAC_UL_MAP,
- + MAC_RNG_REQ,
- + MAC_RNG_RSP,
- + MAC_REG_REQ,
- + MAC_REG_RSP,
- + // 8: reserved
- + // 9-10: Privacy key, not used
- + MAC_DSA_REQ=11,
- + MAC_DSA_RSP,
- + MAC_DSA_ACK,
- +
- + MAC_MOB_NBR_ADV=53,
- + MAC_MOB_SCN_REQ,
- + MAC_MOB_SCN_RSP,
- + MAC_MOB_BSHO_REQ,
- + MAC_MOB_MSHO_REQ,
- + MAC_MOB_BSHO_RSP,
- + MAC_MOB_HO_IND,
- + MAC_MOB_SCN_REP,
- + MAC_MOB_ASC_REP=66
- +};
- +
- +/** Enumeration of scanning types */
- +enum wimax_scanning_type {
- + SCAN_WITHOUT_ASSOC,
- + SCAN_ASSOC_LVL0,
- + SCAN_ASSOC_LVL1,
- + SCAN_ASSOC_LVL2
- +};
- +
- +/** Structure containing physical layer information */
- +struct phy_info_t {
- + double freq_; //the frequency at which it is sent
- + Ofdm_mod_rate modulation_; //modulation at which the packet was sent
- + double g_; //The cyclic prefix information. Used for synchronization
- +};
- +
- +/** Define generic MAC header */
- +struct gen_mac_header_t {
- + u_char ht : 1;
- + u_char ec : 1;
- + u_char type : 6;
- + u_char rsv1: 1;
- + u_char ci: 1;
- + u_char eks: 2;
- + u_char rsv2: 1;
- + u_int16_t len: 11;
- + u_int16_t cid;
- + u_char hcs;
- +};
- +
- +/** Define bandwidth request header */
- +struct bw_req_header_t {
- + u_char ht : 1;
- + u_char ec : 1;
- + u_char type : 3;
- + u_int32_t br : 19;
- + u_int16_t cid;
- + u_char hcs;
- +};
- +
- +/** Define structure for packet information */
- +struct hdr_mac802_16
- +{
- + //virtual info for physical layer
- + phy_info_t phy_info;
- +
- + //generic mac header or bw request header
- + gen_mac_header_t header;
- +
- + //check how to put the subheaders (piggyback)
- + bool frag_subheader; //set to true if there is a fragmentation subheader
- + char fc : 2; //00:no fragmentation, 01:last, 10: first, 11: middle
- + char fsn : 3; //fragmentation number
- +
- + //for management frames, we put
- + //payload in the packet payload
- + //because the size changes
- +
- + //Packet header access functions
- + static int offset_;
- + inline static int& offset() {return offset_;}
- + inline static hdr_mac802_16* access(const Packet* p)
- + {
- + return (hdr_mac802_16*) p->access(offset_);
- + }
- +};
- +
- +/**** Defines some constant for the maximum size of messages ****/
- +/* When sending a packet, the message is copied for each
- + * destination. In that case, we need to store all the information
- + * in the packet itself and not use pointer. We then use arrays.
- + */
- +#define MAX_MAP_IE 10
- +#define MAX_PROFILE 10
- +#define MAX_NBR 10
- +
- +/**** Defines IEs ****/
- +/** Defines DL_MAP IE (see p462.) */
- +struct mac802_16_dlmap_ie {
- + u_int16_t cid;
- + u_char diuc : 4; //p463
- + u_char preamble : 1;
- + u_int16_t start_time : 11;
- + //may contain extended info
- +};
- +#define DL_MAP_IE_SIZE 4
- +
- +/** fast Ranging IE (802.16e) */
- +struct mac802_16_fast_ranging_ie {
- + int mac_addr; //48 bits
- + u_char uiuc : 4;
- + u_int16_t duration : 12; //in OFDM symbols
- +};
- +#define FAST_RANGING_IE_SIZE 9
- +
- +/** Defines UL_MAP IE (see p464.) */
- +struct mac802_16_ulmap_ie {
- + u_int16_t cid;
- + u_int16_t start_time : 11;
- + u_char sub_channel_index : 5;
- + u_char uiuc : 4;
- + u_int16_t duration : 11;
- + u_char midamble_rep : 2;
- + //may contain additional info depending on uiuc
- + u_char extended_uiuc : 4;
- + u_char length : 4;
- + mac802_16_fast_ranging_ie fast_ranging;
- +};
- +#define UL_MAP_IE_SIZE 6
- +
- +/**** Defines burst profiles ****/
- +
- +/* Burst profiles are TLV encoded...we just pick the info we
- + * are interested in.
- + */
- +/** Defines DCD profile */
- +struct mac802_16_dcd_profile {
- + u_char diuc : 4;
- + u_int32_t frequency;
- + u_char fec;
- + //may have more info
- +};
- +#define DCD_PROFILE_SIZE 12
- +
- +/** Defines UCD profile */
- +struct mac802_16_ucd_profile {
- + u_char uiuc : 4;
- + u_char fec;
- + //may have more info
- +};
- +#define UCD_PROFILE_SIZE 6
- +
- +/**** Defines frames ****/
- +/** DCD frame */
- +struct mac802_16_dcd_frame {
- + u_char type;
- + u_char dcid;
- + u_char config_change_count;
- + //info for all channels: TLV encoded
- + u_char frame_duration_code;
- + u_int32_t frame_number : 24;
- + u_char ttg;
- + u_char rtg;
- + u_int32_t frequency;
- + //downlink burst profiles
- + u_int32_t nb_prof;
- + mac802_16_dcd_profile profiles[MAX_PROFILE];
- +};
- +
- +//+3 for the end of map profile
- +#define GET_DCD_SIZE(X) 22+X*DCD_PROFILE_SIZE+3
- +
- +/** DL_MAP frame */
- +struct mac802_16_dl_map_frame {
- + u_char type;
- + u_char dcd_count;
- + int bsid; //normaly 48 bits
- + //DL_MAP IEs
- + u_int32_t nb_ies;
- + mac802_16_dlmap_ie ies[MAX_MAP_IE];
- +};
- +
- +//there is X IEs
- +#define GET_DL_MAP_SIZE(X) 8+X*DL_MAP_IE_SIZE
- +
- +/** UCD frame */
- +struct mac802_16_ucd_frame {
- + u_char type;
- + u_char config_change_count;
- + u_char rng_backoff_start;
- + u_char rng_backoff_end;
- + u_char req_backoff_start;
- + u_char req_backoff_end;
- + //info for overall channel
- + /*
- + u_int16_t rsv_timeout;
- + */
- + u_int16_t bw_req_size;
- + u_int16_t rng_req_size;
- + //uplink burst profile
- + u_int32_t nb_prof;
- + mac802_16_ucd_profile profiles[MAX_PROFILE];
- +};
- +
- +//+3 for the end of map profile
- +#define GET_UCD_SIZE(X) 14+X*UCD_PROFILE_SIZE+3
- +
- +/** UL_MAP frame */
- +struct mac802_16_ul_map_frame {
- + u_char type;
- + u_char ucid;
- + u_char ucd_count;
- + u_int32_t allocation_start;
- + //UL_MAP IEs
- + u_int32_t nb_ies;
- + mac802_16_ulmap_ie ies[MAX_MAP_IE];
- +};
- +
- +#define GET_UL_MAP_SIZE(X) 7+X*UL_MAP_IE_SIZE
- +
- +/**** Defines ranging messages ****/
- +/** Ranging request frame */
- +struct mac802_16_rng_req_frame {
- + u_char type;
- + u_char dc_id;
- + /*TLV values*/
- + /* Requested Downlink Burst Profile
- + * bits 0-3: DIUC of the downlink burst profile
- + * bits 4-7: LSB of Configuration Change Count value
- + * of DCD defining the burst profile assocciated with DIUC
- + */
- + u_char req_dl_burst_profile;
- + int ss_mac_address; //should be 6 bytes
- + //u_char aas_bc_cap; //broadcast capability. optional
- +};
- +#define RNG_REQ_SIZE 13 //max value
- +
- +/** Ranging status */
- +enum ranging_status {
- + RNG_CONTINUE = 1,
- + RNG_ABORT,
- + RNG_SUCCESS,
- + RNG_RERANGE
- +};
- +
- +/** Ranging response frame */
- +struct mac802_16_rng_rsp_frame {
- + u_char type;
- + u_char uc_id;
- + /*TLV values*/
- + u_char pw_adjust;
- + u_int32_t freq_adjust;
- + u_char rng_status;
- + /* byte 0: the least robust DIUC that may be used by BS for
- + * transmissions to the SS
- + * byte 1: Configuration Change Count of DCD defining the burst profile
- + * associated with DIUC
- + */
- + u_int16_t dl_op_burst_profile;
- + int ss_mac_address; //6 bytes
- + u_int16_t basic_cid;
- + u_int16_t primary_cid;
- + u_char aas_bc_perm;
- +};
- +#define RNG_RSP_SIZE 28
- +
- +/**** Defines registration messages ****/
- +/** Registration request frame */
- +struct mac802_16_reg_req_frame {
- + u_char type;
- + /*TLV values*/
- + u_char ss_mngmt_support;
- + u_char ip_mngmt_support;
- + u_int16_t uplink_cid_support;
- +
- +};
- +#define REG_REQ_SIZE 12
- +
- +/** Registration response frame */
- +struct mac802_16_reg_rsp_frame {
- + u_char type;
- + u_char response;
- + /*TLV values*/
- + u_char ss_mngmt_support;
- + u_int16_t sec_mngmt_cid;
- +};
- +#define REG_RSP_SIZE 12
- +
- +/**** Defines Dynamic Service Addition messages ****/
- +/** DSA request frame */
- +struct mac802_16_dsa_req_frame {
- + u_char type; //11
- + u_int16_t transaction_id;
- + /*TLV values*/
- + bool uplink; //direction of the flow, normaly coded in TLV with
- + //type 145 or 146 (see p647).
- + u_int16_t cid;
- +};
- +//parameter X indicates if cid is present (i.e request from BS)
- +#define GET_DSA_REQ_SIZE(X) 6+4*X
- +
- +/** DSA response frame */
- +struct mac802_16_dsa_rsp_frame {
- + u_char type; //12
- + u_int16_t transaction_id;
- + u_char confirmation_code;
- + /*TLV values*/
- + bool uplink; //direction of the flow, normaly coded in TLV with
- + //type 145 or 146 (see p647).
- + u_int16_t cid;
- +};
- +//parameter X indicates if cid is present (i.e response from BS)
- +#define GET_DSA_RSP_SIZE(X) 6+4*X
- +
- +/** DSA Acknowledgement frame */
- +struct mac802_16_dsa_ack_frame {
- + u_char type; //13
- + u_int16_t transaction_id;
- + u_char confirmation_code;
- + /*TLV values*/
- + bool uplink; //direction of the flow, normaly coded in TLV with
- + //type 145 or 146 (see p647).
- +};
- +#define DSA_ACK_SIZE 6
- +
- +
- +/**** Defines Mobility messages (802.16e) ****/
- +/** Structure of physical profile ID */
- +struct mac802_16_phy_profile_id {
- + u_char colocatedFA: 1;
- + u_char FAconfig: 1;
- + u_char timefreq_synch: 2;
- + u_char bs_eirp: 1;
- + u_char dcducd_ref: 1;
- + u_char FAindex: 1;
- + u_char trigger_ref: 1;
- +};
- +
- +/** Structure of physical mode ID */
- +struct mac802_16_phy_mode_id {
- + u_char bandwidth: 7;
- + u_char fttsize: 3;
- + u_char cp: 2;
- + u_char duration_code: 4;
- +};
- +
- +/** Information about a neighbor BS */
- +struct mac802_16_nbr_adv_info {
- + u_char length;
- + mac802_16_phy_profile_id phy_profile_id;
- + u_char fa_index; //if FA index indicator=1 in phy_profile_id
- + u_char bs_eirp;
- + int nbr_bsid;
- + u_char preamble_index; //in OFDM, 5lsb=
- + u_char ho_process_opt;
- + u_char sched_srv_supported;
- + u_char dcd_ccc: 4;
- + u_char ucd_ccc: 4;
- + /* other TLV information */
- + bool dcd_included; //tell if the dcd is included
- + mac802_16_dcd_frame dcd_settings;
- + bool ucd_included; //tell if the ucd is included
- + mac802_16_ucd_frame ucd_settings;
- + bool phy_included; //tell if the phy mode ID is included
- + mac802_16_phy_mode_id phy_mode_id;
- +};
- +
- +/** Neighbor advertisment frame */
- +struct mac802_16_mob_nbr_adv_frame {
- + u_char type; //53
- + u_char skip_opt_field;
- + u_int32_t operatorID: 24;
- + u_char ccc;
- + u_char frag_index: 4;
- + u_char total_frag: 4;
- + u_char n_neighbors; //number of neighbors
- + mac802_16_nbr_adv_info nbr_info[MAX_NBR];
- +};
- +
- +/** Code BS using index in scan request */
- +struct mac802_16_mob_scn_req_bs_index {
- + u_char neighbor_bs_index;
- + u_char scanning_type: 3; //0: scanning without association
- + //1: scanning+assoc level 0
- + //2: scanning+assoc level 1
- + //3: scanning+assoc level 2
- + //4-7: reserved
- +};
- +
- +/** Code BS using full address in scan request */
- +struct mac802_16_mob_scn_req_bs_full {
- + int recommended_bs_id; /* 6 bytes */
- + u_char scanning_type: 3; //0: scanning without association
- + //1: scanning+assoc level 0
- + //2: scanning+assoc level 1
- + //3: scanning+assoc level 2
- + //4-7: reserved
- +};
- +
- +/** Scan request frame */
- +struct mac802_16_mob_scn_req_frame {
- + u_char type; //54
- + u_char scan_duration; //units of frames
- + u_char interleaving_interval; //units of frames
- + u_char scan_iteration; //in frame
- + u_char n_recommended_bs_index; //number of BS recommended
- + u_char ccc; //present if n_recommended_bs_index!= 0
- + mac802_16_mob_scn_req_bs_index rec_bs_index[MAX_NBR];
- + u_char n_recommended_bs_full;
- + mac802_16_mob_scn_req_bs_full rec_bs_full[MAX_NBR];
- + /* TLV info*/
- +};
- +
- +/** Code BS using index in scan response */
- +struct mac802_16_mob_scn_rsp_bs_index {
- + u_char neighbor_bs_index;
- + u_char scanning_type: 3; //0: scanning without association
- + //1: scanning+assoc level 0
- + //2: scanning+assoc level 1
- + //3: scanning+assoc level 2
- + //4-7: reserved
- + /* next present if scanning is 2 or 3*/
- + u_char rdv_time;
- + u_char cdma_code;
- + u_char transmission_opp_offset;
- +};
- +
- +/** Code BS using full address in scan response */
- +struct mac802_16_mob_scn_rsp_bs_full {
- + int recommended_bs_id; /* 6 bytes */
- + u_char scanning_type: 3; //0: scanning without association
- + //1: scanning+assoc level 0
- + //2: scanning+assoc level 1
- + //3: scanning+assoc level 2
- + //4-7: reserved
- + /* next present if scanning is 2 or 3*/
- + u_char rdv_time;
- + u_char cdma_code;
- + u_char transmission_opp_offset;
- +};
- +
- +/** Scan response frame */
- +struct mac802_16_mob_scn_rsp_frame {
- + u_char type; //55
- + u_char scan_duration; //units of frames
- + u_char report_mode: 2;
- + u_char report_period;
- + u_char report_metric;
- + /*next information present only if scan duration !=0*/
- + u_char start_frame: 4;
- + u_char interleaving_interval;
- + u_char scan_iteration;
- + u_char n_recommended_bs_index;
- + //next if n_recommended_bs_index !=0
- + u_char ccc_mob_nbr_adv;
- + mac802_16_mob_scn_rsp_bs_index rec_bs_index[MAX_NBR];
- + u_char n_recommended_bs_full;
- + mac802_16_mob_scn_rsp_bs_full rec_bs_full[MAX_NBR];
- + /* end if scan duration !=0 */
- + /* TLV information */
- +};
- +
- +/** Measurements about current BS */
- +struct mac802_16_mob_scn_rep_current_bs {
- + u_char temp_bsid: 4;
- + u_char bs_cinr_mean; //if report_metric[0]==1
- + u_char bs_rssi_mean; //if report_metric[1]==1
- + u_char relative_delay; //if report_metric[2]==1
- + u_char bs_rtd; //if report_metric[3]==1
- +};
- +
- +/** Measurements about neighbor BS using index */
- +struct mac802_16_mob_scn_rep_bs_index {
- + u_char neighbor_bs_index;
- + u_char bs_cinr_mean; //if report_metric[0]==1
- + u_char bs_rssi_mean; //if report_metric[1]==1
- + u_char relative_delay; //if report_metric[2]==1
- +};
- +
- +/** Measurements about neighbor BS using full address */
- +struct mac802_16_mob_scn_rep_bs_full {
- + int neighbor_bs_id; /* 6 bytes */
- + u_char bs_cinr_mean; //if report_metric[0]==1
- + u_char bs_rssi_mean; //if report_metric[1]==1
- + u_char relative_delay; //if report_metric[2]==1
- +};
- +
- +/** Scan report frame */
- +struct mac802_16_mob_scn_rep_frame {
- + u_char type; //60
- + u_char report_mode: 1;
- + u_char comp_nbr_bsid_ind: 1;
- + u_char n_current_bs: 3;
- + u_char report_metric: 8;
- + mac802_16_mob_scn_rep_current_bs current_bs[MAX_NBR];
- + u_char n_neighbor_bs_index;
- + //next if n_recommended_bs_index !=0
- + u_char ccc_mob_nbr_adv;
- + mac802_16_mob_scn_rep_bs_index nbr_bs_index[MAX_NBR];
- + u_char n_recommended_bs_full;
- + mac802_16_mob_scn_rep_bs_full nbr_bs_full[MAX_NBR];
- + /* other TLV information */
- +};
- +
- +/** Code BS using index in association result report */
- +struct mac802_16_mob_asc_rep_bs_index {
- + u_char neighbor_bs_index;
- + uint32_t timing_adjust;
- + u_char power_level_adjust;
- + uint32_t offset_freq_adjust;
- + u_char rng_status;
- + u_char service_level_prediction;
- +};
- +
- +/** Code BS using address in association result report */
- +struct mac802_16_mob_asc_rep_bs_full {
- + int neighbor_bs_id; /* 6 bytes */
- + uint32_t timing_adjust;
- + u_char power_level_adjust;
- + uint32_t offset_freq_adjust;
- + u_char rng_status;
- + u_char service_level_prediction;
- +};
- +
- +/** Association result report frame */
- +struct mac802_16_mob_asc_rep_frame {
- + u_char type; //66
- + u_char n_recommended_bs_index;
- + //next if n_recommended_bs_index !=0
- + u_char ccc_mob_nbr_adv;
- + mac802_16_mob_asc_rep_bs_index rec_bs_index[MAX_NBR];
- + u_char n_recommended_bs_full;
- + mac802_16_mob_asc_rep_bs_full rec_bs_full[MAX_NBR];
- +};
- +
- +/** Code request in mode 000 (HO request) */
- +struct mac802_16_mob_bsho_req_mode_000 {
- + int neighbor_bsid; /* 6 bytes */
- + u_char service_level_prediction;
- + u_char preamble_index;
- + u_char ho_process_optimization;
- + u_char net_assisted_ho_supported: 1;
- + u_char ho_id_included_indicator: 1;
- + u_char ho_autho_policy_indicator: 1;
- + //if ho_id_included_indicator==1
- + u_char ho_id;
- + //if ho_autho_policy_indicator==1
- + u_char ho_autho_policy_support;
- +};
- +
- +/** Structure for BSHO request */
- +struct mac802_16_mob_bsho_req_mode_new_bs {
- + int neighbor_bsid; /* 6 bytes */
- + u_char temp_bsid: 3;
- +
- +};
- +
- +/** Structure for BSHO request */
- +struct mac802_16_mob_bsho_req_mode_new_bs2 {
- + int neighbor_bsid; /* 6 bytes */
- + u_char temp_bsid: 3;
- + uint16_t new_cid[MAX_NBR];
- + uint16_t new_said[MAX_NBR];
- +
- +};
- +
- +/** Structure for BSHO request */
- +struct mac802_16_mob_bsho_req_mode_new_bs3 {
- + int neighbor_bsid; /* 6 bytes */
- + u_char temp_bsid: 3;
- + uint16_t new_cid[MAX_NBR];
- + uint16_t new_said[MAX_NBR];
- + int cqich_id; //variable
- + u_char feedback_channel_off: 6;
- + u_char period: 2;
- + u_char frame_offset: 3;
- + u_char duration: 3;
- + u_char mimo_permutation_feedback: 2;
- +};
- +
- +/** Structure for BSHO request */
- +struct mac802_16_mob_bsho_req_mode_current_bs {
- + u_char temp_bsid: 3;
- +};
- +
- +/** BSHO request frame */
- +struct mac802_16_mob_bsho_req_frame {
- + u_char type; //56
- + u_char net_assisted_ho_supported: 1;
- + u_char mode: 3;
- + //if mode == 0b000
- + u_char ho_op_mode: 1;
- + u_char n_recommended;
- + u_char resource_retain_flag: 1;
- + mac802_16_mob_bsho_req_mode_000 n_rec[];
- + //if mode == 0b001
- + u_char tmp_bsid: 3;
- + u_char ak_change_indicator: 1;
- + u_char n_cids;
- + uint16_t cids[MAX_NBR];
- + u_char n_saids;
- + uint16_t saids[MAX_NBR];
- +
- + //if mode == 0b010: attribute defined in mode 0b001
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- +
- + //if mode == 0b011
- + u_char n_new_bs: 3;
- + mac802_16_mob_bsho_req_mode_new_bs new_bs[MAX_NBR];
- + u_char n_current_bs: 3;
- + mac802_16_mob_bsho_req_mode_current_bs current_bs[MAX_NBR];
- + //also include the following elements defined in mode 0b001
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- + //u_char n_cids;
- + //uint16_t cids[MAX_NBR];
- + //u_char n_saids;
- + //uint16_t saids[MAX_NBR];
- +
- + //if mode == 0b100, include the following attributes (already defined)
- + //u_char n_new_bs: 3;
- + //mac802_16_mob_bsho_req_mode_new_bs new_bs[MAX_NBR];
- + //u_char n_current_bs: 3;
- + //mac802_16_mob_bsho_req_mode_current_bs current_bs[MAX_NBR];
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- +
- + //if mode == 0b101
- + //u_char n_new_bs: 3;
- + //u_char n_cids;
- + //u_char n_saids;
- + mac802_16_mob_bsho_req_mode_new_bs2 new_bs2[MAX_NBR];
- + //u_char n_current_bs: 3;
- + //mac802_16_mob_bsho_req_mode_current_bs current_bs[];
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- +
- + //if mode == 0b110
- + //u_char n_new_bs: 3;
- + //u_char n_cids;
- + //u_char n_saids;
- + mac802_16_mob_bsho_req_mode_new_bs3 new_bs3[MAX_NBR];
- + //u_char n_current_bs: 3;
- + //mac802_16_mob_bsho_req_mode_current_bs current_bs[];
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- +
- + u_char action_time: 7;
- + /* TLV information */
- +};
- +
- +/** Structure for MSHO request */
- +struct mac802_16_mob_msho_req_bs_index {
- + u_char neighbor_bs_index;
- + u_char preamble_index;
- + u_char bs_cinr_mean; //if report_metric[0]==1
- + u_char bs_rssi_mean; //if report_metric[1]==1
- + u_char relative_delay; //if report_metric[2]==1
- + u_char service_level_prediction: 3;
- + u_char arrival_time_diff_ind: 1;
- + //next if arrival_time_diff_ind==1
- + u_char arrival_time_diff: 4;
- +};
- +
- +/** Structure for MSHO request */
- +struct mac802_16_mob_msho_req_current_bs {
- + u_char temp_bsid: 4;
- + u_char bs_cinr_mean; //if report_metric[0]==1
- + u_char bs_rssi_mean; //if report_metric[1]==1
- + u_char relative_delay; //if report_metric[2]==1
- + u_char bs_rtd; //if report_metric[3]==1
- +};
- +
- +/** MSHO request frame */
- +struct mac802_16_mob_msho_req_frame {
- + u_char type; //57
- + u_char report_metric;
- + u_char n_new_bs_index;
- + //next if n_recommended_bs_index !=0
- + u_char ccc_mob_nbr_adv;
- + mac802_16_mob_msho_req_bs_index bs_index[MAX_NBR];
- + //end
- + u_char n_new_bs_full;
- + mac802_16_mob_msho_req_bs_index bs_full[MAX_NBR];
- + u_char n_current_bs;
- + mac802_16_mob_msho_req_current_bs bs_current[MAX_NBR];
- + /* other TLV information */
- +};
- +
- +/** Structure for BSHO response */
- +struct mac802_16_mob_bsho_rsp_rec {
- + int neighbor_bsid; /* 6 bytes */
- + u_char preamble_index;
- + u_char service_level_prediction;
- + u_char ho_process_optimization;
- + u_char net_assisted_ho_supported: 1;
- + u_char ho_id_included_indicator: 1;
- + //if ho_id_included_indicator==1
- + u_char ho_id;
- + //end if
- + u_char ho_autho_policy_indicator: 1;
- + //if ho_autho_policy_indicator==1
- + u_char ho_autho_policy_support;
- + //end if
- +
- +};
- +
- +/** Structure for BSHO response */
- +struct mac802_16_mob_bsho_rsp_mode_new_bs2 {
- + int neighbor_bsid; /* 6 bytes */
- + u_char temp_bsid: 3;
- + uint16_t new_cid[];
- +};
- +
- +/** BSHO response frame */
- +struct mac802_16_mob_bsho_rsp_frame {
- + u_char type; //58
- + u_char mode: 3;
- +
- + //if mode == 0b000
- + u_char ho_operation_mode: 1;
- + u_char n_recommended;
- + u_char resource_retain_flag: 1;
- + mac802_16_mob_bsho_rsp_rec n_rec[MAX_NBR];
- +
- + //if mode == 0b001
- + u_char tmp_bsid: 3;
- + u_char ak_change_indicator: 1;
- + u_char n_cids;
- + uint16_t cids[MAX_NBR];
- + u_char n_saids;
- + uint16_t saids[MAX_NBR];
- +
- + //if mode == 0b010
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- +
- + //if mode == 0b011
- + u_char n_new_bs: 3;
- + mac802_16_mob_bsho_req_mode_new_bs new_bs[MAX_NBR];
- + u_char n_current_bs: 3;
- + mac802_16_mob_bsho_req_mode_current_bs current_bs[MAX_NBR];
- + //also include the following elements defined in mode 0b001
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- + //u_char n_cids;
- + //uint16_t cids[MAX_NBR];
- + //u_char n_saids;
- + //uint16_t saids[MAX_NBR];
- +
- + //if mode == 0b100
- + //u_char n_new_bs: 3;
- + //mac802_16_mob_bsho_req_mode_new_bs new_bs[MAX_NBR]; //same struct as req
- + //u_char n_current_bs: 3;
- + //mac802_16_mob_bsho_req_mode_current_bs current_bs[MAX_NBR]; //same as req
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- +
- + //if mode == 0b101
- + //u_char n_new_bs: 3;
- + //u_char n_cids;
- + mac802_16_mob_bsho_rsp_mode_new_bs2 new_bs2[MAX_NBR];
- + //u_char n_current_bs: 3;
- + //mac802_16_mob_bsho_req_mode_current_bs current_bs[MAX_NBR];
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- +
- + //if mode == 0b110
- + //u_char n_new_bs: 3;
- + //u_char n_cids;
- + //u_char n_saids;
- + mac802_16_mob_bsho_req_mode_new_bs3 new_bs3[MAX_NBR]; //same as request
- + //u_char n_current_bs: 3;
- + //mac802_16_mob_bsho_req_mode_current_bs current_bs[MAX_NBR];
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- +
- + u_char action_time: 7;
- + /* TLV information */
- +
- +};
- +
- +/** Structure for Handover indication */
- +struct mac802_16_mob_ho_ind_bs {
- + u_char temp_bsid: 3;
- +};
- +
- +/** HO indication frame */
- +struct mac802_16_mob_ho_ind_frame {
- + u_char type; //59
- + u_char mode: 2;
- + //if mode==0b00
- + u_char ho_ind_type: 2;
- + u_char rng_param_valid_ind: 2;
- + //next valid if ho_ind_type==0b00
- + int target_bsid; /* 6 bytes */
- +
- + //if mode==0b01
- + u_char mdhofbss_ind_type: 2;
- + //next valid if mdhofbss_ind_type==0b00
- + u_char bsid: 3;
- + u_char action_time;
- + //end valid if mdhofbss_ind_type==0b00
- +
- + //if mode==0b10
- + //u_char mdhofbss_ind_type: 2;
- + //next valid if mdhofbss_ind_type==0b00
- + u_char diversity_set_included;
- + //next valid if diversity_set_included==1
- + u_char anchor_bsid: 3;
- + u_char n_bs;
- + mac802_16_mob_ho_ind_bs bs[MAX_NBR];
- + //end valid if diversity_set_included==1
- + //u_char action_time;
- + //end valid if mdhofbss_ind_type==0b00
- + u_char preamble_index;
- +
- + /* TLV information */
- +};
- +
- +/** This class contains helpers for manipulating 802.16 messages
- + * and getting the packet size
- + */
- +class Mac802_16pkt {
- + public:
- + /**
- + * Return the size of the MOB_NBR-ADV frame
- + * @param frame The frame
- + */
- + static int getMOB_NBR_ADV_size(mac802_16_mob_nbr_adv_frame *frame);
- +
- + /**
- + * Return the size of the MOB_SCN-REQ
- + * @param frame The frame
- + */
- + static int getMOB_SCN_REQ_size(mac802_16_mob_scn_req_frame *frame);
- +
- + /**
- + * Return the size of the MOB_SCN-RSP
- + * @param frame The frame
- + */
- + static int getMOB_SCN_RSP_size(mac802_16_mob_scn_rsp_frame *frame);
- +
- + /**
- + * Return the size of the MOB_MSHO-REQ
- + * @param frame The frame
- + */
- + static int getMOB_MSHO_REQ_size(mac802_16_mob_msho_req_frame *frame);
- +
- + /**
- + * Return the size of the MOB_BSHO-RSP
- + * @param frame The frame
- + */
- + static int getMOB_BSHO_RSP_size(mac802_16_mob_bsho_rsp_frame *frame);
- +
- + /**
- + * Return the size of the MOB_HO-IND
- + * @param frame The frame
- + */
- + static int getMOB_HO_IND_size(mac802_16_mob_ho_ind_frame *frame);
- +};
- +
- +
- +#endif
- diff -Naur ns-2.29-org/wimax/mac802_16pkt.h~ ns-2.29/wimax/mac802_16pkt.h~
- --- ns-2.29-org/wimax/mac802_16pkt.h~ 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/mac802_16pkt.h~ 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,908 @@
- +/* 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_16PKT_H
- +#define MAC802_16PKT_H
- +
- +#include "packet.h"
- +#include "ofdmphy.h"
- +
- +//#define HDR_MAC802_16(p) ((hdr_mac802_16 *)hdr_mac::access(p))
- +#define HDR_MAC802_16(p) (hdr_mac802_16::access(p))
- +#define HDR_MAC802_16_SIZE 6
- +#define HDR_MAC802_16_FRAGSUB_SIZE 2
- +
- +/** Define fragmentation encoding */
- +enum fragment_status {
- + FRAG_NOFRAG = 0,
- + FRAG_LAST,
- + FRAG_FIRST,
- + FRAG_CONT
- +};
- +
- +/** Define Mac management type */
- +enum mngmt_type {
- + MAC_UCD = 0,
- + MAC_DCD,
- + MAC_DL_MAP,
- + MAC_UL_MAP,
- + MAC_RNG_REQ,
- + MAC_RNG_RSP,
- + MAC_REG_REQ,
- + MAC_REG_RSP,
- + // 8: reserved
- + // 9-10: Privacy key, not used
- + MAC_DSA_REQ=11,
- + MAC_DSA_RSP,
- + MAC_DSA_ACK,
- +
- + MAC_MOB_NBR_ADV=53,
- + MAC_MOB_SCN_REQ,
- + MAC_MOB_SCN_RSP,
- + MAC_MOB_BSHO_REQ,
- + MAC_MOB_MSHO_REQ,
- + MAC_MOB_BSHO_RSP,
- + MAC_MOB_HO_IND,
- + MAC_MOB_SCN_REP,
- + MAC_MOB_ASC_REP=66
- +};
- +
- +/** Enumeration of scanning types */
- +enum wimax_scanning_type {
- + SCAN_WITHOUT_ASSOC,
- + SCAN_ASSOC_LVL0,
- + SCAN_ASSOC_LVL1,
- + SCAN_ASSOC_LVL2
- +};
- +
- +/** Structure containing physical layer information */
- +struct phy_info_t {
- + double freq_; //the frequency at which it is sent
- + Ofdm_mod_rate modulation_; //modulation at which the packet was sent
- + double g_; //The cyclic prefix information. Used for synchronization
- +};
- +
- +/** Define generic MAC header */
- +struct gen_mac_header_t {
- + u_char ht : 1;
- + u_char ec : 1;
- + u_char type : 6;
- + u_char rsv1: 1;
- + u_char ci: 1;
- + u_char eks: 2;
- + u_char rsv2: 1;
- + u_int16_t len: 11;
- + u_int16_t cid;
- + u_char hcs;
- +};
- +
- +/** Define bandwidth request header */
- +struct bw_req_header_t {
- + u_char ht : 1;
- + u_char ec : 1;
- + u_char type : 3;
- + u_int32_t br : 19;
- + u_int16_t cid;
- + u_char hcs;
- +};
- +
- +/** Define structure for packet information */
- +struct hdr_mac802_16
- +{
- + //virtual info for physical layer
- + phy_info_t phy_info;
- +
- + //generic mac header or bw request header
- + gen_mac_header_t header;
- +
- + //check how to put the subheaders (piggyback)
- + bool frag_subheader; //set to true if there is a fragmentation subheader
- + char fc : 2; //00:no fragmentation, 01:last, 10: first, 11: middle
- + char fsn : 3; //fragmentation number
- +
- + //for management frames, we put
- + //payload in the packet payload
- + //because the size changes
- +
- + //Packet header access functions
- + static int offset_;
- + inline static int& offset() {return offset_;}
- + inline static hdr_mac802_16* access(const Packet* p)
- + {
- + return (hdr_mac802_16*) p->access(offset_);
- + }
- +};
- +
- +/**** Defines some constant for the maximum size of messages ****/
- +/* When sending a packet, the message is copied for each
- + * destination. In that case, we need to store all the information
- + * in the packet itself and not use pointer. We then use arrays.
- + */
- +#define MAX_MAP_IE 10
- +#define MAX_PROFILE 10
- +#define MAX_NBR 10
- +
- +/**** Defines IEs ****/
- +/** Defines DL_MAP IE (see p462.) */
- +struct mac802_16_dlmap_ie {
- + u_int16_t cid;
- + u_char diuc : 4; //p463
- + u_char preamble : 1;
- + u_int16_t start_time : 11;
- + //may contain extended info
- +};
- +#define DL_MAP_IE_SIZE 4
- +
- +/** fast Ranging IE (802.16e) */
- +struct mac802_16_fast_ranging_ie {
- + int mac_addr; //48 bits
- + u_char uiuc : 4;
- + u_int16_t duration : 12; //in OFDM symbols
- +};
- +#define FAST_RANGING_IE_SIZE 9
- +
- +/** Defines UL_MAP IE (see p464.) */
- +struct mac802_16_ulmap_ie {
- + u_int16_t cid;
- + u_int16_t start_time : 11;
- + u_char sub_channel_index : 5;
- + u_char uiuc : 4;
- + u_int16_t duration : 11;
- + u_char midamble_rep : 2;
- + //may contain additional info depending on uiuc
- + u_char extended_uiuc : 4;
- + u_char length : 4;
- + mac802_16_fast_ranging_ie fast_ranging;
- +};
- +#define UL_MAP_IE_SIZE 6
- +
- +/**** Defines burst profiles ****/
- +
- +/* Burst profiles are TLV encoded...we just pick the info we
- + * are interested in.
- + */
- +/** Defines DCD profile */
- +struct mac802_16_dcd_profile {
- + u_char diuc : 4;
- + u_int32_t frequency;
- + u_char fec;
- + //may have more info
- +};
- +#define DCD_PROFILE_SIZE 12
- +
- +/** Defines UCD profile */
- +struct mac802_16_ucd_profile {
- + u_char uiuc : 4;
- + u_char fec;
- + //may have more info
- +};
- +#define UCD_PROFILE_SIZE 6
- +
- +/**** Defines frames ****/
- +/** DCD frame */
- +struct mac802_16_dcd_frame {
- + u_char type;
- + u_char dcid;
- + u_char config_change_count;
- + //info for all channels: TLV encoded
- + u_char frame_duration_code;
- + u_int32_t frame_number : 24;
- + u_char ttg;
- + u_char rtg;
- + u_int32_t frequency;
- + //downlink burst profiles
- + u_int32_t nb_prof;
- + mac802_16_dcd_profile profiles[MAX_PROFILE];
- +};
- +
- +//+3 for the end of map profile
- +#define GET_DCD_SIZE(X) 22+X*DCD_PROFILE_SIZE+3
- +
- +/** DL_MAP frame */
- +struct mac802_16_dl_map_frame {
- + u_char type;
- + u_char dcd_count;
- + int bsid; //normaly 48 bits
- + //DL_MAP IEs
- + u_int32_t nb_ies;
- + mac802_16_dlmap_ie ies[MAX_MAP_IE];
- +};
- +
- +//there is X IEs
- +#define GET_DL_MAP_SIZE(X) 8+X*DL_MAP_IE_SIZE
- +
- +/** UCD frame */
- +struct mac802_16_ucd_frame {
- + u_char type;
- + u_char config_change_count;
- + u_char rng_backoff_start;
- + u_char rng_backoff_end;
- + u_char req_backoff_start;
- + u_char req_backoff_end;
- + //info for overall channel
- + /*
- + u_int16_t rsv_timeout;
- + */
- + u_int16_t bw_req_size;
- + u_int16_t rng_req_size;
- + //uplink burst profile
- + u_int32_t nb_prof;
- + mac802_16_ucd_profile profiles[MAX_PROFILE];
- +};
- +
- +//+3 for the end of map profile
- +#define GET_UCD_SIZE(X) 14+X*UCD_PROFILE_SIZE+3
- +
- +/** UL_MAP frame */
- +struct mac802_16_ul_map_frame {
- + u_char type;
- + u_char ucid;
- + u_char ucd_count;
- + u_int32_t allocation_start;
- + //UL_MAP IEs
- + u_int32_t nb_ies;
- + mac802_16_ulmap_ie ies[MAX_MAP_IE];
- +};
- +
- +#define GET_UL_MAP_SIZE(X) 7+X*UL_MAP_IE_SIZE
- +
- +/**** Defines ranging messages ****/
- +/** Ranging request frame */
- +struct mac802_16_rng_req_frame {
- + u_char type;
- + u_char dc_id;
- + /*TLV values*/
- + /* Requested Downlink Burst Profile
- + * bits 0-3: DIUC of the downlink burst profile
- + * bits 4-7: LSB of Configuration Change Count value
- + * of DCD defining the burst profile assocciated with DIUC
- + */
- + u_char req_dl_burst_profile;
- + int ss_mac_address; //should be 6 bytes
- + //u_char aas_bc_cap; //broadcast capability. optional
- +};
- +#define RNG_REQ_SIZE 13 //max value
- +
- +/** Ranging status */
- +enum ranging_status {
- + RNG_CONTINUE = 1,
- + RNG_ABORT,
- + RNG_SUCCESS,
- + RNG_RERANGE
- +};
- +
- +/** Ranging response frame */
- +struct mac802_16_rng_rsp_frame {
- + u_char type;
- + u_char uc_id;
- + /*TLV values*/
- + u_char pw_adjust;
- + u_int32_t freq_adjust;
- + u_char rng_status;
- + /* byte 0: the least robust DIUC that may be used by BS for
- + * transmissions to the SS
- + * byte 1: Configuration Change Count of DCD defining the burst profile
- + * associated with DIUC
- + */
- + u_int16_t dl_op_burst_profile;
- + int ss_mac_address; //6 bytes
- + u_int16_t basic_cid;
- + u_int16_t primary_cid;
- + u_char aas_bc_perm;
- +};
- +#define RNG_RSP_SIZE 28
- +
- +/**** Defines registration messages ****/
- +/** Registration request frame */
- +struct mac802_16_reg_req_frame {
- + u_char type;
- + /*TLV values*/
- + u_char ss_mngmt_support;
- + u_char ip_mngmt_support;
- + u_int16_t uplink_cid_support;
- +
- +};
- +#define REG_REQ_SIZE 12
- +
- +/** Registration response frame */
- +struct mac802_16_reg_rsp_frame {
- + u_char type;
- + u_char response;
- + /*TLV values*/
- + u_char ss_mngmt_support;
- + u_int16_t sec_mngmt_cid;
- +};
- +#define REG_RSP_SIZE 12
- +
- +/**** Defines Dynamic Service Addition messages ****/
- +/** DSA request frame */
- +struct mac802_16_dsa_req_frame {
- + u_char type; //11
- + u_int16_t transaction_id;
- + /*TLV values*/
- + bool uplink; //direction of the flow, normaly coded in TLV with
- + //type 145 or 146 (see p647).
- + u_int16_t cid;
- +};
- +//parameter X indicates if cid is present (i.e request from BS)
- +#define GET_DSA_REQ_SIZE(X) 6+4*X
- +
- +/** DSA response frame */
- +struct mac802_16_dsa_rsp_frame {
- + u_char type; //12
- + u_int16_t transaction_id;
- + u_char confirmation_code;
- + /*TLV values*/
- + bool uplink; //direction of the flow, normaly coded in TLV with
- + //type 145 or 146 (see p647).
- + u_int16_t cid;
- +};
- +//parameter X indicates if cid is present (i.e response from BS)
- +#define GET_DSA_RSP_SIZE(X) 6+4*X
- +
- +/** DSA Acknowledgement frame */
- +struct mac802_16_dsa_ack_frame {
- + u_char type; //13
- + u_int16_t transaction_id;
- + u_char confirmation_code;
- + /*TLV values*/
- + bool uplink; //direction of the flow, normaly coded in TLV with
- + //type 145 or 146 (see p647).
- +};
- +#define DSA_ACK_SIZE 6
- +
- +
- +/**** Defines Mobility messages (802.16e) ****/
- +/** Structure of physical profile ID */
- +struct mac802_16_phy_profile_id {
- + u_char colocatedFA: 1;
- + u_char FAconfig: 1;
- + u_char timefreq_synch: 2;
- + u_char bs_eirp: 1;
- + u_char dcducd_ref: 1;
- + u_char FAindex: 1;
- + u_char trigger_ref: 1;
- +};
- +
- +/** Structure of physical mode ID */
- +struct mac802_16_phy_mode_id {
- + u_char bandwidth: 7;
- + u_char fttsize: 3;
- + u_char cp: 2;
- + u_char duration_code: 4;
- +};
- +
- +/** Information about a neighbor BS */
- +struct mac802_16_nbr_adv_info {
- + u_char length;
- + mac802_16_phy_profile_id phy_profile_id;
- + u_char fa_index; //if FA index indicator=1 in phy_profile_id
- + u_char bs_eirp;
- + int nbr_bsid;
- + u_char preamble_index; //in OFDM, 5lsb=
- + u_char ho_process_opt;
- + u_char sched_srv_supported;
- + u_char dcd_ccc: 4;
- + u_char ucd_ccc: 4;
- + /* other TLV information */
- + bool dcd_included; //tell if the dcd is included
- + mac802_16_dcd_frame dcd_settings;
- + bool ucd_included; //tell if the ucd is included
- + mac802_16_ucd_frame ucd_settings;
- + bool phy_included; //tell if the phy mode ID is included
- + mac802_16_phy_mode_id phy_mode_id;
- +};
- +
- +/** Neighbor advertisment frame */
- +struct mac802_16_mob_nbr_adv_frame {
- + u_char type; //53
- + u_char skip_opt_field;
- + u_int32_t operatorID: 24;
- + u_char ccc;
- + u_char frag_index: 4;
- + u_char total_frag: 4;
- + u_char n_neighbors; //number of neighbors
- + mac802_16_nbr_adv_info nbr_info[MAX_NBR];
- +};
- +
- +/** Code BS using index in scan request */
- +struct mac802_16_mob_scn_req_bs_index {
- + u_char neighbor_bs_index;
- + u_char scanning_type: 3; //0: scanning without association
- + //1: scanning+assoc level 0
- + //2: scanning+assoc level 1
- + //3: scanning+assoc level 2
- + //4-7: reserved
- +};
- +
- +/** Code BS using full address in scan request */
- +struct mac802_16_mob_scn_req_bs_full {
- + int recommended_bs_id; /* 6 bytes */
- + u_char scanning_type: 3; //0: scanning without association
- + //1: scanning+assoc level 0
- + //2: scanning+assoc level 1
- + //3: scanning+assoc level 2
- + //4-7: reserved
- +};
- +
- +/** Scan request frame */
- +struct mac802_16_mob_scn_req_frame {
- + u_char type; //54
- + u_char scan_duration; //units of frames
- + u_char interleaving_interval; //units of frames
- + u_char scan_iteration; //in frame
- + u_char n_recommended_bs_index; //number of BS recommended
- + u_char ccc; //present if n_recommended_bs_index!= 0
- + mac802_16_mob_scn_req_bs_index rec_bs_index[MAX_NBR];
- + u_char n_recommended_bs_full;
- + mac802_16_mob_scn_req_bs_full rec_bs_full[MAX_NBR];
- + /* TLV info*/
- +};
- +
- +/** Code BS using index in scan response */
- +struct mac802_16_mob_scn_rsp_bs_index {
- + u_char neighbor_bs_index;
- + u_char scanning_type: 3; //0: scanning without association
- + //1: scanning+assoc level 0
- + //2: scanning+assoc level 1
- + //3: scanning+assoc level 2
- + //4-7: reserved
- + /* next present if scanning is 2 or 3*/
- + u_char rdv_time;
- + u_char cdma_code;
- + u_char transmission_opp_offset;
- +};
- +
- +/** Code BS using full address in scan response */
- +struct mac802_16_mob_scn_rsp_bs_full {
- + int recommended_bs_id; /* 6 bytes */
- + u_char scanning_type: 3; //0: scanning without association
- + //1: scanning+assoc level 0
- + //2: scanning+assoc level 1
- + //3: scanning+assoc level 2
- + //4-7: reserved
- + /* next present if scanning is 2 or 3*/
- + u_char rdv_time;
- + u_char cdma_code;
- + u_char transmission_opp_offset;
- +};
- +
- +/** Scan response frame */
- +struct mac802_16_mob_scn_rsp_frame {
- + u_char type; //55
- + u_char scan_duration; //units of frames
- + u_char report_mode: 2;
- + u_char report_period;
- + u_char report_metric;
- + /*next information present only if scan duration !=0*/
- + u_char start_frame: 4;
- + u_char interleaving_interval;
- + u_char scan_iteration;
- + u_char n_recommended_bs_index;
- + //next if n_recommended_bs_index !=0
- + u_char ccc_mob_nbr_adv;
- + mac802_16_mob_scn_rsp_bs_index rec_bs_index[MAX_NBR];
- + u_char n_recommended_bs_full;
- + mac802_16_mob_scn_rsp_bs_full rec_bs_full[MAX_NBR];
- + /* end if scan duration !=0 */
- + /* TLV information */
- +};
- +
- +/** Measurements about current BS */
- +struct mac802_16_mob_scn_rep_current_bs {
- + u_char temp_bsid: 4;
- + u_char bs_cinr_mean; //if report_metric[0]==1
- + u_char bs_rssi_mean; //if report_metric[1]==1
- + u_char relative_delay; //if report_metric[2]==1
- + u_char bs_rtd; //if report_metric[3]==1
- +};
- +
- +/** Measurements about neighbor BS using index */
- +struct mac802_16_mob_scn_rep_bs_index {
- + u_char neighbor_bs_index;
- + u_char bs_cinr_mean; //if report_metric[0]==1
- + u_char bs_rssi_mean; //if report_metric[1]==1
- + u_char relative_delay; //if report_metric[2]==1
- +};
- +
- +/** Measurements about neighbor BS using full address */
- +struct mac802_16_mob_scn_rep_bs_full {
- + int neighbor_bs_id; /* 6 bytes */
- + u_char bs_cinr_mean; //if report_metric[0]==1
- + u_char bs_rssi_mean; //if report_metric[1]==1
- + u_char relative_delay; //if report_metric[2]==1
- +};
- +
- +/** Scan report frame */
- +struct mac802_16_mob_scn_rep_frame {
- + u_char type; //60
- + u_char report_mode: 1;
- + u_char comp_nbr_bsid_ind: 1;
- + u_char n_current_bs: 3;
- + u_char report_metric: 8;
- + mac802_16_mob_scn_res_current_bs current_bs[MAX_NBR];
- + u_char n_neighbor_bs_index;
- + //next if n_recommended_bs_index !=0
- + u_char ccc_mob_nbr_adv;
- + mac802_16_mob_scn_rep_bs_index nbr_bs_index[MAX_NBR];
- + u_char n_recommended_bs_full;
- + mac802_16_mob_scn_rep_bs_full nbr_bs_full[MAX_NBR];
- + /* other TLV information */
- +};
- +
- +/** Code BS using index in association result report */
- +struct mac802_16_mob_asc_rep_bs_index {
- + u_char neighbor_bs_index;
- + uint32_t timing_adjust;
- + u_char power_level_adjust;
- + uint32_t offset_freq_adjust;
- + u_char rng_status;
- + u_char service_level_prediction;
- +};
- +
- +/** Code BS using address in association result report */
- +struct mac802_16_mob_asc_rep_bs_full {
- + int neighbor_bs_id; /* 6 bytes */
- + uint32_t timing_adjust;
- + u_char power_level_adjust;
- + uint32_t offset_freq_adjust;
- + u_char rng_status;
- + u_char service_level_prediction;
- +};
- +
- +/** Association result report frame */
- +struct mac802_16_mob_asc_rep_frame {
- + u_char type; //66
- + u_char n_recommended_bs_index;
- + //next if n_recommended_bs_index !=0
- + u_char ccc_mob_nbr_adv;
- + mac802_16_mob_asc_rep_bs_index rec_bs_index[MAX_NBR];
- + u_char n_recommended_bs_full;
- + mac802_16_mob_asc_rep_bs_full rec_bs_full[MAX_NBR];
- +};
- +
- +/** Code request in mode 000 (HO request) */
- +struct mac802_16_mob_bsho_req_mode_000 {
- + int neighbor_bsid; /* 6 bytes */
- + u_char service_level_prediction;
- + u_char preamble_index;
- + u_char ho_process_optimization;
- + u_char net_assisted_ho_supported: 1;
- + u_char ho_id_included_indicator: 1;
- + u_char ho_autho_policy_indicator: 1;
- + //if ho_id_included_indicator==1
- + u_char ho_id;
- + //if ho_autho_policy_indicator==1
- + u_char ho_autho_policy_support;
- +};
- +
- +/** Structure for BSHO request */
- +struct mac802_16_mob_bsho_req_mode_new_bs {
- + int neighbor_bsid; /* 6 bytes */
- + u_char temp_bsid: 3;
- +
- +};
- +
- +/** Structure for BSHO request */
- +struct mac802_16_mob_bsho_req_mode_new_bs2 {
- + int neighbor_bsid; /* 6 bytes */
- + u_char temp_bsid: 3;
- + uint16_t new_cid[MAX_NBR];
- + uint16_t new_said[MAX_NBR];
- +
- +};
- +
- +/** Structure for BSHO request */
- +struct mac802_16_mob_bsho_req_mode_new_bs3 {
- + int neighbor_bsid; /* 6 bytes */
- + u_char temp_bsid: 3;
- + uint16_t new_cid[MAX_NBR];
- + uint16_t new_said[MAX_NBR];
- + int cqich_id; //variable
- + u_char feedback_channel_off: 6;
- + u_char period: 2;
- + u_char frame_offset: 3;
- + u_char duration: 3;
- + u_char mimo_permutation_feedback: 2;
- +};
- +
- +/** Structure for BSHO request */
- +struct mac802_16_mob_bsho_req_mode_current_bs {
- + u_char temp_bsid: 3;
- +};
- +
- +/** BSHO request frame */
- +struct mac802_16_mob_bsho_req_frame {
- + u_char type; //56
- + u_char net_assisted_ho_supported: 1;
- + u_char mode: 3;
- + //if mode == 0b000
- + u_char ho_op_mode: 1;
- + u_char n_recommended;
- + u_char resource_retain_flag: 1;
- + mac802_16_mob_bsho_req_mode_000 n_rec[];
- + //if mode == 0b001
- + u_char tmp_bsid: 3;
- + u_char ak_change_indicator: 1;
- + u_char n_cids;
- + uint16_t cids[MAX_NBR];
- + u_char n_saids;
- + uint16_t saids[MAX_NBR];
- +
- + //if mode == 0b010: attribute defined in mode 0b001
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- +
- + //if mode == 0b011
- + u_char n_new_bs: 3;
- + mac802_16_mob_bsho_req_mode_new_bs new_bs[MAX_NBR];
- + u_char n_current_bs: 3;
- + mac802_16_mob_bsho_req_mode_current_bs current_bs[MAX_NBR];
- + //also include the following elements defined in mode 0b001
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- + //u_char n_cids;
- + //uint16_t cids[MAX_NBR];
- + //u_char n_saids;
- + //uint16_t saids[MAX_NBR];
- +
- + //if mode == 0b100, include the following attributes (already defined)
- + //u_char n_new_bs: 3;
- + //mac802_16_mob_bsho_req_mode_new_bs new_bs[MAX_NBR];
- + //u_char n_current_bs: 3;
- + //mac802_16_mob_bsho_req_mode_current_bs current_bs[MAX_NBR];
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- +
- + //if mode == 0b101
- + //u_char n_new_bs: 3;
- + //u_char n_cids;
- + //u_char n_saids;
- + mac802_16_mob_bsho_req_mode_new_bs2 new_bs2[MAX_NBR];
- + //u_char n_current_bs: 3;
- + //mac802_16_mob_bsho_req_mode_current_bs current_bs[];
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- +
- + //if mode == 0b110
- + //u_char n_new_bs: 3;
- + //u_char n_cids;
- + //u_char n_saids;
- + mac802_16_mob_bsho_req_mode_new_bs3 new_bs3[MAX_NBR];
- + //u_char n_current_bs: 3;
- + //mac802_16_mob_bsho_req_mode_current_bs current_bs[];
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- +
- + u_char action_time: 7;
- + /* TLV information */
- +};
- +
- +/** Structure for MSHO request */
- +struct mac802_16_mob_msho_req_bs_index {
- + u_char neighbor_bs_index;
- + u_char preamble_index;
- + u_char bs_cinr_mean; //if report_metric[0]==1
- + u_char bs_rssi_mean; //if report_metric[1]==1
- + u_char relative_delay; //if report_metric[2]==1
- + u_char service_level_prediction: 3;
- + u_char arrival_time_diff_ind: 1;
- + //next if arrival_time_diff_ind==1
- + u_char arrival_time_diff: 4;
- +};
- +
- +/** Structure for MSHO request */
- +struct mac802_16_mob_msho_req_current_bs {
- + u_char temp_bsid: 4;
- + u_char bs_cinr_mean; //if report_metric[0]==1
- + u_char bs_rssi_mean; //if report_metric[1]==1
- + u_char relative_delay; //if report_metric[2]==1
- + u_char bs_rtd; //if report_metric[3]==1
- +};
- +
- +/** MSHO request frame */
- +struct mac802_16_mob_msho_req_frame {
- + u_char type; //57
- + u_char report_metric;
- + u_char n_new_bs_index;
- + //next if n_recommended_bs_index !=0
- + u_char ccc_mob_nbr_adv;
- + mac802_16_mob_msho_req_bs_index bs_index[MAX_NBR];
- + //end
- + u_char n_new_bs_full;
- + mac802_16_mob_msho_req_bs_index bs_full[MAX_NBR];
- + u_char n_current_bs;
- + mac802_16_mob_msho_req_current_bs bs_current[MAX_NBR];
- + /* other TLV information */
- +};
- +
- +/** Structure for BSHO response */
- +struct mac802_16_mob_bsho_rsp_rec {
- + int neighbor_bsid; /* 6 bytes */
- + u_char preamble_index;
- + u_char service_level_prediction;
- + u_char ho_process_optimization;
- + u_char net_assisted_ho_supported: 1;
- + u_char ho_id_included_indicator: 1;
- + //if ho_id_included_indicator==1
- + u_char ho_id;
- + //end if
- + u_char ho_autho_policy_indicator: 1;
- + //if ho_autho_policy_indicator==1
- + u_char ho_autho_policy_support;
- + //end if
- +
- +};
- +
- +/** Structure for BSHO response */
- +struct mac802_16_mob_bsho_rsp_mode_new_bs2 {
- + int neighbor_bsid; /* 6 bytes */
- + u_char temp_bsid: 3;
- + uint16_t new_cid[];
- +};
- +
- +/** BSHO response frame */
- +struct mac802_16_mob_bsho_rsp_frame {
- + u_char type; //58
- + u_char mode: 3;
- +
- + //if mode == 0b000
- + u_char ho_operation_mode: 1;
- + u_char n_recommended;
- + u_char resource_retain_flag: 1;
- + mac802_16_mob_bsho_rsp_rec n_rec[MAX_NBR];
- +
- + //if mode == 0b001
- + u_char tmp_bsid: 3;
- + u_char ak_change_indicator: 1;
- + u_char n_cids;
- + uint16_t cids[MAX_NBR];
- + u_char n_saids;
- + uint16_t saids[MAX_NBR];
- +
- + //if mode == 0b010
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- +
- + //if mode == 0b011
- + u_char n_new_bs: 3;
- + mac802_16_mob_bsho_req_mode_new_bs new_bs[MAX_NBR];
- + u_char n_current_bs: 3;
- + mac802_16_mob_bsho_req_mode_current_bs current_bs[MAX_NBR];
- + //also include the following elements defined in mode 0b001
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- + //u_char n_cids;
- + //uint16_t cids[MAX_NBR];
- + //u_char n_saids;
- + //uint16_t saids[MAX_NBR];
- +
- + //if mode == 0b100
- + //u_char n_new_bs: 3;
- + //mac802_16_mob_bsho_req_mode_new_bs new_bs[MAX_NBR]; //same struct as req
- + //u_char n_current_bs: 3;
- + //mac802_16_mob_bsho_req_mode_current_bs current_bs[MAX_NBR]; //same as req
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- +
- + //if mode == 0b101
- + //u_char n_new_bs: 3;
- + //u_char n_cids;
- + mac802_16_mob_bsho_rsp_mode_new_bs2 new_bs2[MAX_NBR];
- + //u_char n_current_bs: 3;
- + //mac802_16_mob_bsho_req_mode_current_bs current_bs[MAX_NBR];
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- +
- + //if mode == 0b110
- + //u_char n_new_bs: 3;
- + //u_char n_cids;
- + //u_char n_saids;
- + mac802_16_mob_bsho_req_mode_new_bs3 new_bs3[MAX_NBR]; //same as request
- + //u_char n_current_bs: 3;
- + //mac802_16_mob_bsho_req_mode_current_bs current_bs[MAX_NBR];
- + //u_char tmp_bsid: 3;
- + //u_char ak_change_indicator: 1;
- +
- + u_char action_time: 7;
- + /* TLV information */
- +
- +};
- +
- +/** Structure for Handover indication */
- +struct mac802_16_mob_ho_ind_bs {
- + u_char temp_bsid: 3;
- +};
- +
- +/** HO indication frame */
- +struct mac802_16_mob_ho_ind_frame {
- + u_char type; //59
- + u_char mode: 2;
- + //if mode==0b00
- + u_char ho_ind_type: 2;
- + u_char rng_param_valid_ind: 2;
- + //next valid if ho_ind_type==0b00
- + int target_bsid; /* 6 bytes */
- +
- + //if mode==0b01
- + u_char mdhofbss_ind_type: 2;
- + //next valid if mdhofbss_ind_type==0b00
- + u_char bsid: 3;
- + u_char action_time;
- + //end valid if mdhofbss_ind_type==0b00
- +
- + //if mode==0b10
- + //u_char mdhofbss_ind_type: 2;
- + //next valid if mdhofbss_ind_type==0b00
- + u_char diversity_set_included;
- + //next valid if diversity_set_included==1
- + u_char anchor_bsid: 3;
- + u_char n_bs;
- + mac802_16_mob_ho_ind_bs bs[MAX_NBR];
- + //end valid if diversity_set_included==1
- + //u_char action_time;
- + //end valid if mdhofbss_ind_type==0b00
- + u_char preamble_index;
- +
- + /* TLV information */
- +};
- +
- +/** This class contains helpers for manipulating 802.16 messages
- + * and getting the packet size
- + */
- +class Mac802_16pkt {
- + public:
- + /**
- + * Return the size of the MOB_NBR-ADV frame
- + * @param frame The frame
- + */
- + static int getMOB_NBR_ADV_size(mac802_16_mob_nbr_adv_frame *frame);
- +
- + /**
- + * Return the size of the MOB_SCN-REQ
- + * @param frame The frame
- + */
- + static int getMOB_SCN_REQ_size(mac802_16_mob_scn_req_frame *frame);
- +
- + /**
- + * Return the size of the MOB_SCN-RSP
- + * @param frame The frame
- + */
- + static int getMOB_SCN_RSP_size(mac802_16_mob_scn_rsp_frame *frame);
- +
- + /**
- + * Return the size of the MOB_MSHO-REQ
- + * @param frame The frame
- + */
- + static int getMOB_MSHO_REQ_size(mac802_16_mob_msho_req_frame *frame);
- +
- + /**
- + * Return the size of the MOB_BSHO-RSP
- + * @param frame The frame
- + */
- + static int getMOB_BSHO_RSP_size(mac802_16_mob_bsho_rsp_frame *frame);
- +
- + /**
- + * Return the size of the MOB_HO-IND
- + * @param frame The frame
- + */
- + static int getMOB_HO_IND_size(mac802_16_mob_ho_ind_frame *frame);
- +};
- +
- +
- +#endif
- diff -Naur ns-2.29-org/wimax/mac802_16timer.cc ns-2.29/wimax/mac802_16timer.cc
- --- ns-2.29-org/wimax/mac802_16timer.cc 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/mac802_16timer.cc 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,318 @@
- +/* 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_16timer.h"
- +#include "mac802_16.h"
- +#include "scheduling/wimaxscheduler.h"
- +
- +/*
- + * Starts a timer for the given duration
- + * @param time The timer duration
- + */
- +void WimaxTimer::start(double time)
- +{
- + Scheduler &s = Scheduler::instance();
- + assert(busy_ == 0);
- + busy_ = 1;
- + paused_ = 0;
- + stime = s.clock();
- + rtime = time;
- + assert(rtime >= 0.0);
- + s.schedule(this, &intr, rtime); //schedule the event
- +}
- +
- +/*
- + * Stop the timer
- + */
- +void WimaxTimer::stop(void)
- +{
- + Scheduler &s = Scheduler::instance();
- +
- + assert(busy_);
- +
- + if(paused_ == 0)
- + s.cancel(&intr); //cancel the event
- +
- + busy_ = 0;
- + paused_ = 0;
- + stime = 0.0;
- + rtime = 0.0;
- +}
- +
- +void WimaxTimer::pause(void)
- +{
- + Scheduler &s = Scheduler::instance();
- +
- + assert(busy_ && ! paused_);
- +
- + paused_ = 1;
- + rtime -= s.clock()-stime;
- +
- + assert(rtime >= 0.0);
- +
- + s.cancel(&intr);
- +}
- +
- +
- +void WimaxTimer::resume(void)
- +{
- + Scheduler &s = Scheduler::instance();
- +
- + assert(busy_ && paused_);
- +
- + paused_ = 0;
- + stime = s.clock();
- +
- + assert(rtime >= 0.0);
- + s.schedule(this, &intr, rtime );
- +}
- +
- +
- +
- +/*
- + * Handling function for WimaxFrameTimer
- + * @param e The event that occured
- + */
- +void WimaxRxTimer::handle(Event *e)
- +{
- + busy_ = 0;
- + paused_ = 0;
- + stime = 0.0;
- + rtime = 0.0;
- +
- + mac->receive ();
- +}
- +
- +/*
- + * Handling function for WimaxFrameTimer
- + * @param e The event that occured
- + */
- +void WimaxT1Timer::handle(Event *e)
- +{
- + busy_ = 0;
- + paused_ = 0;
- + stime = 0.0;
- + rtime = 0.0;
- +
- + mac->getScheduler()->expire(WimaxT1TimerID);
- +}
- +
- +/*
- + * Handling function for WimaxFrameTimer
- + * @param e The event that occured
- + */
- +void WimaxT2Timer::handle(Event *e)
- +{
- + busy_ = 0;
- + paused_ = 0;
- + stime = 0.0;
- + rtime = 0.0;
- +
- + mac->getScheduler()->expire(WimaxT2TimerID);
- +}
- +
- +/*
- + * Handling function for WimaxT3Timer
- + * @param e The event that occured
- + */
- +void WimaxT3Timer::handle(Event *e)
- +{
- + busy_ = 0;
- + paused_ = 0;
- + stime = 0.0;
- + rtime = 0.0;
- +
- + mac->getScheduler()->expire(WimaxT3TimerID);
- +}
- +
- +/*
- + * Handling function for WimaxT6Timer
- + * @param e The event that occured
- + */
- +void WimaxT6Timer::handle(Event *e)
- +{
- + busy_ = 0;
- + paused_ = 0;
- + stime = 0.0;
- + rtime = 0.0;
- +
- + mac->getScheduler()->expire(WimaxT6TimerID);
- +}
- +
- +/*
- + * Handling function for WimaxT12Timer
- + * @param e The event that occured
- + */
- +void WimaxT12Timer::handle(Event *e)
- +{
- + busy_ = 0;
- + paused_ = 0;
- + stime = 0.0;
- + rtime = 0.0;
- +
- + mac->getScheduler()->expire(WimaxT12TimerID);
- +}
- +
- +/*
- + * Handling function for WimaxT17Timer
- + * @param e The event that occured
- + */
- +void WimaxT17Timer::handle(Event *e)
- +{
- + busy_ = 0;
- + paused_ = 0;
- + stime = 0.0;
- + rtime = 0.0;
- +
- + /** The node did not send a registration: release and
- + * age out Basic and Primary CIDs
- + */
- + PeerNode * peer = mac->getPeerNode (peerIndex_);
- + mac->debug ("At %f in Mac %d did not register on time...release CIDsn", NOW, mac->addr(),peerIndex_);
- + mac->removePeerNode (peer);
- +}
- +
- +
- +/*
- + * Handling function for WimaxT21Timer
- + * @param e The event that occured
- + */
- +void WimaxT21Timer::handle(Event *e)
- +{
- + busy_ = 0;
- + paused_ = 0;
- + stime = 0.0;
- + rtime = 0.0;
- +
- + mac->getScheduler()->expire(WimaxT21TimerID);
- +}
- +
- +/*
- + * Handling function for WimaxFrameTimer
- + * @param e The event that occured
- + */
- +void WimaxLostDLMAPTimer::handle(Event *e)
- +{
- + busy_ = 0;
- + paused_ = 0;
- + stime = 0.0;
- + rtime = 0.0;
- +
- + mac->getScheduler()->expire(WimaxLostDLMAPTimerID);
- +}
- +
- +/*
- + * Handling function for WimaxFrameTimer
- + * @param e The event that occured
- + */
- +void WimaxLostULMAPTimer::handle(Event *e)
- +{
- + busy_ = 0;
- + paused_ = 0;
- + stime = 0.0;
- + rtime = 0.0;
- +
- + mac->getScheduler()->expire(WimaxLostULMAPTimerID);
- +}
- +
- +/*
- + * Handling function for WimaxDCDTimer
- + * @param e The event that occured
- + */
- +void WimaxDCDTimer::handle(Event *e)
- +{
- + busy_ = 0;
- + paused_ = 0;
- + stime = 0.0;
- + rtime = 0.0;
- +
- + mac->getScheduler()->expire(WimaxDCDTimerID);
- +}
- +
- +/*
- + * Handling function for WimaxUCDTimer
- + * @param e The event that occured
- + */
- +void WimaxUCDTimer::handle(Event *e)
- +{
- + busy_ = 0;
- + paused_ = 0;
- + stime = 0.0;
- + rtime = 0.0;
- +
- + mac->getScheduler()->expire(WimaxUCDTimerID);
- +}
- +
- +/*
- + * Handling function for WimaxScanIntervalTimer
- + * @param e The event that occured
- + */
- +void WimaxScanIntervalTimer::handle(Event *e)
- +{
- + busy_ = 0;
- + paused_ = 0;
- + stime = 0.0;
- + rtime = 0.0;
- +
- + mac->getScheduler()->expire(WimaxScanIntervalTimerID);
- +}
- +
- +/*
- + * Handling function for WimaxT44Timer
- + * @param e The event that occured
- + */
- +void WimaxT44Timer::handle(Event *e)
- +{
- + busy_ = 0;
- + paused_ = 0;
- + stime = 0.0;
- + rtime = 0.0;
- +
- + mac->getScheduler()->expire(WimaxT44TimerID);
- +}
- +
- +/*
- + * Handling function for WimaxMobNbrAdvTimer
- + * @param e The event that occured
- + */
- +void WimaxMobNbrAdvTimer::handle(Event *e)
- +{
- + busy_ = 0;
- + paused_ = 0;
- + stime = 0.0;
- + rtime = 0.0;
- +
- + mac->getScheduler()->expire(WimaxMobNbrAdvTimerID);
- +}
- +
- +/*
- + * Handling function for WimaxRdvTimer
- + * @param e The event that occured
- + */
- +void WimaxRdvTimer::handle(Event *e)
- +{
- + busy_ = 0;
- + paused_ = 0;
- + stime = 0.0;
- + rtime = 0.0;
- +
- + mac->getScheduler()->expire(WimaxRdvTimerID);
- + printf ("Rdv timeout going to channel %dn", channel_);
- + mac->setChannel (channel_);
- +}
- +
- diff -Naur ns-2.29-org/wimax/mac802_16timer.h ns-2.29/wimax/mac802_16timer.h
- --- ns-2.29-org/wimax/mac802_16timer.h 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/mac802_16timer.h 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,243 @@
- +/* 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_16TIMER_H
- +#define MAC802_16TIMER_H
- +
- +#include "scheduler.h"
- +
- +/** Define the ID for each timer **/
- +enum timer_id {
- + WimaxFrameTimerID,
- + WimaxRxTimerID,
- + WimaxDCDTimerID,
- + WimaxUCDTimerID,
- + WimaxRngIntTimerID,
- + WimaxLostDLMAPTimerID,
- + WimaxLostULMAPTimerID,
- + WimaxT1TimerID,
- + WimaxT2TimerID,
- + WimaxT3TimerID,
- + WimaxT6TimerID,
- + WimaxT9TimerID,
- + WimaxT12TimerID,
- + WimaxT16TimerID,
- + WimaxT17TimerID,
- + WimaxT21TimerID,
- + WimaxT44TimerID,
- + //mobility extension
- + WimaxMobNbrAdvTimerID,
- +
- + WimaxScanIntervalTimerID,
- + WimaxRdvTimerID
- +};
- +
- +
- +class Mac802_16;
- +
- +/**
- + * Super class for timers used in wimax
- + */
- +class WimaxTimer : public Handler {
- +public:
- + WimaxTimer(Mac802_16* m) : mac(m) {
- + busy_ = paused_ = 0; stime = rtime = 0.0;
- + }
- +
- + virtual void handle(Event *e) = 0;
- +
- + virtual void start(double time);
- + virtual void stop(void);
- + void pause(void); /*{ assert(0); }*/
- + void resume(void);/* { assert(0); }*/
- +
- + inline int busy(void) { return busy_; }
- + inline int paused(void) { return paused_; }
- + inline double expire(void) {
- + return ((stime + rtime) - Scheduler::instance().clock());
- + }
- +
- +protected:
- + Mac802_16 *mac;
- + int busy_;
- + int paused_;
- + Event intr;
- + double stime; // start time
- + double rtime; // remaining time
- +};
- +
- +/** Timer for receiving a packet */
- +class WimaxRxTimer : public WimaxTimer {
- + public:
- + WimaxRxTimer(Mac802_16 *m) : WimaxTimer(m) {}
- +
- + void handle(Event *e);
- +};
- +
- +/** Timer for DCD interval */
- +class WimaxDCDTimer : public WimaxTimer {
- + public:
- + WimaxDCDTimer(Mac802_16 *m) : WimaxTimer(m) {}
- +
- + void handle(Event *e);
- +};
- +
- +/** Timer for UCD interval */
- +class WimaxUCDTimer : public WimaxTimer {
- + public:
- + WimaxUCDTimer(Mac802_16 *m) : WimaxTimer(m) {}
- +
- + void handle(Event *e);
- +};
- +
- +/** Timer for initial ranging regions interval */
- +class WimaxRngIntTimer : public WimaxTimer {
- + public:
- + WimaxRngIntTimer(Mac802_16 *m) : WimaxTimer(m) {}
- +
- + void handle(Event *e);
- +};
- +
- +/** Timer for Lost DL-MAP interval */
- +class WimaxLostDLMAPTimer : public WimaxTimer {
- + public:
- + WimaxLostDLMAPTimer(Mac802_16 *m) : WimaxTimer(m) {}
- +
- + void handle(Event *e);
- +};
- +
- +/** Timer for Lost UL-MAP interval */
- +class WimaxLostULMAPTimer : public WimaxTimer {
- + public:
- + WimaxLostULMAPTimer(Mac802_16 *m) : WimaxTimer(m) {}
- +
- + void handle(Event *e);
- +};
- +
- +/** Timer for T1 : wait for DCD timeout */
- +class WimaxT1Timer : public WimaxTimer {
- + public:
- + WimaxT1Timer(Mac802_16 *m) : WimaxTimer(m) {}
- +
- + void handle(Event *e);
- +};
- +
- +/** Timer for T2 : wait for broadcast ranging timeout */
- +class WimaxT2Timer : public WimaxTimer {
- + public:
- + WimaxT2Timer(Mac802_16 *m) : WimaxTimer(m) {}
- +
- + void handle(Event *e);
- +};
- +
- +/** Timer for T3 : ranging response timeout */
- +class WimaxT3Timer : public WimaxTimer {
- + public:
- + WimaxT3Timer(Mac802_16 *m) : WimaxTimer(m) {}
- +
- + void handle(Event *e);
- +};
- +
- +/** Timer for T6 : wait for registration response */
- +class WimaxT6Timer : public WimaxTimer {
- + public:
- + WimaxT6Timer(Mac802_16 *m) : WimaxTimer(m) {}
- +
- + void handle(Event *e);
- +};
- +
- +/** Timer for T9 : registration timeout */
- +class WimaxT9Timer : public WimaxTimer {
- + public:
- + WimaxT9Timer(Mac802_16 *m) : WimaxTimer(m) {}
- +
- + void handle(Event *e);
- +};
- +
- +/** Timer for T12 : wait for UCD descriptor */
- +class WimaxT12Timer : public WimaxTimer {
- + public:
- + WimaxT12Timer(Mac802_16 *m) : WimaxTimer(m) {}
- +
- + void handle(Event *e);
- +};
- +
- +/** Timer for T16 : wait for bw request grant */
- +class WimaxT16Timer : public WimaxTimer {
- + public:
- + WimaxT16Timer(Mac802_16 *m) : WimaxTimer(m) {}
- +
- + void handle(Event *e);
- +};
- +
- +/** Timer for T17 : wait for SS to register */
- +class WimaxT17Timer : public WimaxTimer {
- + public:
- + WimaxT17Timer(Mac802_16 *m, int peerIndex) : WimaxTimer(m) { peerIndex_ = peerIndex;}
- +
- + void handle(Event *e);
- + private:
- + int peerIndex_;
- +};
- +
- +/** Timer for T21 : time the station searches for DL-MAP on a channel */
- +class WimaxT21Timer : public WimaxTimer {
- + public:
- + WimaxT21Timer(Mac802_16 *m) : WimaxTimer(m) {}
- +
- + void handle(Event *e);
- +};
- +
- +/** Timer for T44 : wait for BS to send MOB_SCN-REP */
- +class WimaxT44Timer : public WimaxTimer {
- + public:
- + WimaxT44Timer(Mac802_16 *m) : WimaxTimer(m) {}
- +
- + void handle(Event *e);
- +};
- +
- +/** Timer for scan interval : timer for scanning */
- +class WimaxScanIntervalTimer : public WimaxTimer {
- + public:
- + WimaxScanIntervalTimer(Mac802_16 *m) : WimaxTimer(m) {}
- +
- + void handle(Event *e);
- +};
- +
- +/** Timer for neighbor advertisement interval */
- +class WimaxMobNbrAdvTimer : public WimaxTimer {
- + public:
- + WimaxMobNbrAdvTimer(Mac802_16 *m) : WimaxTimer(m) {}
- +
- + void handle(Event *e);
- +};
- +
- +/** Timer for rendez-vous with target BSs */
- +class WimaxRdvTimer : public WimaxTimer {
- + public:
- + WimaxRdvTimer(Mac802_16 *m, int channel) : WimaxTimer(m)
- + {
- + channel_ = channel;
- + }
- +
- + void handle(Event *e);
- + private:
- + int channel_;
- +};
- +
- +#endif
- diff -Naur ns-2.29-org/wimax/neighbordb.cc ns-2.29/wimax/neighbordb.cc
- --- ns-2.29-org/wimax/neighbordb.cc 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/neighbordb.cc 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,103 @@
- +/* 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 "neighbordb.h"
- +
- +/**
- + * Constructor
- + */
- +NeighborDB::NeighborDB ()
- +{
- + nbentry_ = 0;
- + nbs_ = (NeighborEntry **) malloc (DEFAULT_DB_SIZE*sizeof (NeighborEntry *));
- +}
- +
- +/**
- + * Destructor
- + */
- +NeighborDB::~NeighborDB ()
- +{
- + for (int i=0 ; i < nbentry_ ; i++) {
- + delete (nbs_[i]);
- + }
- +}
- +
- +/**
- + * Add an entry in the database
- + * @param nb The neighbor to add
- + */
- +void NeighborDB::addNeighbor (NeighborEntry *nb)
- +{
- + if (nbentry_ == DEFAULT_DB_SIZE) {
- + printf ("Default size for neighbor database is too small. Update DEFAULT_DB_SIZE attributen");
- + exit (0);
- + }
- + nbs_[nbentry_++] = nb;
- +}
- +
- +/**
- + * Remove the entry associated with the given node
- + * @param nbid The neighbor id
- + */
- +void NeighborDB::removeNeighbor (int nbid)
- +{
- + assert (getNeighbor (nbid)==NULL);
- +
- + for (int i = 0 ; i < nbentry_ ; i++) {
- + if (nbs_[i]->getID() == nbid) {
- + delete (nbs_[i]);
- + for (int j = i+1 ; j < nbentry_ ; j++, i++)
- + nbs_[i]=nbs_[j];
- + nbentry_--;
- + break;
- + }
- + }
- +}
- +
- +/**
- + * Return the number of neighbor in the list
- + * @return the number of neighbor in the list
- + */
- +int NeighborDB::getNbNeighbor ()
- +{
- + return nbentry_;
- +}
- +
- +/**
- + * Return the entry associated with the given node
- + * @param nbid The neighbor id
- + * @return the entry for the given node or NULL
- + */
- +NeighborEntry * NeighborDB::getNeighbor (int nbid)
- +{
- + for (int i = 0 ; i < nbentry_ ; i++) {
- + if (nbs_[i]->getID() == nbid) {
- + return (nbs_[i]);
- + }
- + }
- + return NULL;
- +}
- +
- +/**
- + * Return a pointer to the list of all neighbors
- + * @return a pointer to the list of all neighbors
- + */
- +NeighborEntry ** NeighborDB::getNeighbors ()
- +{
- + return nbs_;
- +}
- diff -Naur ns-2.29-org/wimax/neighbordb.h ns-2.29/wimax/neighbordb.h
- --- ns-2.29-org/wimax/neighbordb.h 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/neighbordb.h 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
- + */
- +
- +#ifndef NEIGHBORDB_H
- +#define NEIGHBORDB_H
- +
- +#include "neighborentry.h"
- +#include "mac802_16pkt.h"
- +
- +/* This is the size of database allocated. Needs to be modified if
- + * a node could have more entries
- + */
- +#define DEFAULT_DB_SIZE 10
- +
- +/**
- + * The class is used to store and manipulate the list
- + * of neighbors in a given node
- + */
- +class NeighborDB {
- + public:
- + /**
- + * Constructor
- + */
- + NeighborDB ();
- +
- + /**
- + * Destructor
- + */
- + ~NeighborDB ();
- +
- + /**
- + * Add an entry in the database
- + * @param nb The neighbor to add
- + */
- + void addNeighbor (NeighborEntry *nb);
- +
- + /**
- + * Remove the entry associated with the given node
- + * @param nbid The neighbor id
- + */
- + void removeNeighbor (int nbid);
- +
- + /**
- + * Return the number of neighbor in the list
- + * @return the number of neighbor in the list
- + */
- + int getNbNeighbor ();
- +
- + /**
- + * Return the entry associated with the given node
- + * @param nbid The neighbor id
- + * @return the entry for the given node or NULL
- + */
- + NeighborEntry * getNeighbor (int nbid);
- +
- + /**
- + * Return a pointer to the list of all neighbors
- + * @return a pointer to the list of all neighbors
- + */
- + NeighborEntry ** getNeighbors ();
- +
- + protected:
- +
- + private:
- + /**
- + * Current number of neighbor
- + */
- + int nbentry_;
- +
- + /**
- + * Array of neighbors
- + */
- + NeighborEntry **nbs_;
- +
- +};
- +
- +
- +#endif
- diff -Naur ns-2.29-org/wimax/neighborentry.cc ns-2.29/wimax/neighborentry.cc
- --- ns-2.29-org/wimax/neighborentry.cc 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/neighborentry.cc 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,159 @@
- +/* 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 "neighborentry.h"
- +
- +/**
- + * Constructor
- + */
- +NeighborEntry::NeighborEntry (int id) : nbr_adv_(0), dcd_(0), ucd_ (0), rng_rsp_(0)
- +{
- + id_ = id;
- + memset (&state_, 0, sizeof (struct sched_state_info));
- + detected_ = false;
- +}
- +
- +/**
- + * Destructor
- + */
- +NeighborEntry::~NeighborEntry ()
- +{
- + free (nbr_adv_);
- + free (dcd_);
- + free (ucd_);
- + free (rng_rsp_);
- +}
- +
- +
- +/**
- + * Return the address of the neighbor of this entry
- + * @return the address of the neighbor of this entry
- + */
- +int NeighborEntry::getID ()
- +{
- + return id_;
- +}
- +
- +/**
- + * Set the neighbor advertisement message
- + * @param frame The advertisment message
- + */
- +void NeighborEntry::setNbrAdvMessage (mac802_16_nbr_adv_info *frame)
- +{
- + nbr_adv_ = frame;
- +}
- +
- +/**
- + * Return the neighbor advertisement message
- + * @param frame The advertisment message
- + */
- +mac802_16_nbr_adv_info * NeighborEntry::getNbrAdvMessage ()
- +{
- + return nbr_adv_;
- +}
- +
- +/**
- + * Set the DCD message received during scanning
- + * @param dcd the DCD message received
- + */
- +void NeighborEntry::setDCD (mac802_16_dcd_frame *frame)
- +{
- + dcd_ = frame;
- +}
- +
- +/**
- + * Get the DCD message received during scanning
- + * @return the DCD message received
- + */
- +mac802_16_dcd_frame * NeighborEntry::getDCD ()
- +{
- + return dcd_;
- +}
- +
- +/**
- + * Set the UCD message received during scanning
- + * @param dcd the DCD message received
- + */
- +void NeighborEntry::setUCD (mac802_16_ucd_frame *frame)
- +{
- + ucd_ = frame;
- +}
- +
- +/**
- + * Get the DCD message received during scanning
- + * @return the DCD message received
- + */
- +mac802_16_ucd_frame * NeighborEntry::getUCD ()
- +{
- + return ucd_;
- +}
- +
- +/**
- + * Set the MAC state associated with this neighbor
- + * @param state
- + */
- +/*void NeighborEntry::setState (sched_state_info *state)
- +{
- + state_ = state;
- +}*/
- +
- +/**
- + * Get the MAC state associated with this neighbor
- + * @return the MAC state associated with this neighbor
- + */
- +sched_state_info * NeighborEntry::getState ()
- +{
- + return &state_;
- +}
- +
- +/**
- + * Mark the neighbor as being detected
- + * @param detected indicate if the neighbor has been detected
- + */
- +void NeighborEntry::setDetected (bool detected)
- +{
- + detected_ = detected;
- +}
- +
- +/**
- + * Indicates the neighbor as being detected
- + * @return indication if the neighbor has been detected
- + */
- +bool NeighborEntry::isDetected ()
- +{
- + return detected_;
- +}
- +
- +/**
- + * Set the UCD message received during scanning
- + * @param dcd the DCD message received
- + */
- +void NeighborEntry::setRangingRsp (mac802_16_rng_rsp_frame *frame)
- +{
- + rng_rsp_ = frame;
- +}
- +
- +/**
- + * Get the DCD message received during scanning
- + * @return the DCD message received
- + */
- +mac802_16_rng_rsp_frame *NeighborEntry::getRangingRsp ()
- +{
- + return rng_rsp_;
- +}
- +
- diff -Naur ns-2.29-org/wimax/neighborentry.h ns-2.29/wimax/neighborentry.h
- --- ns-2.29-org/wimax/neighborentry.h 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/neighborentry.h 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,168 @@
- +/* 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 NEIGHBORENTRY_H
- +#define NEIGHBORENTRY_H
- +
- +#include "scheduling/framemap.h"
- +
- +/** Data structure used to store Mac state information during scanning */
- +struct sched_state_info {
- + struct state_info *state_info;
- + FrameMap *map;
- + WimaxT1Timer *t1timer;
- + WimaxT2Timer *t2timer;
- + WimaxT6Timer *t6timer;
- + WimaxT12Timer *t12timer;
- + WimaxT21Timer *t21timer;
- + WimaxLostDLMAPTimer *lostDLMAPtimer;
- + WimaxLostULMAPTimer *lostULMAPtimer;
- + WimaxT44Timer *t44timer;
- +};
- +
- +/**
- + * Store information about a neighboring BS.
- + */
- +class NeighborEntry {
- + public:
- + /**
- + * Constructor
- + */
- + NeighborEntry (int id);
- +
- + /**
- + * Destructor
- + */
- + ~NeighborEntry ();
- +
- + /**
- + * Return the address of the neighbor of this entry
- + * @return the address of the neighbor of this entry
- + */
- + int getID ();
- +
- + /**
- + * Set the neighbor advertisement message
- + * @param frame The advertisment message
- + */
- + void setNbrAdvMessage (mac802_16_nbr_adv_info *frame);
- +
- + /**
- + * Return the neighbor advertisement message
- + * @param frame The advertisment message
- + */
- + mac802_16_nbr_adv_info * getNbrAdvMessage ();
- +
- + /**
- + * Set the DCD message received during scanning
- + * @param dcd the DCD message received
- + */
- + void setDCD (mac802_16_dcd_frame *frame);
- +
- + /**
- + * Get the DCD message received during scanning
- + * @return the DCD message received
- + */
- + mac802_16_dcd_frame *getDCD ();
- +
- + /**
- + * Set the UCD message received during scanning
- + * @param dcd the DCD message received
- + */
- + void setUCD (mac802_16_ucd_frame *frame);
- +
- + /**
- + * Get the DCD message received during scanning
- + * @return the DCD message received
- + */
- + mac802_16_ucd_frame *getUCD ();
- +
- + /**
- + * Set the UCD message received during scanning
- + * @param dcd the DCD message received
- + */
- + void setRangingRsp (mac802_16_rng_rsp_frame *frame);
- +
- + /**
- + * Get the DCD message received during scanning
- + * @return the DCD message received
- + */
- + mac802_16_rng_rsp_frame *getRangingRsp ();
- +
- + /**
- + * Mark the neighbor as being detected
- + * @param detected indicate if the neighbor has been detected
- + */
- + void setDetected (bool detected);
- +
- + /**
- + * Indicates the neighbor as being detected
- + * @return indication if the neighbor has been detected
- + */
- + bool isDetected ();
- +
- + /**
- + * Set the MAC state associated with this neighbor
- + * @param state
- + */
- + //void setState (sched_state_info *state);
- +
- + /**
- + * Get the MAC state associated with this neighbor
- + * @return the MAC state associated with this neighbor
- + */
- + sched_state_info * getState ();
- +
- + private:
- + /**
- + * The MAC address of neighbor
- + */
- + int id_;
- +
- + /**
- + * The neighbor info adv message
- + */
- + struct mac802_16_nbr_adv_info *nbr_adv_;
- +
- + /**
- + * The DCD message received during scanning
- + */
- + mac802_16_dcd_frame *dcd_;
- +
- + /**
- + * The DCD message received during scanning
- + */
- + mac802_16_ucd_frame *ucd_;
- +
- + /**
- + * The ranging response received during scanning
- + */
- + mac802_16_rng_rsp_frame *rng_rsp_;
- +
- + /**
- + * Save the state
- + */
- + struct sched_state_info state_;
- +
- + /**
- + * Indicate if the neighbor has been detected
- + */
- + bool detected_;
- +};
- +
- +#endif
- diff -Naur ns-2.29-org/wimax/ofdmphy.cc ns-2.29/wimax/ofdmphy.cc
- --- ns-2.29-org/wimax/ofdmphy.cc 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/ofdmphy.cc 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,304 @@
- +/* 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 "ofdmphy.h"
- +#include "mac802_16pkt.h"
- +
- +//#define DEBUG_WIMAX 1
- +
- +/**
- + * Tcl hook for creating the physical layer
- + */
- +static class OFDMPhyClass: public TclClass {
- +public:
- + OFDMPhyClass() : TclClass("Phy/WirelessPhy/OFDM") {}
- + TclObject* create(int, const char*const*) {
- + return (new OFDMPhy);
- + }
- +} class_OfdmPhy;
- +
- +OFDMPhy::OFDMPhy() : WirelessPhy()
- +{
- + //bind attributes
- + bind ("g_", &g_);
- + //bind ("rtg_", &rtg_);
- + //bind ("ttg_", &ttg_);
- + //bind ("fbandwidth_", &fbandwidth_);
- +
- + //default modulation is BPSK
- + modulation_ = OFDM_BPSK_1_2;
- + Tcl& tcl = Tcl::instance();
- + tcl.evalf("Mac/802_16 set fbandwidth_");
- + fbandwidth_ = atof (tcl.result());
- + state_ = OFDM_IDLE;
- + activated_ = true;
- +
- + updateFs ();
- +}
- +
- +/*
- + * Activate node
- + */
- +void OFDMPhy::node_on ()
- +{
- + activated_ = true;
- +}
- +
- +/*
- + * Deactivate node
- + */
- +void OFDMPhy::node_off ()
- +{
- + activated_ = false;
- +}
- +
- +
- +/**
- + * Change the frequency at which the phy is operating
- + * @param freq The new frequency
- + */
- +void OFDMPhy::setFrequency (double freq)
- +{
- + freq_ = freq;
- + lambda_ = SPEED_OF_LIGHT / freq_;
- +}
- +
- +/**
- + * Set the new modulation for the physical layer
- + */
- +void OFDMPhy::setModulation (Ofdm_mod_rate modulation) {
- + modulation_ = modulation;
- +}
- +/**
- + * Return the current modulation
- + */
- +Ofdm_mod_rate OFDMPhy::getModulation () {
- + return modulation_;
- +}
- +/**
- + * Set the new transmitting power
- + */
- +void OFDMPhy::setTxPower (double power) {
- + Pt_ = power;
- +}
- +/**
- + * Return the current transmitting power
- + */
- +double OFDMPhy::getTxPower () {
- + return getPt();
- +}
- +
- +/**
- + * Update the PS information
- + */
- +void OFDMPhy::updateFs () {
- + /* The PS=4*Fs with Fs=floor (n.BW/8000)*8000
- + * and n=8/7 is channel bandwidth multiple of 1.75Mhz
- + * n=86/75 is channel bandwidth multiple of 1.5Mhz
- + * n=144/125 is channel bandwidth multiple of 1.25Mhz
- + * n=316/275 is channel bandwidth multiple of 2.75Mhz
- + * n=57/50 is channel bandwidth multiple of 2.0Mhz
- + * n=8/7 for all other cases
- + */
- + double n;
- +
- + if (((int) (fbandwidth_ / 1.75)) * 1.75 == fbandwidth_) {
- + n = 8.0/7;
- + } else if (((int) (fbandwidth_ / 1.5)) * 1.5 == fbandwidth_) {
- + n = 86.0/75;
- + } else if (((int) (fbandwidth_ / 1.25)) * 1.25 == fbandwidth_) {
- + n = 144.0/125;
- + } else if (((int) (fbandwidth_ / 2.75)) * 2.75 == fbandwidth_) {
- + n = 316.0/275;
- + } else if (((int) (fbandwidth_ / 2.0)) * 2.0 == fbandwidth_) {
- + n = 57.0/50;
- + } else {
- + n = 8.0/7;
- + }
- +
- + fs_ = floor (n*fbandwidth_/8000) * 8000;
- +#ifdef DEBUG_WIMAX
- + printf ("Fs updated. Bw=%f, n=%f, new value is %en", fbandwidth_, n, fs_);
- +#endif
- +}
- +
- +/*
- + * Compute the transmission time for a packet of size sdusize and
- + * using the given modulation
- + * @param sdusize Size in bytes of the data to send
- + * @param mod The modulation to use
- + */
- +double OFDMPhy::getTrxTime (int sdusize, Ofdm_mod_rate mod) {
- + //we compute the number of symbols required
- + int nb_symbols, bpsymb;
- +
- + switch (mod) {
- + case OFDM_BPSK_1_2:
- + bpsymb = OFDM_BPSK_1_2_bpsymb;
- + break;
- + case OFDM_QPSK_1_2:
- + bpsymb = OFDM_QPSK_1_2_bpsymb;
- + break;
- + case OFDM_QPSK_3_4:
- + bpsymb = OFDM_QPSK_3_4_bpsymb;
- + break;
- + case OFDM_16QAM_1_2:
- + bpsymb = OFDM_16QAM_1_2_bpsymb;
- + break;
- + case OFDM_16QAM_3_4:
- + bpsymb = OFDM_16QAM_3_4_bpsymb;
- + break;
- + case OFDM_64QAM_2_3:
- + bpsymb = OFDM_64QAM_2_3_bpsymb;
- + break;
- + case OFDM_64QAM_3_4:
- + bpsymb = OFDM_64QAM_3_4_bpsymb;
- + break;
- + default:
- + printf ("Error: unknown modulation: method getTrxTime in file ofdmphy.ccn");
- + exit (1);
- + }
- +
- +#ifdef DEBUG_WIMAX
- + printf ("Nb symbols=%dn", (int) (ceil(((double)sdusize*8)/bpsymb)));
- +#endif
- +
- + nb_symbols = (int) (ceil(((double)sdusize*8)/bpsymb));
- + return (nb_symbols*getSymbolTime ());
- +}
- +
- +/*
- + * Return the maximum size in bytes that can be sent for the given
- + * nb symbols and modulation
- + */
- +int OFDMPhy::getMaxPktSize (double nbsymbols, Ofdm_mod_rate mod)
- +{
- + int bpsymb;
- +
- + switch (mod) {
- + case OFDM_BPSK_1_2:
- + bpsymb = OFDM_BPSK_1_2_bpsymb;
- + break;
- + case OFDM_QPSK_1_2:
- + bpsymb = OFDM_QPSK_1_2_bpsymb;
- + break;
- + case OFDM_QPSK_3_4:
- + bpsymb = OFDM_QPSK_3_4_bpsymb;
- + break;
- + case OFDM_16QAM_1_2:
- + bpsymb = OFDM_16QAM_1_2_bpsymb;
- + break;
- + case OFDM_16QAM_3_4:
- + bpsymb = OFDM_16QAM_3_4_bpsymb;
- + break;
- + case OFDM_64QAM_2_3:
- + bpsymb = OFDM_64QAM_2_3_bpsymb;
- + break;
- + case OFDM_64QAM_3_4:
- + bpsymb = OFDM_64QAM_3_4_bpsymb;
- + break;
- + default:
- + printf ("Error: unknown modulation: method getTrxTime in file ofdmphy.ccn");
- + exit (1);
- + }
- +
- + return (int)(nbsymbols*bpsymb)/8;
- +}
- +
- +/**
- + * Return the OFDM symbol duration time
- + */
- +double OFDMPhy::getSymbolTime ()
- +{
- + //printf ("fs=%e, Subcarrier spacing=%en", fs_, fs_/((double)NFFT));
- + return (1+g_)*((double)NFFT)/fs_;
- +}
- +
- +
- +/*
- + * Set the mode for physical layer
- + * The Mac layer is in charge of know when to change the state by
- + * request the delay for the Rx2Tx and Tx2Rx
- + */
- +void OFDMPhy::setMode (Ofdm_phy_state mode)
- +{
- + state_ = mode;
- +}
- +
- +/* Redefine the method for sending a packet
- + * Add physical layer information
- + * @param p The packet to be sent
- + */
- +void OFDMPhy::sendDown(Packet *p)
- +{
- + hdr_mac802_16* wph = HDR_MAC802_16(p);
- +
- + /* Check phy status */
- + if (state_ != OFDM_SEND) {
- + printf ("Warning: OFDM not in sending state. Drop packet.n");
- + Packet::free (p);
- + return;
- + }
- +
- +#ifdef DEBUG_WIMAX
- + printf ("OFDM phy sending packet. Modulation is %d, cyclic prefix is %fn",
- + modulation_, g_);
- +#endif
- +
- + wph->phy_info.freq_ = freq_;
- + wph->phy_info.modulation_ = modulation_;
- + wph->phy_info.g_ = g_;
- +
- + //the packet can be sent
- + WirelessPhy::sendDown (p);
- +}
- +
- +/* Redefine the method for receiving a packet
- + * Add physical layer information
- + * @param p The packet to be sent
- + */
- +int OFDMPhy::sendUp(Packet *p)
- +{
- + hdr_mac802_16* wph = HDR_MAC802_16(p);
- +
- + if (!activated_)
- + return 0;
- +
- + if (freq_ != wph->phy_info.freq_) {
- +#ifdef DEBUG_WIMAX
- + printf ("drop packet because frequency is different (%f, %f)n", freq_,wph->phy_info.freq_);
- +#endif
- + return 0;
- + }
- +
- + /* Check phy status */
- + if (state_ != OFDM_RECV) {
- +#ifdef DEBUG_WIMAX
- + printf ("Warning: OFDM phy not in receiving state. Drop packet.n");
- +#endif
- + return 0;
- + }
- +
- +#ifdef DEBUG_WIMAX
- + printf ("OFDM phy receiving packet with mod=%d and cp=%fn", wph->phy_info.modulation_,wph->phy_info.g_);
- +#endif
- +
- + //the packet can be received
- + return WirelessPhy::sendUp (p);
- +}
- +
- diff -Naur ns-2.29-org/wimax/ofdmphy.h ns-2.29/wimax/ofdmphy.h
- --- ns-2.29-org/wimax/ofdmphy.h 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/ofdmphy.h 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,214 @@
- +/* 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 OFDMPHY_H
- +#define OFDMPHY_H
- +
- +#include <packet.h>
- +#include "wireless-phy.h"
- +
- +/* Define subcarrier information */
- +#define NFFT 256
- +#define NUSED 200 //number of subcarrier used
- +
- +/** Status of physical layer */
- +enum Ofdm_phy_state {
- + OFDM_IDLE, /* Module is not doing anything */
- + OFDM_SEND, /* Module is ready to send or sending */
- + OFDM_RECV, /* Module is can receive or is receiving */
- + OFDM_RX2TX, /* Module is transitioning from receiving mode to sending mode */
- + OFDM_TX2RX /* Module is transitioning from sending mode to receiving mode */
- +};
- +
- +/** Definition of supported rate */
- +enum Ofdm_mod_rate {
- + OFDM_BPSK_1_2, /* Efficiency is 1 bps/Hz */
- + OFDM_QPSK_1_2, /* Efficiency is 2 bps/Hz */
- + OFDM_QPSK_3_4, /* Efficiency is 2 bps/Hz */
- + OFDM_16QAM_1_2, /* Efficiency is 4 bps/Hz */
- + OFDM_16QAM_3_4, /* Efficiency is 4 bps/Hz */
- + OFDM_64QAM_2_3, /* Efficiency is 6 bps/Hz */
- + OFDM_64QAM_3_4, /* Efficiency is 6 bps/Hz */
- +};
- +
- +/**
- + * How to compute the number of information bit per symbol:
- + * - Each symbol has 192 data subcarrier (200-8 for pilots)
- + * - A modulation has a coding rate (1/2, 2/3, or 3/4)
- + * - A modulation has an efficiency (1, 2, 4, or 6)
- + * - There is a 0x00 tail byte at the end of each OFDM symbol
- + * So for BPSK, 192*1*1/2-8=88
- + */
- +enum Ofdm_bit_per_symbol {
- + OFDM_BPSK_1_2_bpsymb = 88,
- + OFDM_QPSK_1_2_bpsymb = 184,
- + OFDM_QPSK_3_4_bpsymb = 280,
- + OFDM_16QAM_1_2_bpsymb = 376,
- + OFDM_16QAM_3_4_bpsymb = 578,
- + OFDM_64QAM_2_3_bpsymb = 760,
- + OFDM_64QAM_3_4_bpsymb = 856,
- +};
- +
- +/**
- + * Class OFDMPhy
- + * Physical layer implementing OFDM
- + */
- +class OFDMPhy : public WirelessPhy {
- +
- +public:
- + OFDMPhy();
- +
- + /**
- + * Change the frequency at which the phy is operating
- + * @param freq The new frequency
- + */
- + void setFrequency (double freq);
- +
- + /**
- + * Set the new modulation for the physical layer
- + * @param modulation The new physical modulation
- + */
- + void setModulation (Ofdm_mod_rate modulation);
- +
- + /**
- + * Return the current modulation
- + */
- + Ofdm_mod_rate getModulation ();
- +
- + /**
- + * Set the new transmitting power
- + * @param power The new transmitting power
- + */
- + void setTxPower (double power);
- +
- + /**
- + * Return the current transmitting power
- + */
- + double getTxPower ();
- +
- + /**
- + * Return the duration of a PS (physical slot), unit for allocation time.
- + * Use Frame duration / PS to find the number of available slot per frame
- + */
- + inline double getPS () { return (4/fs_); }
- +
- + /**
- + * Return the OFDM symbol duration time
- + */
- + double getSymbolTime ();
- +
- + /**
- + * Compute the transmission time for a packet of size sdusize and
- + * using the given modulation
- + */
- + double getTrxTime (int, Ofdm_mod_rate);
- +
- + /**
- + * Return the maximum size in bytes that can be sent for the given
- + * nb of symbols and modulation
- + */
- + int getMaxPktSize (double nbsymbols, Ofdm_mod_rate);
- +
- + /**
- + * Return the number of PS used by an OFDM symbol
- + */
- + inline int getSymbolPS () { return (int) (ceil (getSymbolTime() / getPS())); }
- +
- + /**
- + * Set the mode for physical layer
- + */
- + void setMode (Ofdm_phy_state mode);
- +
- + /**
- + * Activate node
- + */
- + void node_on ();
- +
- + /**
- + * Deactivate node
- + */
- + void node_off ();
- +
- +protected:
- +
- + /**
- + * Update the sampling frequency. Called after changing frequency BW
- + */
- + void updateFs ();
- +
- + /*
- + * Return the delay required for switching for Rx to Tx mode
- + */
- + //inline double getRx2TxDelay () { return getPS () * rtg_; }
- +
- + /*
- + * Return the delay required for switching for Tx to Rx mode
- + */
- + //inline double getTx2RxDelay () { return getPS () * ttg_; }
- +
- +
- + /* Overwritten methods for handling packets */
- + void sendDown(Packet *p);
- + int sendUp(Packet *p);
- +
- +private:
- +
- + /**
- + * The current modulation
- + */
- + Ofdm_mod_rate modulation_;
- + /**
- + * The current transmitting power
- + */
- + int tx_power_;
- + /**
- + * Ratio of CP time over useful time
- + */
- + double g_;
- + /**
- + * The number of PS required to switch from Receiver to Transmitter
- + */
- + //int rtg_;
- + /**
- + * The number of PS required to switch from Transmitter to Receiver
- + */
- + //int ttg_;
- +
- + /**
- + * The sampling frequency
- + */
- + double fs_;
- +
- + /**
- + * The frequency bandwidth (Hz)
- + */
- + double fbandwidth_;
- +
- + /**
- + * The state of the OFDM
- + */
- + Ofdm_phy_state state_;
- +
- + /**
- + * Indicates if the node is activated
- + */
- + bool activated_;
- +
- +};
- +#endif //OFDMPHY_H
- +
- diff -Naur ns-2.29-org/wimax/peernode.cc ns-2.29/wimax/peernode.cc
- --- ns-2.29-org/wimax/peernode.cc 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/peernode.cc 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,123 @@
- +/* 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 "peernode.h"
- +
- +/**
- + * Constructor
- + * @param index The Mac address of the peer node
- + */
- +PeerNode::PeerNode (int index): basic_(0), primary_(0), secondary_(0), indata_(0),
- + outdata_(0), rxtime_ (0.0), rxp_watch_()
- +{
- + peerIndex_ = index;
- + going_down_ = false;
- +}
- +
- +/**
- + * Set the basic connection
- + * @param connection The basic connection
- + */
- +void PeerNode::setBasic (Connection* connection )
- +{
- + assert (connection != NULL);
- +
- + basic_ = connection;
- + connection->set_category (CONN_BASIC);
- + connection->setPeerNode (this);
- +}
- +
- +/**
- + * Set the primary connection
- + * @param connection The primary connection
- + */
- +void PeerNode::setPrimary (Connection* connection )
- +{
- + assert (connection != NULL);
- +
- + primary_ = connection;
- + connection->set_category (CONN_PRIMARY);
- + connection->setPeerNode (this);
- +}
- +
- +/**
- + * Set the secondary connection
- + * @param connection The secondary connection
- + */
- +void PeerNode::setSecondary (Connection* connection )
- +{
- + assert (connection != NULL);
- +
- + secondary_ = connection;
- + connection->set_category (CONN_SECONDARY);
- + connection->setPeerNode (this);
- +}
- +
- +/**
- + * Set the incoming data connection
- + * @param connection The connection
- + */
- +void PeerNode::setInData (Connection* connection )
- +{
- + assert (connection != NULL);
- +
- + indata_ = connection;
- + connection->set_category (CONN_DATA);
- + connection->setPeerNode (this);
- +}
- +
- +/**
- + * Set the outgoing data connection
- + * @param connection The connection
- + */
- +void PeerNode::setOutData (Connection* connection )
- +{
- + assert (connection != NULL);
- +
- + outdata_ = connection;
- + connection->set_category (CONN_DATA);
- + connection->setPeerNode (this);
- +}
- +
- +/**
- + * Set the time the last packet was received
- + * @param time The time the last packet was received
- + */
- +void PeerNode::setRxTime (double time)
- +{
- + assert (time >=0.0);
- + rxtime_ = time;
- +}
- +
- +/**
- + * Get the time the last packet was received
- + * @return The time the last packet was received
- + */
- +double PeerNode::getRxTime ()
- +{
- + return rxtime_;
- +}
- +
- +/**
- + * Return the stat watch
- + * @return The stat watch
- + */
- +StatWatch * PeerNode::getStatWatch()
- +{
- + return &rxp_watch_;
- +}
- diff -Naur ns-2.29-org/wimax/peernode.h ns-2.29/wimax/peernode.h
- --- ns-2.29-org/wimax/peernode.h 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/peernode.h 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,197 @@
- +/* 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 PEERNODE_H
- +#define PEERNODE_H
- +
- +#include "connection.h"
- +#include "mac-stats.h"
- +
- +class PeerNode;
- +LIST_HEAD (peerNode, PeerNode);
- +/**
- + * Class PeerNode
- + * Supports list
- + */
- +class PeerNode {
- +
- +public:
- +
- + /**
- + * Constructor
- + * @param index The Mac address of the peer node
- + */
- + PeerNode (int index);
- +
- + /**
- + * Return the address of the peer node
- + * @return The address of the peer node
- + */
- + int getPeerNode () { return peerIndex_; }
- +
- + /**
- + * Set the connection for delay-intolerant management messages
- + * @param connection The connection used as basic
- + */
- + void setBasic (Connection * connection);
- +
- + /**
- + * Return the connection used for delay-intolerant messages
- + */
- + Connection* getBasic () { return basic_; }
- +
- + /**
- + * Set the connection for delay-tolerant management messages
- + * @param connection
- + */
- + void setPrimary (Connection * connection);
- +
- + /**
- + * Return the connection used for delay-tolerant messages
- + */
- + inline Connection* getPrimary () { return primary_; }
- +
- + /**
- + * Set the channel used for standard-based messages
- + * @param connection
- + */
- + void setSecondary (Connection * connection);
- +
- + /**
- + * Return the connection used for standard-based messages
- + */
- + Connection* getSecondary () { return secondary_; }
- +
- + /**
- + * Set the channel used for data messages
- + * @param connection
- + */
- + void setInData (Connection * connection);
- +
- + /**
- + * Set the channel used for data messages
- + * @param connection
- + */
- + void setOutData (Connection * connection);
- +
- + /**
- + * Return the connection used for data messages
- + */
- + Connection* getOutData () { return outdata_; }
- +
- + /**
- + * Return the connection used for data messages
- + */
- + Connection* getInData () { return indata_; }
- +
- + /**
- + * Set the time the last packet was received
- + * @param time The time the last packet was received
- + */
- + void setRxTime (double time);
- +
- + /**
- + * Get the time the last packet was received
- + * @return The time the last packet was received
- + */
- + double getRxTime ();
- +
- + /**
- + * Return the stat watch
- + * @return The stat watch
- + */
- + StatWatch * getStatWatch();
- +
- + /**
- + * Return true if the peer is going down
- + * @return true if the peer is going down
- + */
- + inline bool isGoingDown () { return going_down_; }
- +
- + /**
- + * Set the status of going down
- + * @param status The link going down status
- + */
- + inline void setGoingDown (bool status) { going_down_ = status; }
- +
- + // Chain element to the list
- + inline void insert_entry(struct peerNode *head) {
- + LIST_INSERT_HEAD(head, this, link);
- + }
- +
- + // Return next element in the chained list
- + PeerNode* next_entry(void) const { return link.le_next; }
- +
- + // Remove the entry from the list
- + inline void remove_entry() {
- + LIST_REMOVE(this, link);
- + }
- +protected:
- +
- + /*
- + * Pointer to next in the list
- + */
- + LIST_ENTRY(PeerNode) link;
- + //LIST_ENTRY(PeerNode); //for magic draw
- +
- +private:
- + /**
- + * Mac address of peer node
- + */
- + int peerIndex_;
- +
- + /**
- + * Used to send delay intolerant management messages
- + */
- + Connection* basic_;
- + /**
- + * Used to send delay tolerant mac messages
- + */
- + Connection* primary_;
- + /**
- + * Used to transport standard-based protocol (DHCP...)
- + */
- + Connection* secondary_;
- + /**
- + * Incomfing data connection to this client
- + */
- + Connection* indata_;
- +
- + /**
- + * Outgoing data connection to this client
- + */
- + Connection* outdata_;
- +
- + /**
- + * Time last packet was received for this peer
- + */
- + double rxtime_;
- +
- + /**
- + * Received signal strength stats
- + */
- + StatWatch rxp_watch_;
- +
- + /**
- + * Inidicate the link going down status of the peer node
- + */
- + bool going_down_;
- +
- +};
- +#endif //PEERNODE_H
- +
- diff -Naur ns-2.29-org/wimax/plot-data ns-2.29/wimax/plot-data
- --- ns-2.29-org/wimax/plot-data 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/plot-data 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,17 @@
- +reset
- +set terminal post eps
- +set output "synch.eps"
- +set nogrid
- +#set logscale y
- +set xlabel "dcd interval (s)"
- +set ylabel "Synchronization latency (s)"
- +set xrange [0:10]
- +set yrange [0:11]
- +#set key 45,0.45
- +set title "Thoeratical synchronization latency"
- +plot "result1.dat" using 1:3 title "ucd interval=1s" with lp,
- +"result2.dat" using 1:3 title "ucd interval=2s" with lp,
- +"result5.dat" using 1:3 title "ucd interval=5s" with lp,
- +"result10.dat" using 1:3 title "ucd interval=10s" with lp
- +
- +
- diff -Naur ns-2.29-org/wimax/scheduling/bsscheduler.cc ns-2.29/wimax/scheduling/bsscheduler.cc
- --- ns-2.29-org/wimax/scheduling/bsscheduler.cc 1969-12-31 19:00:00.000000000 -0500
- +++ ns-2.29/wimax/scheduling/bsscheduler.cc 2006-09-22 17:27:47.000000000 -0400
- @@ -0,0 +1,1003 @@
- +/* 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 "bsscheduler.h"
- +#include "burst.h"
- +#include "dlburst.h"
- +#include "ulburst.h"
- +#include "random.h"
- +#include "wimaxctrlagent.h"
- +
- +/**
- + * Bridge to TCL for BSScheduler
- + */
- +static class BSSchedulerClass : public TclClass {
- +public:
- + BSSchedulerClass() : TclClass("WimaxScheduler/BS") {}
- + TclObject* create(int, const char*const*) {
- + return (new BSScheduler());
- +
- + }
- +} class_bsscheduler;
- +
- +/*
- + * Create a scheduler
- + */
- +BSScheduler::BSScheduler () : cl_head_(0), cl_tail_(0), ctrlagent_(0)
- +{
- + debug2 ("BSScheduler createdn");
- + LIST_INIT (&t17_head_);
- + LIST_INIT (&scan_stations_);
- + LIST_INIT (&fast_ranging_head_);
- + bw_peer_ = NULL;
- + bw_node_index_ = 0;
- + default_mod_ = OFDM_BPSK_1_2;
- + contention_size_ = MIN_CONTENTION_SIZE;
- + sendDCD = false;
- + dlccc_ = 0;
- + sendUCD = false;
- + ulccc_ = 0;
- +}
- +
- +/*
- + * Interface with the TCL script
- + * @param argc The number of parameter
- + * @param argv The list of parameters
- + */
- +int BSScheduler::command(int argc, const char*const* argv)
- +{
- + if (argc == 3) {
- + if (strcmp(argv[1], "set-default-modulation") == 0) {
- + if (strcmp(argv[2], "OFDM_BPSK_1_2") == 0)
- + default_mod_ = OFDM_BPSK_1_2;
- + else if (strcmp(argv[2], "OFDM_QPSK_1_2") == 0)
- + default_mod_ = OFDM_QPSK_1_2;
- + else if (strcmp(argv[2], "OFDM_QPSK_3_4") == 0)
- + default_mod_ = OFDM_QPSK_3_4;
- + else if (strcmp(argv[2], "OFDM_16QAM_1_2") == 0)
- + default_mod_ = OFDM_16QAM_1_2;
- + else if (strcmp(argv[2], "OFDM_16QAM_3_4") == 0)
- + default_mod_ = OFDM_16QAM_3_4;
- + else if (strcmp(argv[2], "OFDM_64QAM_2_3") == 0)
- + default_mod_ = OFDM_64QAM_2_3;
- + else if (strcmp(argv[2], "OFDM_64QAM_3_4") == 0)
- + default_mod_ = OFDM_64QAM_3_4;
- + else
- + return TCL_ERROR;
- + return TCL_OK;
- + }
- + else if (strcmp(argv[1], "set-contention-size") == 0) {
- + contention_size_ = atoi (argv[2]);
- + assert (contention_size_>=0);
- + return TCL_OK;
- + }
- + }
- + return TCL_ERROR;
- +}
- +
- +/**
- + * Initializes the scheduler
- + */
- +void BSScheduler::init ()
- +{
- + WimaxScheduler::init();
- +
- + /*print debug information */
- + int nbPS = (int) round((mac_->getFrameDuration()/mac_->getPhy()->getPS()));
- + debug2 ("duration=%f, PStime=%f, nbPS=%d,Symbol time=%f, %d n",mac_->getFrameDuration(), mac_->getPhy()->getPS(), nbPS, mac_->getPhy()->getSymbolTime (), mac_->getPhy()->getSymbolPS());
- +
- + //At initialization, allocate one DL burst
- + //and contention windows
- + //1-create one profile to be used for broadcast
- + // packets (and DL_MAP...)
- + Profile *p = map_->getDlSubframe()->addProfile ((int)round((mac_->getPhy()->getFreq()/1000)), default_mod_);
- + p->setIUC (DIUC_PROFILE_1);
- + map_->getDlSubframe()->getPdu ()->setPreamble (DL_PREAMBLE); //preamble + fch
- + //2-add the burst to carry the broadcast message
- + DlBurst *b = (DlBurst*) map_->getDlSubframe()->getPdu ()->addBurst (0);
- + b->setCid ( BROADCAST_CID );
- + b->setIUC (p->getIUC());
- + b->setStarttime (0); //after preamble and fch
- + b->setDuration (INIT_DL_DURATION); //enough to send DL_MAP...
- + b->setPreamble(true); //this is the first burst after preamble
- + //3-Add the End of map element
- + b = (DlBurst*) map_->getDlSubframe()->getPdu ()->addBurst (1);
- + b->setIUC (DIUC_END_OF_MAP);
- + b->setStarttime (INIT_DL_DURATION);
- +
- + //create uplink
- + //start of UL subframe is after DL and TTG and unit is PS
- + int starttime = (INIT_DL_DURATION+DL_PREAMBLE)*mac_->getPhy()->getSymbolPS()+mac_->phymib_.ttg;
- + map_->getUlSubframe()->setStarttime (starttime);
- + int slotleft = nbPS - starttime - mac_->phymib_.rtg;
- + //duration is in unit of ofdm symbols
- + int rangingslot = slotleft/2;
- + int rangingduration =(int) round(((mac_->getPhy()->getPS()*rangingslot)/mac_->getPhy()->getSymbolTime()));
- + int bwduration = (int) round(((mac_->getPhy()->getPS()*(slotleft - rangingslot))/mac_->getPhy()->getSymbolTime()));
- +
- + //we open the uplink to initial ranging and bw requests
- + //add profile for the ranging burst
- + p = map_->getUlSubframe()->addProfile (0, default_mod_);
- + p->setIUC (UIUC_INITIAL_RANGING);
- + ContentionSlot *slot = map_->getUlSubframe()->getRanging ();
- + slot->setSize (getInitRangingopportunity ());
- + slot->setBackoff_start (mac_->macmib_.rng_backoff_start);
- + slot->setBackoff_stop (mac_->macmib_.rng_backoff_stop);
- + //create burst to represent the contention slot
- + Burst* b2 = map_->getUlSubframe()->addPhyPdu (0,0)->addBurst (0);
- + b2->setIUC (UIUC_INITIAL_RANGING);
- + b2->setDuration (rangingduration);
- + b2->setStarttime (0); //we put the contention at the begining
- +
- + //now the bw request
- + //add profile for the bw burst
- + p = map_->getUlSubframe()->addProfile (0, default_mod_);
- + p->setIUC (UIUC_REQ_REGION_FULL);
- + slot = map_->getUlSubframe()->getBw_req ();
- + slot->setSize (getBWopportunity ());
- + slot->setBackoff_start (mac_->macmib_.bw_backoff_start);
- + slot->setBackoff_stop (mac_->macmib_.rng_backoff_stop);
- + b2 = map_->getUlSubframe()->addPhyPdu (1,0)->addBurst (0);
- + b2->setIUC (UIUC_REQ_REGION_FULL);
- + b2->setDuration (bwduration);
- + b2->setStarttime (rangingduration); //start after the ranging slot
- +
- + //end of map
- + b2 = map_->getUlSubframe()->addPhyPdu (2,0)->addBurst (0);
- + b2->setIUC (UIUC_END_OF_MAP);
- + b2->setStarttime (rangingduration+bwduration);
- +
- + //schedule the first frame by using a random backoff to avoid
- + //synchronization between BSs.
- + double stime = Random::uniform(0, mac_->getFrameDuration ());
- + dl_timer_->sched (stime);
- +
- + ul_timer_->sched (stime+starttime*mac_->getPhy()->getPS());
- +
- + //also start the DCD and UCD timer
- + dcdtimer_ = new WimaxDCDTimer (mac_);
- + ucdtimer_ = new WimaxUCDTimer (mac_);
- + nbradvtimer_ = new WimaxMobNbrAdvTimer (mac_);
- + dcdtimer_->start (mac_->macmib_.dcd_interval);
- + ucdtimer_->start (mac_->macmib_.ucd_interval);
- + nbradvtimer_->start (mac_->macmib_.nbr_adv_interval+stime);
- +}
- +
- +/**
- + * Compute and return the bandwidth request opportunity size
- + * @return The bandwidth request opportunity size
- + */
- +int BSScheduler::getBWopportunity ()
- +{
- + int nbPS = BW_REQ_PREAMBLE * mac_->getPhy()->getSymbolPS();
- + //add PS for carrying header
- + nbPS += (int) round((mac_->getPhy()->getTrxTime (HDR_MAC802_16_SIZE, map_->getUlSubframe()->getProfile(UIUC_REQ_REGION_FULL)->getEncoding())/mac_->getPhy()->getPS ()));
- + //printf ("BWopportunity size=%dn", nbPS);
- + return nbPS;
- +}
- +
- +/**
- + * Compute and return the initial ranging opportunity size
- + * @return The initial ranging opportunity size
- + */
- +int BSScheduler::getInitRangingopportunity ()
- +{
- + int nbPS = INIT_RNG_PREAMBLE * mac_->getPhy()->getSymbolPS();
- + //add PS for carrying header
- + nbPS += (int) round((mac_->getPhy()->getTrxTime (RNG_REQ_SIZE+HDR_MAC802_16_SIZE, map_->getUlSubframe()->getProfile(UIUC_INITIAL_RANGING)->getEncoding())/mac_->getPhy()->getPS ()));
- + //printf ("Init ranging opportunity size=%dn", nbPS);
- + return nbPS;
- +}
- +
- +/**
- + * Called when a timer expires
- + * @param The timer ID
- + */
- +void BSScheduler::expire (timer_id id)
- +{
- + switch (id) {
- + case WimaxDCDTimerID:
- + sendDCD = true;
- + mac_->debug ("At %f in Mac %d DCDtimer expiredn", NOW, mac_->addr());
- + dcdtimer_->start (mac_->macmib_.dcd_interval);
- + break;
- + case WimaxUCDTimerID:
- + sendUCD = true;
- + mac_->debug ("At %f in Mac %d UCDtimer expiredn", NOW, mac_->addr());
- + ucdtimer_->start (mac_->macmib_.ucd_interval);
- + break;
- + case WimaxMobNbrAdvTimerID:
- + send_nbr_adv();
- + nbradvtimer_->start (mac_->macmib_.nbr_adv_interval);
- + break;
- + default:
- + mac_->debug ("Warning: unknown timer expired in BSSchedulern");
- + }
- +}
- +
- +/**
- + * Set the control agent
- + */
- +void BSScheduler::setCtrlAgent (WimaxCtrlAgent *agent)