|
INET Framework for OMNeT++/OMNEST
|
Implements a simple VoIP source.
More...
#include <SimpleVoipReceiver.h>
Implements a simple VoIP source.
See the NED file for more information.
◆ PacketsList
◆ PacketsVector
◆ SimpleVoipReceiver()
| inet::SimpleVoipReceiver::SimpleVoipReceiver |
( |
| ) |
|
◆ ~SimpleVoipReceiver()
| inet::SimpleVoipReceiver::~SimpleVoipReceiver |
( |
| ) |
|
◆ eModel()
| double inet::SimpleVoipReceiver::eModel |
( |
double |
delay, |
|
|
double |
loss |
|
) |
| |
|
private |
290 static const double alpha3 = 177.3;
291 double delayms = 1000.0 * delay;
294 int u = (delayms - alpha3) > 0 ? 1 : 0;
295 double id = 0.024 * delayms + 0.11 * (delayms - alpha3) * u;
298 double p = lossRate * 100;
311 else if (Rfactor > 100.0) {
315 mos = 1.0 + 0.035 * Rfactor + 7.0 * 1E-6 * Rfactor * (Rfactor - 60.0) * (100.0 - Rfactor);
318 mos = (mos < 1.0) ? 1.0 : mos;
Referenced by evaluateTalkspurt().
◆ evaluateTalkspurt()
| void inet::SimpleVoipReceiver::evaluateTalkspurt |
( |
bool |
finish | ) |
|
|
private |
168 simtime_t firstPlayoutTime = firstPacket.arrivalTime +
playoutDelay;
169 simtime_t mouthToEarDelay = firstPlayoutTime - firstPacket.creationTime;
170 unsigned int firstPacketId = firstPacket.packetID;
172 unsigned int playoutLoss = 0;
173 unsigned int tailDropLoss = 0;
174 unsigned int channelLoss;
177 unsigned int maxId = 0;
179 maxId =
std::max(maxId, (elem).packetID);
188 double packetLossRate = ((double)channelLoss / (
double)talkspurtNumPackets);
192 bool *isArrived =
new bool[talkspurtNumPackets];
193 for (
unsigned int y = 0; y < talkspurtNumPackets; y++)
194 isArrived[y] =
false;
204 lastLateness = elem.arrivalTime - elem.playoutTime;
205 if (maxLateness < lastLateness)
206 maxLateness = lastLateness;
208 EV_DEBUG <<
"MEASURED PACKET LATENESS: " << lastLateness <<
" TALK " <<
currentTalkspurt.
talkspurtID <<
" PACKET " << elem.packetID <<
"\n\n";
211 if (isArrived[elem.packetID]) {
215 else if (lastLateness > 0.0) {
217 EV_DEBUG <<
"REMOVED LATE PACKET: TALK " <<
currentTalkspurt.
talkspurtID <<
" PACKET " << elem.packetID <<
", LATENESS " << lastLateness * 1000.0 <<
"ms\n\n";
223 auto qi = playoutQueue.begin();
224 while (qi != playoutQueue.end()) {
225 if ((*qi)->playoutTime < elem.arrivalTime) {
227 qi = playoutQueue.erase(qi);
234 EV_DEBUG <<
"PACKET INSERTED INTO PLAYOUT BUFFER: TALK "
236 <<
"ARRIVAL TIME " << elem.arrivalTime <<
"s, "
237 <<
"PLAYOUT TIME " << elem.playoutTime <<
"s\n\n";
239 isArrived[elem.packetID] =
true;
241 playoutQueue.push_back(&(elem));
247 << elem.packetID <<
" ARRIVAL TIME " << elem.arrivalTime <<
"s\n\n";
252 double proportionalLossRate = (double)(tailDropLoss + playoutLoss + channelLoss) / (double)talkspurtNumPackets;
253 EV_DEBUG <<
"proportionalLossRate " << proportionalLossRate <<
"(tailDropLoss=" << tailDropLoss
254 <<
" - playoutLoss=" << playoutLoss <<
" - channelLoss=" << channelLoss <<
")\n\n";
256 double mos =
eModel(SIMTIME_DBL(mouthToEarDelay), proportionalLossRate);
259 double lossRate = ((double)playoutLoss / (
double)talkspurtNumPackets);
266 double tailDropRate = ((double)tailDropLoss / (
double)talkspurtNumPackets);
269 EV_DEBUG <<
"CALCULATED MOS: eModel( " <<
playoutDelay <<
" , " << tailDropLoss <<
"+" << playoutLoss <<
"+" << channelLoss <<
" ) = " << mos <<
"\n\n";
271 EV_DEBUG <<
"PLAYOUT DELAY ADAPTATION \n" <<
"OLD PLAYOUT DELAY: " <<
playoutDelay <<
"\nMAX LATENESS MEASURED: " << maxLateness <<
"\n\n";
273 if (par(
"adaptivePlayoutDelay")) {
277 EV_DEBUG <<
"NEW PLAYOUT DELAY: " <<
playoutDelay <<
"\n\n";
Referenced by finish(), handleMessage(), and socketDataArrived().
◆ finish()
| void inet::SimpleVoipReceiver::finish |
( |
| ) |
|
|
overrideprotectedvirtual |
◆ handleMessage()
| void inet::SimpleVoipReceiver::handleMessage |
( |
cMessage * |
msg | ) |
|
|
overrideprotected |
106 if (msg->isSelfMessage()) {
110 else if (msg->arrivedOn(
"socketIn")) {
114 throw cRuntimeError(
"Unknown incoming gate: '%s'", msg->getArrivalGate()->getFullName());
◆ initialize()
| void inet::SimpleVoipReceiver::initialize |
( |
int |
stage | ) |
|
|
overrideprotected |
63 cSimpleModule::initialize(stage);
79 NodeStatus *nodeStatus = node ? check_and_cast_nullable<NodeStatus *>(node->getSubmodule(
"status")) : nullptr;
80 bool isOperational = (!nodeStatus) || nodeStatus->getState() ==
NodeStatus::UP;
82 throw cRuntimeError(
"This module doesn't support starting in node DOWN state");
84 int port = par(
"localPort");
85 EV_INFO <<
"VoIPReceiver::initialize - binding to port: local:" << port << endl;
◆ numInitStages()
| virtual int inet::SimpleVoipReceiver::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ socketClosed()
| virtual void inet::SimpleVoipReceiver::socketClosed |
( |
UdpSocket * |
socket | ) |
|
|
inlineoverrideprotectedvirtual |
◆ socketDataArrived()
| void inet::SimpleVoipReceiver::socketDataArrived |
( |
UdpSocket * |
socket, |
|
|
Packet * |
packet |
|
) |
| |
|
overrideprotectedvirtual |
Notifies about data arrival, packet ownership is transferred to the callee.
Implements inet::UdpSocket::ICallback.
120 const auto& voice = packet->peekAtFront<SimpleVoipPacket>();
137 throw cRuntimeError(
"Talkspurt parameters not equals");
142 EV_DEBUG <<
"PACKET ARRIVED TOO LATE: TALKSPURT " << voice->getTalkspurtID() <<
" PACKET " << voice->getPacketID() <<
", IGNORED\n\n";
147 EV_DEBUG <<
"PACKET ARRIVED: TALKSPURT " << voice->getTalkspurtID() <<
" PACKET " << voice->getPacketID() <<
"\n\n";
149 simtime_t delay = packet->getArrivalTime() - voice->getVoipTimestamp();
◆ socketErrorArrived()
| void inet::SimpleVoipReceiver::socketErrorArrived |
( |
UdpSocket * |
socket, |
|
|
Indication * |
indication |
|
) |
| |
|
overrideprotectedvirtual |
Notifies about error indication arrival, indication ownership is transferred to the callee.
Implements inet::UdpSocket::ICallback.
157 EV_WARN <<
"Unknown message '" << indication->getName() <<
"', kind = " << indication->getKind() <<
", discarding it." << endl;
◆ startTalkspurt()
| void inet::SimpleVoipReceiver::startTalkspurt |
( |
Packet * |
packet | ) |
|
|
private |
98 const auto& voice = packet->peekAtFront<SimpleVoipPacket>();
Referenced by socketDataArrived().
◆ bufferSpace
| unsigned int inet::SimpleVoipReceiver::bufferSpace = 0 |
|
private |
◆ currentTalkspurt
◆ emodelA
| int inet::SimpleVoipReceiver::emodelA = -1 |
|
private |
◆ emodelBpl
| int inet::SimpleVoipReceiver::emodelBpl = -1 |
|
private |
◆ emodelIe
| int inet::SimpleVoipReceiver::emodelIe = -1 |
|
private |
◆ emodelRo
| double inet::SimpleVoipReceiver::emodelRo = NaN |
|
private |
◆ mosSpareTime
| simtime_t inet::SimpleVoipReceiver::mosSpareTime |
|
private |
◆ playoutDelay
| simtime_t inet::SimpleVoipReceiver::playoutDelay |
|
private |
◆ selfTalkspurtFinished
| cMessage* inet::SimpleVoipReceiver::selfTalkspurtFinished = nullptr |
|
private |
◆ socket
◆ voipMosRateSignal
| simsignal_t inet::SimpleVoipReceiver::voipMosRateSignal = registerSignal("voipMosRate") |
|
staticprivate |
◆ voipPacketDelaySignal
| simsignal_t inet::SimpleVoipReceiver::voipPacketDelaySignal = registerSignal("voipPacketDelay") |
|
staticprivate |
◆ voipPacketLossRateSignal
| simsignal_t inet::SimpleVoipReceiver::voipPacketLossRateSignal = registerSignal("voipPacketLossRate") |
|
staticprivate |
◆ voipPlayoutDelaySignal
| simsignal_t inet::SimpleVoipReceiver::voipPlayoutDelaySignal = registerSignal("voipPlayoutDelay") |
|
staticprivate |
◆ voipPlayoutLossRateSignal
| simsignal_t inet::SimpleVoipReceiver::voipPlayoutLossRateSignal = registerSignal("voipPlayoutLossRate") |
|
staticprivate |
◆ voipTaildropLossRateSignal
| simsignal_t inet::SimpleVoipReceiver::voipTaildropLossRateSignal = registerSignal("voipTaildropLossRate") |
|
staticprivate |
The documentation for this class was generated from the following files:
Status status
Definition: SimpleVoipReceiver.h:48
void setOutputGate(cGate *toUdp)
Sets the gate on which to send to UDP.
Definition: UdpSocket.h:117
cModule * findContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:31
unsigned int bufferSpace
Definition: SimpleVoipReceiver.h:65
static simsignal_t voipMosRateSignal
Definition: SimpleVoipReceiver.h:81
void bind(int localPort)
Bind the socket to a local port number.
Definition: UdpSocket.cc:34
int emodelIe
Definition: SimpleVoipReceiver.h:66
static simsignal_t voipPacketDelaySignal
Definition: SimpleVoipReceiver.h:78
static simsignal_t voipTaildropLossRateSignal
Definition: SimpleVoipReceiver.h:82
simtime_t mosSpareTime
Definition: SimpleVoipReceiver.h:70
int emodelA
Definition: SimpleVoipReceiver.h:68
UdpSocket socket
Definition: SimpleVoipReceiver.h:73
int emodelBpl
Definition: SimpleVoipReceiver.h:67
void finishTalkspurt()
Definition: SimpleVoipReceiver.h:57
static simsignal_t voipPlayoutDelaySignal
Definition: SimpleVoipReceiver.h:79
bool checkPacket(const SimpleVoipPacket *pk)
Definition: SimpleVoipReceiver.cc:36
void evaluateTalkspurt(bool finish)
Definition: SimpleVoipReceiver.cc:161
@ ACTIVE
Definition: SimpleVoipReceiver.h:45
void setCallback(ICallback *cb)
Sets a callback object, to be used with processMessage().
Definition: UdpSocket.cc:338
void addPacket(const SimpleVoipPacket *pk)
Definition: SimpleVoipReceiver.cc:43
virtual void finish() override
Definition: SimpleVoipReceiver.cc:323
unsigned int talkspurtNumPackets
Definition: SimpleVoipReceiver.h:50
virtual void processMessage(cMessage *msg) override
Examines the message, takes ownership, and updates socket state.
Definition: UdpSocket.cc:343
PacketsVector packets
Definition: SimpleVoipReceiver.h:52
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
std::list< VoipPacketInfo * > PacketsList
Definition: SimpleVoipReceiver.h:38
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
@ EMPTY
Definition: SimpleVoipReceiver.h:44
simtime_t playoutDelay
Definition: SimpleVoipReceiver.h:69
unsigned int talkspurtID
Definition: SimpleVoipReceiver.h:49
double max(const double a, const double b)
Returns the maximum of a and b.
Definition: SctpAssociation.h:266
void startTalkspurt(const SimpleVoipPacket *pk)
Definition: SimpleVoipReceiver.cc:25
double eModel(double delay, double loss)
Definition: SimpleVoipReceiver.cc:288
TalkspurtInfo currentTalkspurt
Definition: SimpleVoipReceiver.h:75
bool isActive()
Definition: SimpleVoipReceiver.h:60
INET_API InitStage INITSTAGE_APPLICATION_LAYER
Initialization of applications.
@ UP
Definition: NodeStatus.h:28
#define FINGERPRINT_ADD_EXTRA_DATA(x)
Definition: INETDefs.h:84
cMessage * selfTalkspurtFinished
Definition: SimpleVoipReceiver.h:74
static simsignal_t voipPacketLossRateSignal
Definition: SimpleVoipReceiver.h:77
void startTalkspurt(Packet *packet)
Definition: SimpleVoipReceiver.cc:96
double emodelRo
Definition: SimpleVoipReceiver.h:64
static simsignal_t voipPlayoutLossRateSignal
Definition: SimpleVoipReceiver.h:80
simtime_t voiceDuration
Definition: SimpleVoipReceiver.h:51