EthernetSessionMux.h Source File

Simu5G: EthernetSessionMux.h Source File
Simu5G
EthernetSessionMux.h
1//
2// Simu5G
3//
4// Copyright (C) 2026 Andras Varga (OpenSim Ltd)
5//
6// This file is part of a software released under the license included in file
7// "license.pdf". Please read LICENSE and README files before using it.
8// The above files and the present reference are part of the software itself,
9// and cannot be removed from it.
10//
11
12#ifndef _ETHERNETSESSIONMUX_H_
13#define _ETHERNETSESSIONMUX_H_
14
15#include <map>
16
17#include <inet/common/ModuleRefByPar.h>
18#include <inet/common/packet/Packet.h>
19#include <inet/linklayer/ethernet/contract/IMacForwardingTable.h>
20#include <inet/networklayer/common/NetworkInterface.h>
21#include <inet/networklayer/contract/IInterfaceTable.h>
22#include <inet/queueing/contract/IPassivePacketSink.h>
23
24#include "simu5g/corenetwork/gtp/GtpTunnel.h"
25
26namespace simu5g {
27
33class EthernetSessionPortal : public omnetpp::cSimpleModule, public virtual inet::queueing::IPassivePacketSink
34{
35 protected:
36 inet::NetworkInterface *networkInterface_ = nullptr;
37
38 protected:
39 int numInitStages() const override { return inet::NUM_INIT_STAGES; }
40 void initialize(int stage) override;
41 void handleMessage(omnetpp::cMessage *msg) override;
42
43 public:
44 bool canPushSomePacket(const omnetpp::cGate *gate) const override { return true; }
45 bool canPushPacket(inet::Packet *packet, const omnetpp::cGate *gate) const override { return true; }
46 void pushPacket(inet::Packet *packet, const omnetpp::cGate *gate) override;
47 void pushPacketStart(inet::Packet *packet, const omnetpp::cGate *gate, inet::bps datarate) override { throw omnetpp::cRuntimeError("EthernetSessionPortal: packet streaming is not supported"); }
48 void pushPacketEnd(inet::Packet *packet, const omnetpp::cGate *gate) override { throw omnetpp::cRuntimeError("EthernetSessionPortal: packet streaming is not supported"); }
49 void pushPacketProgress(inet::Packet *packet, const omnetpp::cGate *gate, inet::bps datarate, inet::b position, inet::b extraProcessableLength = inet::b(0)) override { throw omnetpp::cRuntimeError("EthernetSessionPortal: packet streaming is not supported"); }
50};
51
56class EthernetSessionMux : public omnetpp::cSimpleModule
57{
58 protected:
59 inet::ModuleRefByPar<inet::IInterfaceTable> interfaceTable_;
60 inet::ModuleRefByPar<inet::IMacForwardingTable> macTable_;
61
62 // A session's port, and the index of the mux gates its lower side is connected to
63 struct Port {
64 TunnelSession session;
65 inet::NetworkInterface *networkInterface = nullptr;
66 int gateIndex = -1;
67 };
68 std::map<MacNodeId, Port> ports_; // by the UE's LTE node id
69 std::map<int, MacNodeId> portOfGate_; // portIn gate index -> the UE's LTE node id
70 int portCounter_ = 0; // for the ports' module names
71
72 protected:
73 int numInitStages() const override { return inet::NUM_INIT_STAGES; }
74 void initialize(int stage) override;
75 void handleMessage(omnetpp::cMessage *msg) override;
76
77 public:
78 // The Ethernet PDU session is established at this UPF: its port is created
79 virtual void addSessionPort(const SessionRef& session);
80
81 // The session is released: its port's MAC table entries are flushed and the port is
82 // deleted; nothing happens if the session has no port here
83 virtual void removeSessionPort(const SessionRef& session);
84};
85
86} //namespace
87
88#endif
Definition EthernetSessionMux.h:57
Definition EthernetSessionMux.h:34
Definition AlertReceiver.h:24
Definition GtpTunnel.h:51
Definition GtpTunnel.h:100