169 simtime_t firstPlayoutTime = firstPacket.arrivalTime +
playoutDelay;
170 simtime_t mouthToEarDelay = firstPlayoutTime - firstPacket.creationTime;
171 unsigned int firstPacketId = firstPacket.packetID;
173 unsigned int playoutLoss = 0;
174 unsigned int tailDropLoss = 0;
175 unsigned int channelLoss;
178 unsigned int maxId = 0;
180 maxId =
std::max(maxId, (elem).packetID);
189 double packetLossRate = ((double)channelLoss / (
double)talkspurtNumPackets);
193 bool *isArrived =
new bool[talkspurtNumPackets];
194 for (
unsigned int y = 0; y < talkspurtNumPackets; y++)
195 isArrived[y] =
false;
205 lastLateness = elem.arrivalTime - elem.playoutTime;
206 if (maxLateness < lastLateness)
207 maxLateness = lastLateness;
209 EV_DEBUG <<
"MEASURED PACKET LATENESS: " << lastLateness <<
" TALK " <<
currentTalkspurt.
talkspurtID <<
" PACKET " << elem.packetID <<
"\n\n";
212 if (isArrived[elem.packetID]) {
216 else if (lastLateness > 0.0) {
218 EV_DEBUG <<
"REMOVED LATE PACKET: TALK " <<
currentTalkspurt.
talkspurtID <<
" PACKET " << elem.packetID <<
", LATENESS " << lastLateness * 1000.0 <<
"ms\n\n";
224 auto qi = playoutQueue.begin();
225 while (qi != playoutQueue.end()) {
226 if ((*qi)->playoutTime < elem.arrivalTime) {
228 qi = playoutQueue.erase(qi);
235 EV_DEBUG <<
"PACKET INSERTED INTO PLAYOUT BUFFER: TALK " 237 <<
"ARRIVAL TIME " << elem.arrivalTime <<
"s, " 238 <<
"PLAYOUT TIME " << elem.playoutTime <<
"s\n\n";
240 isArrived[elem.packetID] =
true;
242 playoutQueue.push_back(&(elem));
248 << elem.packetID <<
" ARRIVAL TIME " << elem.arrivalTime <<
"s\n\n";
253 double proportionalLossRate = (double)(tailDropLoss + playoutLoss + channelLoss) / (double)talkspurtNumPackets;
254 EV_DEBUG <<
"proportionalLossRate " << proportionalLossRate <<
"(tailDropLoss=" << tailDropLoss
255 <<
" - playoutLoss=" << playoutLoss <<
" - channelLoss=" << channelLoss <<
")\n\n";
257 double mos =
eModel(SIMTIME_DBL(mouthToEarDelay), proportionalLossRate);
260 double lossRate = ((double)playoutLoss / (
double)talkspurtNumPackets);
267 double tailDropRate = ((double)tailDropLoss / (
double)talkspurtNumPackets);
270 EV_DEBUG <<
"CALCULATED MOS: eModel( " <<
playoutDelay <<
" , " << tailDropLoss <<
"+" << playoutLoss <<
"+" << channelLoss <<
" ) = " << mos <<
"\n\n";
272 EV_DEBUG <<
"PLAYOUT DELAY ADAPTATION \n" <<
"OLD PLAYOUT DELAY: " <<
playoutDelay <<
"\nMAX LATENESS MEASURED: " << maxLateness <<
"\n\n";
274 if (par(
"adaptivePlayoutDelay").boolValue()) {
278 EV_DEBUG <<
"NEW PLAYOUT DELAY: " <<
playoutDelay <<
"\n\n";
std::list< VoIPPacketInfo * > PacketsList
Definition: SimpleVoIPReceiver.h:52
static simsignal_t taildropLossRateSignal
Definition: SimpleVoIPReceiver.h:97
simtime_t voiceDuration
Definition: SimpleVoIPReceiver.h:66
double max(double a, double b)
Returns the greater of the given parameters.
Definition: INETMath.h:161
bool isActive()
Definition: SimpleVoIPReceiver.h:75
unsigned int talkspurtNumPackets
Definition: SimpleVoIPReceiver.h:65
simtime_t playoutDelay
Definition: SimpleVoIPReceiver.h:84
void finishTalkspurt()
Definition: SimpleVoIPReceiver.h:72
static simsignal_t playoutDelaySignal
Definition: SimpleVoIPReceiver.h:94
static simsignal_t playoutLossRateSignal
Definition: SimpleVoIPReceiver.h:95
TalkspurtInfo currentTalkspurt
Definition: SimpleVoIPReceiver.h:90
unsigned int bufferSpace
Definition: SimpleVoIPReceiver.h:80
PacketsVector packets
Definition: SimpleVoIPReceiver.h:67
double eModel(double delay, double loss)
Definition: SimpleVoIPReceiver.cc:289
static simsignal_t mosSignal
Definition: SimpleVoIPReceiver.h:96
virtual void finish() override
Definition: SimpleVoIPReceiver.cc:324
static simsignal_t packetLossRateSignal
Definition: SimpleVoIPReceiver.h:92
#define FINGERPRINT_ADD_EXTRA_DATA(x)
Definition: INETDefs.h:87
unsigned int talkspurtID
Definition: SimpleVoIPReceiver.h:64