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
60
62{
63 InitValues();
64 m_connection = nullptr;
65 m_isEnabled = false;
69 "Invalid TLV");
70
72 param = (SfVectorTlvValue*)(tlv.PeekValue());
73
74 if (tlv.GetType() == Tlv::UPLINK_SERVICE_FLOW)
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
197
200{
201 return m_connection;
202}
203
204void
209
210bool
212{
213 return m_isEnabled;
214}
215
216void
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{
269 Ptr<Packet> packet;
271 if (m_connection)
272 {
273 while (m_connection->HasPackets())
274 {
275 packet = m_connection->GetQueue()->Peek(hdr, timeStamp);
276
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
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
517
518void
523
524void
529
530void
535
536void
541
542void
547
548void
553
554void
559
560void
565
566void
571
572void
577
578void
583
584void
589
590void
595
596void
601
602void
607
608void
613
614void
619
620void
625
626void
628{
629 m_arqBlockSize = size;
630}
631
632void
637
638void
643
644void
649
650void
655
656void
661
662void
667
668void
703
704void
706{
707 m_serviceClassName = sf.GetServiceClassName();
708 m_qosParamSetType = sf.GetQosParamSetType();
709 m_trafficPriority = sf.GetTrafficPriority();
710 m_maxSustainedTrafficRate = sf.GetMaxSustainedTrafficRate();
711 m_maxTrafficBurst = sf.GetMaxTrafficBurst();
712 m_minReservedTrafficRate = sf.GetMinReservedTrafficRate();
713 m_minTolerableTrafficRate = sf.GetMinTolerableTrafficRate();
714 m_schedulingType = sf.GetServiceSchedulingType();
715 m_requestTransmissionPolicy = sf.GetRequestTransmissionPolicy();
716 m_toleratedJitter = sf.GetToleratedJitter();
717 m_maximumLatency = sf.GetMaximumLatency();
718 m_fixedversusVariableSduIndicator = sf.GetFixedversusVariableSduIndicator();
719 m_sduSize = sf.GetSduSize();
720 m_targetSAID = sf.GetTargetSAID();
721 m_arqEnable = sf.GetArqEnable();
722 m_arqWindowSize = sf.GetArqWindowSize();
723 m_arqRetryTimeoutTx = sf.GetArqRetryTimeoutTx();
724 m_arqRetryTimeoutRx = sf.GetArqRetryTimeoutRx();
725 m_csSpecification = sf.GetCsSpecification();
726 m_convergenceSublayerParam = sf.GetConvergenceSublayerParam();
727 m_unsolicitedGrantInterval = sf.GetUnsolicitedGrantInterval();
728 m_unsolicitedPollingInterval = sf.GetUnsolicitedPollingInterval();
729 m_direction = sf.GetDirection();
730 m_isMulticast = sf.GetIsMulticast();
731 m_modulationType = sf.GetModulation();
732}
733
735{
736 m_sfid = sf.GetSfid();
737 m_serviceClassName = sf.GetServiceClassName();
738 m_qosParamSetType = sf.GetQosParamSetType();
739 m_trafficPriority = sf.GetTrafficPriority();
740 m_maxSustainedTrafficRate = sf.GetMaxSustainedTrafficRate();
741 m_maxTrafficBurst = sf.GetMaxTrafficBurst();
742 m_minReservedTrafficRate = sf.GetMinReservedTrafficRate();
743 m_minTolerableTrafficRate = sf.GetMinTolerableTrafficRate();
744 m_schedulingType = sf.GetServiceSchedulingType();
745 m_requestTransmissionPolicy = sf.GetRequestTransmissionPolicy();
746 m_toleratedJitter = sf.GetToleratedJitter();
747 m_maximumLatency = sf.GetMaximumLatency();
748 m_fixedversusVariableSduIndicator = sf.GetFixedversusVariableSduIndicator();
749 m_sduSize = sf.GetSduSize();
750 m_targetSAID = sf.GetTargetSAID();
751 m_arqEnable = sf.GetArqEnable();
752 m_arqWindowSize = sf.GetArqWindowSize();
753 m_arqRetryTimeoutTx = sf.GetArqRetryTimeoutTx();
754 m_arqRetryTimeoutRx = sf.GetArqRetryTimeoutRx();
755 m_csSpecification = sf.GetCsSpecification();
756 m_convergenceSublayerParam = sf.GetConvergenceSublayerParam();
757 m_unsolicitedGrantInterval = sf.GetUnsolicitedGrantInterval();
758 m_unsolicitedPollingInterval = sf.GetUnsolicitedPollingInterval();
759 m_direction = sf.GetDirection();
760 m_type = sf.GetType();
761 m_connection = sf.GetConnection();
762 m_isEnabled = sf.GetIsEnabled();
764 (*m_record) = (*sf.GetRecord());
765 m_isMulticast = sf.GetIsMulticast();
766 m_modulationType = sf.GetModulation();
767}
768
771{
772 m_sfid = o.GetSfid();
773 m_serviceClassName = o.GetServiceClassName();
774 m_qosParamSetType = o.GetQosParamSetType();
775 m_trafficPriority = o.GetTrafficPriority();
776 m_maxSustainedTrafficRate = o.GetMaxSustainedTrafficRate();
777 m_maxTrafficBurst = o.GetMaxTrafficBurst();
778 m_minReservedTrafficRate = o.GetMinReservedTrafficRate();
779 m_minTolerableTrafficRate = o.GetMinTolerableTrafficRate();
780 m_schedulingType = o.GetServiceSchedulingType();
781 m_requestTransmissionPolicy = o.GetRequestTransmissionPolicy();
782 m_toleratedJitter = o.GetToleratedJitter();
783 m_maximumLatency = o.GetMaximumLatency();
784 m_fixedversusVariableSduIndicator = o.GetFixedversusVariableSduIndicator();
785 m_sduSize = o.GetSduSize();
786 m_targetSAID = o.GetTargetSAID();
787 m_arqEnable = o.GetArqEnable();
788 m_arqWindowSize = o.GetArqWindowSize();
789 m_arqRetryTimeoutTx = o.GetArqRetryTimeoutTx();
790 m_arqRetryTimeoutRx = o.GetArqRetryTimeoutRx();
791 m_csSpecification = o.GetCsSpecification();
792 m_convergenceSublayerParam = o.GetConvergenceSublayerParam();
793 m_unsolicitedGrantInterval = o.GetUnsolicitedGrantInterval();
794 m_unsolicitedPollingInterval = o.GetUnsolicitedPollingInterval();
795 m_direction = o.GetDirection();
796 m_type = o.GetType();
797 m_connection = o.GetConnection();
798 m_isEnabled = o.GetIsEnabled();
799 m_isMulticast = o.GetIsMulticast();
800 m_modulationType = o.GetModulation();
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{
837 tmpSfVector.Add(
841 4,
843 tmpSfVector.Add(
846 4,
849 4,
851 tmpSfVector.Add(
854 4,
859 1,
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
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.
Definition ptr.h:66
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 "IEEE Standard f...
Definition wimax-tlv.h:76
@ 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
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 > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
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