📄 mac-802_16.h
字号:
/**************************************************************************************
* *Copyright (c) 2006 Regents of the University of Chang Gung *
* *All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. All advertising materials mentioning features or use of this software *
* must display the following acknowledgement: *
* This product includes software developed by the Computer Systems *
* Engineering Group at Lawrence Berkeley Laboratory. *
* 4. Neither the name of the University nor of the Laboratory may be used *
* to endorse or promote products derived from this software without *
* specific prior written permission. *
*5. If you have any problem about these codes, *
please mail to antibanish@gmail.com or b9229008@stmail.cgu.edu.tw *
**************************************************************************************/
#ifndef ns_mac_80216_h
#define ns_mac_80216_h
#include "timer-802_16.h"
#include "ip.h"
#include "address.h"
#include "marshall.h"
#include "agent.h"
#include "tclcl.h"
#include "packet.h"
#include "cmu-trace.h"
#include "basetrace.h"
#include "connector.h"
struct SFID_List{
SFID_List(){
SFID = -1;
TCID = -1;
BW = -1;
destIP = -1;
next = NULL;
}
int SFID;
int TCID;
int BW;
int destIP;
SFID_List* next;
};
struct BCID_List{
BCID_List(){
BCID = -1;
SS_UL_BW = -1;
SS_DL_BW = -1;
srcIP = -1;
SF = NULL;
SF_tail = SF;
next = NULL;
}
int BCID;
int srcIP;
int SS_UL_BW;
int SS_DL_BW;
SFID_List* SF;
SFID_List* SF_tail;
BCID_List* next;
};
struct Queue_construct{
Queue_construct():destIP(-5),BCID(-1){}
SerQueue UGS;
SerQueue ertPS;
SerQueue rtPS;
SerQueue nrtPS;
SerQueue BE;
SerQueue PDUQueue;
SerQueue fragQueue;
int destIP;
int BCID;
Queue_construct* next_;
};
struct Queue_List{
Queue_construct* head_;
Queue_construct* tail_;
Queue_List():head_(0),tail_(0){}
void enque(int destip){
Queue_construct *p=new Queue_construct;
p->destIP=destip;
if (!tail_) head_= tail_= p;
else {
tail_->next_= p;
tail_= p;
}
tail_->next_= 0;
}
Queue_construct* lookup(int DESTIP) {
for (Queue_construct* p = head_; p != 0; p = p->next_) {
if (p->destIP==DESTIP)
return (p);
}
return 0;
}
Queue_construct* Search_BCID(int bcid) {
for (Queue_construct* p = head_; p != 0; p = p->next_) {
if (p->BCID==bcid)
return (p);
}
return 0;
}
};
enum dir_t { UL=0, DL= 1};
enum MacStatus {MSEND = 0, MIDLE = 1};
class Mac802_16 : public Mac {
friend class TX16timer;
friend class RX16timer;
friend class Defer16Timer;
friend class ULmap16timer;
friend class DLmap16timer;
friend class Preamble;
friend class Backofftimer;
friend class ResumeSStimer;
friend class ResumeBStimer;
friend class SendULmap16timer;
friend class SendDLmap16timer;
friend class BWBackofftimer;
public:
Mac802_16();
void sendRNGREQ(int); //used by SS to send RNG_REQ message to BS
void sendRNGRSP(int ssmac,int BSCID);
void sendBWREQ(int BR, int CID, packet_t pype, int DA, int SA);
void BS_Scheduler(int BCID, int Symbol_number);
void SS_Scheduler(int BCID, int Symbol_number);
void Bandwidth_Management();
bool Call_Admission_Control(int BCID,packet_t ptype,int BR_BW);
void PDU_Generator(packet_t ser_type, int grab,int bcid);
void Frag_or_Pack(packet_t ser_type, int num, int usr);
void SS_Frag_or_Pack(packet_t ser_type, int num, int user);
void SS_PDU_Generator(packet_t ser_type, int grab_byte,int bcid);
void transmit(Packet*,double);
int Insert_BCID(int srcIP);
int Insert_SFID(int BCID,packet_t ptype,dir_t direction_);
BCID_List* Search_BCID(int BCID);
BCID_List* Search_BCID_macSA(int srcIP);
void sendULMAP(int SS_count);
void sendDLMAP(int SS_count);
Packet* Add_Mac_Header(Packet* p,int CID,packet_t ptype);
SFID_List* Search_SFID(int SFID);
Queue_List* Insert_TCID(int SFID,int destID);
Queue_construct* Search_Queue(int destIP);
protected:
int creatid; //Node ID, used to identify nodes
double txtime(Packet *p); //璸衡┮肚癳
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -