12#ifndef STACK_SDAP_COMMON_REFLECTIVEQOSTABLE_H_
13#define STACK_SDAP_COMMON_REFLECTIVEQOSTABLE_H_
19#include <inet/common/packet/Packet.h>
20#include "simu5g/common/LteTypes.h"
22using namespace omnetpp;
36 FlowKey(
const std::string& src,
const std::string& dst, uint16_t sp, uint16_t dp, uint8_t prot)
37 : srcAddr(src), dstAddr(dst), srcPort(sp), dstPort(dp), protocol(prot) {}
40 std::string toString()
const {
41 return srcAddr +
":" + std::to_string(srcPort) +
"->" +
42 dstAddr +
":" + std::to_string(dstPort) +
"/" + std::to_string(protocol);
46 FlowKey reverse()
const {
47 return FlowKey(dstAddr, srcAddr, dstPort, srcPort, protocol);
51 bool operator<(
const FlowKey& other)
const {
52 if (srcAddr != other.srcAddr)
return srcAddr < other.srcAddr;
53 if (dstAddr != other.dstAddr)
return dstAddr < other.dstAddr;
54 if (srcPort != other.srcPort)
return srcPort < other.srcPort;
55 if (dstPort != other.dstPort)
return dstPort < other.dstPort;
56 return protocol < other.protocol;
59 bool operator==(
const FlowKey& other)
const {
60 return srcAddr == other.srcAddr && dstAddr == other.dstAddr &&
61 srcPort == other.srcPort && dstPort == other.dstPort &&
62 protocol == other.protocol;
66inline std::ostream& operator<<(std::ostream& os,
const FlowKey& k)
68 os << k.srcAddr <<
":" << k.srcPort <<
"->" << k.dstAddr <<
":" << k.dstPort
69 <<
"/" << (
unsigned int)k.protocol;
74struct ReflectiveQosFlow {
81 ReflectiveQosFlow() =
default;
82 ReflectiveQosFlow(Qfi q,
const FlowKey& key)
83 : qfi(q), flowKey(key), lastSeen(simTime()), isActive(true) {}
86inline std::ostream& operator<<(std::ostream& os,
const ReflectiveQosFlow& f)
88 os <<
"qfi=" << f.qfi <<
" flow=" << f.flowKey <<
" lastSeen=" << f.lastSeen
89 << (f.isActive ?
" active" :
" inactive");
106class ReflectiveQosTable :
public cSimpleModule
110 simtime_t timeout_ = 30;
112 std::map<FlowKey, ReflectiveQosFlow> reflectiveFlows_;
113 cMessage *cleanupTimer_ =
nullptr;
116 virtual void initialize()
override;
117 virtual void handleMessage(cMessage *msg)
override;
118 virtual void finish()
override;
122 ReflectiveQosTable();
123 virtual ~ReflectiveQosTable();
126 virtual void handleDownlinkFlow(inet::Packet *pkt, Qfi qfi);
127 virtual Qfi lookupUplinkQfi(inet::Packet *pkt);
130 virtual void cleanupExpiredFlows();
131 size_t getActiveFlowCount()
const {
return reflectiveFlows_.size(); }
132 virtual void clearAllFlows();
135 virtual void printFlows()
const;
139 virtual FlowKey extractFlowKey(inet::Packet *pkt)
const;
142 virtual void scheduleCleanupTimer();
143 virtual void cancelCleanupTimer();
Definition AlertReceiver.h:24
constexpr Qfi QFI_NONE
Logical Connection Identifier (used in MAC layer)
Definition LteTypes.h:82