24 #include "ns3/simulator.h"
25 #include "ns3/packet.h"
26 #include "service-flow.h"
27 #include "service-flow-manager.h"
29 #include "bs-net-device.h"
30 #include "ss-record.h"
31 #include "ns3/pointer.h"
33 #include "wimax-connection.h"
34 #include "ss-manager.h"
35 #include "connection-manager.h"
36 #include "bs-uplink-scheduler.h"
37 #include "ss-scheduler.h"
38 #include "ns3/buffer.h"
39 #include "service-flow-record.h"
44 BsServiceFlowManager::BsServiceFlowManager (Ptr<BaseStationNetDevice> device)
47 m_maxDsaRspRetries (100)
52 BsServiceFlowManager::~BsServiceFlowManager (
void)
65 m_maxDsaRspRetries = maxDsaRspRetries;
69 BsServiceFlowManager::GetMaxDsaRspRetries (
void)
const
71 return m_maxDsaRspRetries;
75 BsServiceFlowManager::GetDsaAckTimeoutEvent (
void)
const
77 return m_dsaAckTimeoutEvent;
83 ServiceFlowManager::AddServiceFlow (serviceFlow);
89 return ServiceFlowManager::GetServiceFlow (sfid);
95 return ServiceFlowManager::GetServiceFlow (cid);
98 std::vector<ServiceFlow*>
101 return ServiceFlowManager::GetServiceFlows (schedulingType);
105 BsServiceFlowManager::CreateDsaRsp (
const ServiceFlow *serviceFlow, uint16_t transactionId)
108 dsaRsp.SetTransactionId (transactionId);
111 dsaRsp.SetConfirmationCode (CONFIRMATION_CODE_SUCCESS);
117 BsServiceFlowManager::ScheduleDsaRsp (ServiceFlow *serviceFlow, Cid cid)
119 Ptr<BaseStationNetDevice> bs = m_device->GetObject<BaseStationNetDevice> ();
121 SSRecord *ssRecord = bs->GetSSManager ()->GetSSRecord (cid);
124 NS_LOG_INFO (
"SS not registered with the BS CID:" << cid);
128 serviceFlow->SetIsEnabled (
true);
129 serviceFlow->SetType (ServiceFlow::SF_TYPE_ACTIVE);
130 ssRecord->AddServiceFlow (serviceFlow);
133 bs->GetUplinkScheduler ()->SetupServiceFlow (ssRecord, serviceFlow);
135 Ptr<Packet> p = Create<Packet> ();
138 if (ssRecord->GetDsaRspRetries () == 0)
140 dsaRsp = CreateDsaRsp (serviceFlow, ssRecord->GetSfTransactionId ());
141 p->AddHeader (dsaRsp);
142 ssRecord->SetDsaRsp (dsaRsp);
146 if (ssRecord->GetDsaRspRetries () < m_maxDsaRspRetries)
148 p->AddHeader (ssRecord->GetDsaRsp ());
152 NS_LOG_DEBUG (
"Service flows could not be initialized!");
156 ssRecord->IncrementDsaRspRetries ();
157 p->AddHeader (ManagementMessageType (ManagementMessageType::MESSAGE_TYPE_DSA_RSP));
164 m_inuseScheduleDsaRspCid = cid;
167 &BsServiceFlowManager::ScheduleDsaRsp,
171 m_device->Enqueue (p, MacHeaderType (), bs->GetConnection (ssRecord->GetPrimaryCid ()));
179 SSRecord *ssRecord = bs->GetSSManager ()->GetSSRecord (cid);
181 NS_LOG_INFO (
"BsServiceFlowManager: Processing DSA-REQ...");
182 if (ssRecord->GetSfTransactionId () != 0)
185 NS_ASSERT_MSG (dsaReq.GetTransactionId () == ssRecord->GetSfTransactionId (),
186 "Error while processing DSA request:the received transaction ID is not expected");
194 transportConnection = BsConManager->CreateConnection (Cid::TRANSPORT);
195 serviceFlow =
new ServiceFlow (m_sfidIndex++, sf.GetDirection (), transportConnection);
196 transportConnection->SetServiceFlow (serviceFlow);
197 serviceFlow->CopyParametersFrom (sf);
198 serviceFlow->SetUnsolicitedGrantInterval (1);
199 serviceFlow->SetUnsolicitedPollingInterval (1);
200 serviceFlow->SetConvergenceSublayerParam (sf.GetConvergenceSublayerParam ());
202 ssRecord->SetSfTransactionId (dsaReq.GetTransactionId ());
203 NS_LOG_INFO (
"BsServiceFlowManager: Creating a new Service flow: SFID = " << serviceFlow->GetSfid () <<
" CID = "
204 << serviceFlow->GetCid ());
213 serviceFlow->CopyParametersFrom (sf);
215 Ptr<WimaxConnection> multicastConnection = bs->GetConnectionManager ()->CreateConnection (Cid::MULTICAST);
216 serviceFlow->SetConnection (multicastConnection);
218 serviceFlow->SetIsEnabled (
true);
219 serviceFlow->SetType (ServiceFlow::SF_TYPE_ACTIVE);
220 serviceFlow->SetIsMulticast (
true);
221 serviceFlow->SetModulation (modulation);
222 bs->GetUplinkScheduler ()->SetupServiceFlow (0, serviceFlow);
226 BsServiceFlowManager::AllocateServiceFlows (
const DsaReq &dsaReq,
Cid cid)
230 ScheduleDsaRsp (serviceFlow, cid);
232 NS_LOG_INFO (
"No service Flow. Could not connect.");
240 SSRecord *ssRecord = bs->GetSSManager ()->GetSSRecord (cid);
242 if (dsaAck.GetTransactionId () != ssRecord->GetSfTransactionId ())
247 ssRecord->SetDsaRspRetries (0);
248 ssRecord->SetSfTransactionId (0);
253 ssRecord->SetAreServiceFlowsAllocated (
true);
smart pointer class similar to boost::intrusive_ptr
void SetServiceFlow(ServiceFlow sf)
specify a service flow to be requested by this message
ServiceFlow GetServiceFlow(void) const
#define NS_LOG_COMPONENT_DEFINE(name)
static void Cancel(const EventId &id)
bool IsRunning(void) const
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
static Cid InitialRanging(void)
bool AreServiceFlowsAllocated()
ServiceFlow * GetServiceFlow(uint32_t sfid) const
ServiceFlow * ProcessDsaReq(const DsaReq &dsaReq, Cid cid)
process a DSA-Req message
#define NS_ASSERT_MSG(condition, message)
void SetMaxDsaRspRetries(uint8_t maxDsaRspRetries)
set the maximum Dynamic ServiceFlow Add (DSA) retries
void ProcessDsaAck(const DsaAck &dsaAck, Cid cid)
process a DSA-ACK message
#define NS_LOG_DEBUG(msg)
void AddServiceFlow(ServiceFlow *serviceFlow)
Add a new service flow.
void AddMulticastServiceFlow(ServiceFlow sf, enum WimaxPhy::ModulationType modulation)
add a multicast service flow
This class is used by the base station to store some information related to subscriber station in the...
std::vector< ServiceFlow * > GetServiceFlows(ServiceFlow::SchedulingType schedulingType) const