A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
service-flow.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008,2009 INRIA, UDcast
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
7 * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
8 * <amine.ismail@UDcast.com>
9 */
10
11#include "service-flow.h"
12
13#include "service-flow-record.h"
14#include "wimax-tlv.h"
15
16#include "ns3/simulator.h"
17
18namespace ns3
19{
20
33
35 : m_sfid(0),
36 m_direction(SF_DIRECTION_DOWN),
37 m_type(SF_TYPE_PROVISIONED),
38 m_connection(nullptr),
39 m_isEnabled(false),
40 m_record(new ServiceFlowRecord())
41{
42 InitValues();
43 m_isMulticast = false;
45}
46
48{
49 InitValues();
51 m_isEnabled = false;
52 m_connection = connection;
53 m_connection->SetServiceFlow(this);
55 m_direction = direction;
56 m_sfid = sfid;
57 m_isMulticast = false;
59}
60
62{
63 InitValues();
64 m_connection = nullptr;
65 m_isEnabled = false;
69 "Invalid TLV");
70
71 SfVectorTlvValue* param;
72 param = (SfVectorTlvValue*)(tlv.PeekValue());
73
75 {
77 }
78 else
79 {
81 }
82
83 for (auto iter = param->Begin(); iter != param->End(); ++iter)
84 {
85 switch ((*iter)->GetType())
86 {
88 m_sfid = ((U32TlvValue*)((*iter)->PeekValue()))->GetValue();
89 break;
90 }
92 uint16_t cid = ((U16TlvValue*)((*iter)->PeekValue()))->GetValue();
94 break;
95 }
97 m_qosParamSetType = ((U8TlvValue*)((*iter)->PeekValue()))->GetValue();
98 break;
99 }
101 m_trafficPriority = ((U8TlvValue*)((*iter)->PeekValue()))->GetValue();
102 break;
103 }
105 m_maxSustainedTrafficRate = ((U32TlvValue*)((*iter)->PeekValue()))->GetValue();
106 break;
107 }
109 m_maxTrafficBurst = ((U32TlvValue*)((*iter)->PeekValue()))->GetValue();
110 break;
111 }
113 m_minReservedTrafficRate = ((U32TlvValue*)((*iter)->PeekValue()))->GetValue();
114 break;
115 }
117 m_minTolerableTrafficRate = ((U32TlvValue*)((*iter)->PeekValue()))->GetValue();
118 break;
119 }
122 (ServiceFlow::SchedulingType)((U8TlvValue*)((*iter)->PeekValue()))->GetValue();
123 break;
124 }
126 m_requestTransmissionPolicy = ((U32TlvValue*)((*iter)->PeekValue()))->GetValue();
127 break;
128 }
130 m_toleratedJitter = ((U32TlvValue*)((*iter)->PeekValue()))->GetValue();
131 break;
132 }
134 m_maximumLatency = ((U32TlvValue*)((*iter)->PeekValue()))->GetValue();
135 break;
136 }
138 m_fixedversusVariableSduIndicator = ((U8TlvValue*)((*iter)->PeekValue()))->GetValue();
139 break;
140 }
143 (CsSpecification)(((U8TlvValue*)((*iter)->PeekValue()))->GetValue());
144 break;
145 }
146
149 break;
150 }
151 }
152 }
153 m_isMulticast = false;
155}
156
158{
159 if (m_record != nullptr)
160 {
161 delete m_record;
162 m_record = nullptr;
163 }
164 m_connection = nullptr;
165}
166
167void
169{
170 m_direction = direction;
171}
172
175{
176 return m_direction;
177}
178
179void
181{
182 m_type = type;
183}
184
187{
188 return m_type;
189}
190
191void
193{
194 m_connection = connection;
195 m_connection->SetServiceFlow(this);
196}
197
200{
201 return m_connection;
202}
203
204void
206{
207 m_isEnabled = isEnabled;
208}
209
210bool
212{
213 return m_isEnabled;
214}
215
216void
218{
219 m_record = record;
220}
221
224{
225 return m_record;
226}
227
230{
231 if (!m_connection)
232 {
233 return nullptr;
234 }
235 return m_connection->GetQueue();
236}
237
243
244bool
246{
247 if (!m_connection)
248 {
249 return false;
250 }
251 return m_connection->HasPackets();
252}
253
254bool
256{
257 if (!m_connection)
258 {
259 return false;
260 }
261 return m_connection->HasPackets(packetType);
262}
263
264void
266{
268 Time timeStamp;
269 Ptr<Packet> packet;
270 Time currentTime = Simulator::Now();
271 if (m_connection)
272 {
273 while (m_connection->HasPackets())
274 {
275 packet = m_connection->GetQueue()->Peek(hdr, timeStamp);
276
277 if (currentTime - timeStamp > MilliSeconds(GetMaximumLatency()))
278 {
279 m_connection->Dequeue();
280 }
281 else
282 {
283 break;
284 }
285 }
286 }
287}
288
289void
293
294// ==============================================================================
295
298{
299 return m_sfid;
300}
301
302uint16_t
304{
305 if (!m_connection)
306 {
307 return 0;
308 }
309 return m_connection->GetCid().GetIdentifier();
310}
311
312std::string
317
318uint8_t
323
324uint8_t
329
335
341
347
353
359
365
371
377
378uint8_t
383
384uint8_t
386{
387 return m_sduSize;
388}
389
390uint16_t
392{
393 return m_targetSAID;
394}
395
396uint8_t
398{
399 return m_arqEnable;
400}
401
402uint16_t
404{
405 return m_arqWindowSize;
406}
407
408uint16_t
413
414uint16_t
419
420uint16_t
425
426uint16_t
428{
429 return m_arqSyncLoss;
430}
431
432uint8_t
437
438uint16_t
443
444uint16_t
446{
447 return m_arqBlockSize;
448}
449
455
461
462uint16_t
467
468uint16_t
473
474bool
476{
477 return m_isMulticast;
478}
479
482{
483 return m_modulationType;
484}
485
486// ==============================================================================
487
488void
490{
491 m_sfid = sfid;
492}
493
494void
496{
497 m_serviceClassName = name;
498}
499
500void
502{
503 m_qosParamSetType = type;
504}
505
506void
508{
509 m_trafficPriority = priority;
510}
511
512void
514{
515 m_maxSustainedTrafficRate = maxSustainedRate;
516}
517
518void
520{
521 m_maxTrafficBurst = maxTrafficBurst;
522}
523
524void
529
530void
535
536void
541
542void
547
548void
553
554void
556{
557 m_maximumLatency = MaximumLatency;
558}
559
560void
565
566void
568{
569 m_sduSize = sduSize;
570}
571
572void
573ServiceFlow::SetTargetSAID(uint16_t targetSaid)
574{
575 m_targetSAID = targetSaid;
576}
577
578void
580{
581 m_arqEnable = arqEnable;
582}
583
584void
585ServiceFlow::SetArqWindowSize(uint16_t arqWindowSize)
586{
587 m_arqWindowSize = arqWindowSize;
588}
589
590void
595
596void
601
602void
604{
605 m_arqBlockLifeTime = lifeTime;
606}
607
608void
610{
611 m_arqSyncLoss = syncLoss;
612}
613
614void
616{
617 m_arqDeliverInOrder = inOrder;
618}
619
620void
625
626void
628{
629 m_arqBlockSize = size;
630}
631
632void
637
638void
643
644void
645ServiceFlow::SetUnsolicitedGrantInterval(uint16_t unsolicitedGrantInterval)
646{
647 m_unsolicitedGrantInterval = unsolicitedGrantInterval;
648}
649
650void
651ServiceFlow::SetUnsolicitedPollingInterval(uint16_t unsolicitedPollingInterval)
652{
653 m_unsolicitedPollingInterval = unsolicitedPollingInterval;
654}
655
656void
658{
659 m_isMulticast = isMulticast;
660}
661
662void
664{
665 m_modulationType = modulationType;
666}
667
668void
703
704void
733
735{
736 m_sfid = sf.GetSfid();
749 m_sduSize = sf.GetSduSize();
760 m_type = sf.GetType();
764 (*m_record) = (*sf.GetRecord());
767}
768
771{
772 m_sfid = o.GetSfid();
785 m_sduSize = o.GetSduSize();
796 m_type = o.GetType();
801 if (m_record != nullptr)
802 {
803 delete m_record;
804 }
805
807
808 (*m_record) = (*o.GetRecord());
809 return *this;
810}
811
812char*
814{
815 switch (m_schedulingType)
816 {
817 case SF_TYPE_UGS:
818 return (char*)"UGS";
819 case SF_TYPE_RTPS:
820 return (char*)"rtPS";
821 case SF_TYPE_NRTPS:
822 return (char*)"nrtPS";
823 case SF_TYPE_BE:
824 return (char*)"BE";
825 default:
826 NS_FATAL_ERROR("Invalid scheduling type");
827 }
828 return nullptr;
829}
830
831Tlv
833{
834 SfVectorTlvValue tmpSfVector;
836 tmpSfVector.Add(Tlv(SfVectorTlvValue::CID, 2, U16TlvValue(GetCid())));
837 tmpSfVector.Add(
841 4,
843 tmpSfVector.Add(
846 4,
849 4,
851 tmpSfVector.Add(
854 4,
859 1,
864 tmpSfVector.Add(m_convergenceSublayerParam.ToTlv());
866 {
867 return Tlv(Tlv::UPLINK_SERVICE_FLOW, tmpSfVector.GetSerializedSize(), tmpSfVector);
868 }
869 else
870 {
871 return Tlv(Tlv::DOWNLINK_SERVICE_FLOW, tmpSfVector.GetSerializedSize(), tmpSfVector);
872 }
873}
874
875bool
877 Ipv4Address dstAddress,
878 uint16_t srcPort,
879 uint16_t dstPort,
880 uint8_t proto) const
881{
883 dstAddress,
884 srcPort,
885 dstPort,
886 proto);
887}
888} // namespace ns3
@ TRANSPORT
Definition cid.h:35
CsParameters class.
Tlv ToTlv() const
creates a tlv from the classifier record
IpcsClassifierRecord GetPacketClassifierRule() const
This class implements the Generic mac Header as described by IEEE Standard for Local and metropolitan...
bool CheckMatch(Ipv4Address srcAddress, Ipv4Address dstAddress, uint16_t srcPort, uint16_t dstPort, uint8_t proto) const
check if a packets can be used with this classifier
Ipv4 addresses are stored in host order in this class.
HeaderType
Header type enumeration.
Smart pointer class similar to boost::intrusive_ptr.
This class implements service flows as described by the IEEE-802.16 standard.
uint16_t m_targetSAID
target SAID
uint32_t m_requestTransmissionPolicy
request transmission policy
uint16_t GetArqSyncLoss() const
Get ARQ sync loss.
void SetTargetSAID(uint16_t targetSaid)
Set target SAID.
void SetRequestTransmissionPolicy(uint32_t policy)
Set request transmission policy.
void SetDirection(Direction direction)
Set direction.
uint16_t m_arqBlockSize
ARQ block size.
void SetSfid(uint32_t sfid)
Set SFID.
void SetCsSpecification(CsSpecification spec)
Set CS specification.
uint16_t GetTargetSAID() const
Get target SAID.
ServiceFlow & operator=(const ServiceFlow &o)
assignment operator
std::string m_serviceClassName
service class name
uint32_t GetRequestTransmissionPolicy() const
Get request transmission policy.
uint32_t m_toleratedJitter
tolerated jitter
ServiceFlow::SchedulingType GetServiceSchedulingType() const
Get service scheduling type.
uint16_t GetArqWindowSize() const
Get ARQ retry timeout transmit.
uint32_t GetMaxSustainedTrafficRate() const
Get max sustained traffic rate.
void SetArqEnable(uint8_t arqEnable)
Set ARQ enable.
void SetArqBlockSize(uint16_t size)
Set ARQ block size.
uint32_t GetMaxTrafficBurst() const
Get max traffic burst.
void SetServiceClassName(std::string name)
Set service class name.
uint32_t GetSfid() const
Get SFID.
uint32_t m_maximumLatency
maximum latency
uint32_t m_minTolerableTrafficRate
minimum tolerable traffic rate
uint32_t GetMaximumLatency() const
Get maximum latency.
uint8_t GetFixedversusVariableSduIndicator() const
Get fixed versus variable SDU indicator.
void PrintQoSParameters() const
Print QoS parameters.
uint16_t m_arqBlockLifeTime
ARQ block life time.
ServiceFlow::SchedulingType GetSchedulingType() const
Get scheduling type.
~ServiceFlow()
Destructor.
uint16_t m_unsolicitedGrantInterval
unsolicited grant interval
uint16_t GetUnsolicitedPollingInterval() const
Get unsolicited polling interval.
CsParameters m_convergenceSublayerParam
convergence sublayer parameters
bool m_isEnabled
is enabled?
std::string GetServiceClassName() const
Get service class name.
uint16_t m_arqRetryTimeoutTx
ARQ retry timeout transmit.
uint8_t m_trafficPriority
traffic priority
uint32_t m_minReservedTrafficRate
minimum reserved traffic rate
Ptr< WimaxConnection > m_connection
connection
void SetMaxTrafficBurst(uint32_t maxTrafficBurst)
Set maximum traffic burst.
void SetArqSyncLoss(uint16_t syncLoss)
Set ARQ sync loss.
void SetServiceSchedulingType(ServiceFlow::SchedulingType schedType)
Set service scheduling type.
Tlv ToTlv() const
creates a TLV from this service flow
uint8_t GetQosParamSetType() const
Get QOS parameter set type.
uint32_t m_maxSustainedTrafficRate
maximum sustained traffic rate
void SetMaximumLatency(uint32_t MaximumLatency)
Set maximum latency.
uint8_t m_arqDeliverInOrder
ARQ deliver in order.
void SetModulation(WimaxPhy::ModulationType modulationType)
Set modulation.
uint16_t GetArqRetryTimeoutRx() const
Get ARQ retry timeout receive.
void InitValues()
Initialize values.
void SetQosParamSetType(uint8_t type)
Set QOS parameter set type.
uint32_t m_maxTrafficBurst
maximum traffic burst
uint16_t m_unsolicitedPollingInterval
unsolicited polling interval
uint8_t m_qosParamSetType
QOS parameter type.
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
ServiceFlow()
Default constructor.
uint16_t m_arqSyncLoss
ARQ sync loss.
void SetArqWindowSize(uint16_t arqWindowSize)
Set ARQ retry timeout transmit.
void SetConvergenceSublayerParam(CsParameters csparam)
Set convergence sublayer parameters.
void SetSduSize(uint8_t sduSize)
Set SDU size.
void SetRecord(ServiceFlowRecord *record)
Set service flow record.
char * GetSchedulingTypeStr() const
Get scheduling type string.
uint8_t GetTrafficPriority() const
Get traffic priority.
bool m_isMulticast
is multicast?
uint8_t GetArqEnable() const
Get ARQ enable.
uint32_t GetMinReservedTrafficRate() const
Get minimum reserved traffic rate.
void SetArqPurgeTimeout(uint16_t timeout)
Set ARQ purge timeout.
uint16_t m_arqPurgeTimeout
ARQ purge timeout.
Type
Type enumeration.
uint16_t GetCid() const
Get CID.
bool GetIsEnabled() const
Get is enabled flag.
void SetTrafficPriority(uint8_t priority)
Set traffic priority.
ServiceFlowRecord * m_record
service flow record
bool HasPackets() const
Check if packets are present.
uint8_t GetSduSize() const
Get SDU size.
void SetArqBlockLifeTime(uint16_t lifeTime)
Set ARQ block lifetime.
CsSpecification GetCsSpecification() const
Get CS specification.
void CopyParametersFrom(ServiceFlow sf)
Copy parameters from another service flow.
uint16_t GetArqRetryTimeoutTx() const
Get ARQ retry timeout transmit.
void SetMinTolerableTrafficRate(uint32_t minJitter)
Set minimum tolerable traffic rate.
uint16_t m_arqWindowSize
ARQ window size.
void SetIsMulticast(bool isMulticast)
Set is multicast.
uint8_t GetArqDeliverInOrder() const
Get ARQ deliver in order.
void SetArqRetryTimeoutTx(uint16_t timeout)
Set ARQ retry timeout transmit.
ServiceFlow::SchedulingType m_schedulingType
scheduling type
Type GetType() const
Get type of service flow.
uint8_t m_arqEnable
ARQ enable.
uint8_t m_fixedversusVariableSduIndicator
fixed versus variable SDI indicator
uint32_t GetMinTolerableTrafficRate() const
Get minimum tolerable traffic rate.
void SetToleratedJitter(uint32_t jitter)
Set tolerated jitter.
WimaxPhy::ModulationType GetModulation() const
Get modulation.
void SetUnsolicitedGrantInterval(uint16_t unsolicitedGrantInterval)
Set unsolicited grant interval.
ServiceFlowRecord * GetRecord() const
Get service flow record.
uint8_t m_sduSize
SDU size.
void SetArqDeliverInOrder(uint8_t inOrder)
Set ARQ deliver in order.
uint16_t GetArqBlockLifeTime() const
Get ARQ block lifetime.
uint16_t m_arqRetryTimeoutRx
ARQ retry timeout receive.
uint16_t GetArqBlockSize() const
Get ARQ block size.
void SetArqRetryTimeoutRx(uint16_t timeout)
Set ARQ retry timeout receive.
void SetUnsolicitedPollingInterval(uint16_t unsolicitedPollingInterval)
Set unsolicited polling interval.
void SetMinReservedTrafficRate(uint32_t minResvRate)
Set minimum reserved traffic rate.
void SetType(Type type)
Set type of service flow.
uint16_t GetArqPurgeTimeout() const
Get ARQ purge timeout.
bool GetIsMulticast() const
Get is multicast.
CsSpecification
section 11.13.19.2 CS parameter encoding rules, page 707
bool CheckClassifierMatch(Ipv4Address srcAddress, Ipv4Address dstAddress, uint16_t srcPort, uint16_t dstPort, uint8_t proto) const
check classifier match.
CsSpecification m_csSpecification
CS specification.
uint32_t GetToleratedJitter() const
Get tolerated jitter.
Direction
Direction enumeration.
Ptr< WimaxMacQueue > GetQueue() const
Get pointer to queue.
uint16_t GetUnsolicitedGrantInterval() const
Get unsolicited grant interval.
uint32_t m_sfid
SFID.
void SetFixedversusVariableSduIndicator(uint8_t sduIndicator)
Set fixed versus variable SDU indicator.
Direction GetDirection() const
Get direction.
Direction m_direction
direction
CsParameters GetConvergenceSublayerParam() const
Get convergence sublayer.
void SetMaxSustainedTrafficRate(uint32_t maxSustainedRate)
Set max sustained traffic rate.
Ptr< WimaxConnection > GetConnection() const
Can return a null connection is this service flow has not been associated yet to a connection.
void CleanUpQueue()
Shall be called only by BS.
WimaxPhy::ModulationType m_modulationType
modulation type
void SetConnection(Ptr< WimaxConnection > connection)
Set connection.
void SetIsEnabled(bool isEnabled)
Set is enabled flag.
this class implements a structure to manage some parameters and statistics related to a service flow
SfVectorTlvValue class.
Definition wimax-tlv.h:326
@ Fixed_length_versus_Variable_length_SDU_Indicator
Definition wimax-tlv.h:345
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
This class implements the Type-Len-Value structure channel encodings as described by "IEEEStandard fo...
Definition wimax-tlv.h:76
uint8_t GetType() const
Get type value.
Definition wimax-tlv.cc:200
TlvValue * PeekValue()
Peek value.
Definition wimax-tlv.cc:212
@ UPLINK_SERVICE_FLOW
Definition wimax-tlv.h:85
@ DOWNLINK_SERVICE_FLOW
Definition wimax-tlv.h:84
U16TlvValue class.
Definition wimax-tlv.h:204
U32TlvValue class.
Definition wimax-tlv.h:244
U8TlvValue class.
Definition wimax-tlv.h:164
uint32_t GetSerializedSize() const override
Get serialized size in bytes.
Definition wimax-tlv.cc:240
Iterator End() const
End iterator.
Definition wimax-tlv.cc:267
Iterator Begin() const
Begin iterator.
Definition wimax-tlv.cc:261
void Add(const Tlv &val)
Add a TLV.
Definition wimax-tlv.cc:273
ModulationType
ModulationType enumeration.
Definition wimax-phy.h:43
@ MODULATION_TYPE_QPSK_12
Definition wimax-phy.h:45
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1356
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Time timeout