Unipisa / Simu5G

Simu5G - 5G NR and LTE/LTE-A user-plane simulation model for OMNeT++ & INET
https://simu5g.org
Other
142 stars 81 forks source link

Evaluation of E2E delay #111

Closed saharhoteit closed 1 year ago

saharhoteit commented 1 year ago

Hello all, we have implemented a Vulnerable Road Users scenario that consists of users sending an alert message to nearby vehicles to inform them of their status. We aim in our simulation to study the effect of enabling mobile edge computing (MEC) on the average end to end latency. An example of the scenario with only two users and 7 vehicles is in attachement.

Picture 1

The simulation results gave us only the mac delay, rlc delay and rlc pdu delay, please find in attachement the results we have got. We would like to know if there is way to determine the E2E delay directly, or in other terms, how to enable to output the delay from the other layers? Thanks Best regards resultat.csv

giovanninardini commented 1 year ago

Hello,

the E2E delay needs to be computed by the applications running on the vehicles. So, in the code of the application you are using, you should implement a statistic that computes and emits the E2E delay. See the CBRSender/CBRReceiver apps as an example.

Best regards. Giovanni

helamarouane commented 1 year ago

Hello, In the paper "Exploiting Simu5G for generating datasets for training and testing AImodels for 5G/6G network applications ", there is the following formula: simtime_t delay_val= rxTime - txTime; (Listing 4). What is the meaning of rxTime and txTime

giovanninardini commented 1 year ago

Hello, In the paper "Exploiting Simu5G for generating datasets for training and testing AImodels for 5G/6G network applications ", there is the following formula: simtime_t delay_val= rxTime - txTime; (Listing 4). What is the meaning of rxTime and txTime

Hello, rxTime is the time a packet was received at the receiving module (e.g., receiver application), whereas txTime is the time the same packet was sent from the transmitting module (e.g., sender application). Their difference is the end-to-end delay.

helamarouane commented 1 year ago

Hello all, we have implemented a Vulnerable Road Users scenario that consists of users sending an alert message to nearby vehicles to inform them of their status. We aim in our simulation to study the effect of enabling mobile edge computing (MEC) on the average end to end latency. We have added the E2E delay statistics in the following files: AlertReceiver.ned, AlertReceiver.h, AlertReceiver.cc

But, the problem, in the result file (.vec), we don’t have the endToEnd delay. Can you help me please ?

---------------------------------------------AlertReceiver.ned---------------------------------------------------------------------------- // Simu5G // Authors: Giovanni Nardini, Giovanni Stea, Antonio Virdis (University of Pisa) // This file is part of a software released under the license included in file // "license.pdf". Please read LICENSE and README files before using it. // The above files and the present reference are part of the software itself, // and cannot be removed from it. package simu5g.apps.alert; import inet.applications.contract.IApp; simple AlertReceiver like IApp { parameters: int localPort = default(3000); string interfaceTableModule; string multicastInterface = default("wlan"); // if not empty, set the multicast output interface option on the socket (interface name expected) @signal[alertDelay]; @statistic[alertDelay](title="Alert Message Delay"; unit="s"; source="alertDelay"; record=mean, vector);
@signal[alertRcvdMsg]; @statistic[alertRcvdMsg](title="Alert Messages Received"; unit="s"; source="alertRcvdMsg"; record=sum, vector);
@display("i=block/source"); @signalalertEndToEndDelay; @statistic[alertEndToEndDelay](title="End-to-end delay"; source="alertEndToEndDelay"; record=mean,vector);

gates:
    output socketOut;
    input socketIn;**

-----------------------------------------------AlertReceiver.h-------------------------------------------------------------------------------- // Simu5G // Authors: Giovanni Nardini, Giovanni Stea, Antonio Virdis (University of Pisa) // // This file is part of a software released under the license included in file // "license.pdf". Please read LICENSE and README files before using it. // The above files and the present reference are part of the software itself, // and cannot be removed from it.

ifndef _LTE_AlertReceiverH

define _LTE_AlertReceiverH

include

include

include <inet/networklayer/common/L3AddressResolver.h>

include <inet/transportlayer/contract/udp/UdpSocket.h>

include "apps/alert/AlertPacket_m.h"

class AlertReceiver : public omnetpp::cSimpleModule { inet::UdpSocket socket;

omnetpp::simsignal_t alertDelay_;
omnetpp::simsignal_t alertRcvdMsg_;
omnetpp::simsignal_t alertEndToEndDelay_;

omnetpp::simtime_t delaySum;
long nrReceived;

protected:

virtual int numInitStages() const override { return inet::NUM_INIT_STAGES; }
void initialize(int stage) override;
void handleMessage(omnetpp::cMessage *msg) override;

// utility: show current statistics above the icon
virtual void refreshDisplay() const override;

};

endif

---------------------------------------------------AlertReceiver.cc ---------------------------------------------------------------------- // Simu5G // // Authors: Giovanni Nardini, Giovanni Stea, Antonio Virdis (University of Pisa) // // This file is part of a software released under the license included in file // "license.pdf". Please read LICENSE and README files before using it. // The above files and the present reference are part of the software itself, // and cannot be removed from it. //

include "apps/alert/AlertReceiver.h"

include <inet/common/ModuleAccess.h> // for multicast support

Define_Module(AlertReceiver); using namespace inet;

void AlertReceiver::initialize(int stage) { cSimpleModule::initialize(stage);

if (stage != inet::INITSTAGE_APPLICATION_LAYER)
    return;

int port = par("localPort");
EV << "AlertReceiver::initialize - binding to port: local:" << port << endl;
if (port != -1)
{
    socket.setOutputGate(gate("socketOut"));
    socket.bind(port);

    // for multicast support
    inet::IInterfaceTable *ift = inet::getModuleFromPar<inet::IInterfaceTable>(par("interfaceTableModule"), this);
    inet::MulticastGroupList mgl = ift->collectMulticastGroups();
    socket.joinLocalMulticastGroups(mgl);

    // if the multicastInterface parameter is not empty, set the interface explicitly
    const char *multicastInterface = par("multicastInterface");
    if (multicastInterface[0]) {
        NetworkInterface *ie = ift->findInterfaceByName(multicastInterface);
        if (!ie)
            throw cRuntimeError("Wrong multicastInterface setting: no interface named \"%s\"", multicastInterface);
        socket.setMulticastOutputInterface(ie->getInterfaceId());
    }

    // -------------------- //
}

alertDelay_ = registerSignal("alertDelay");
alertRcvdMsg_ = registerSignal("alertRcvdMsg");
alertEndToEndDelay_ = registerSignal("alertEndToEndDelay");
nrReceived = 0;
delaySum = 0;

}

void AlertReceiver::handleMessage(cMessage *msg) { if (msg->isSelfMessage()) return;

Packet* pPacket = check_and_cast<Packet*>(msg);

// read Alert header
auto alert = pPacket->popAtFront<AlertPacket>();

// emit statistics
simtime_t delay = simTime() - alert->getPayloadTimestamp();
emit(alertDelay_, delay);
emit(alertRcvdMsg_, (long)1);
nrReceived++;
delaySum+=delay;

simtime_t delayVal = simTime() - msg->getCreationTime();
emit(alertEndToEndDelay_, delayVal);
EV << "AlertReceiver::handleMessage - Packet received: SeqNo[" << alert->getSno() << "] Delay[" << delay << "]" << "] EndToEndDelay [" << delayVal  << endl;

delete msg;

}

void AlertReceiver::refreshDisplay() const { char buf[80]; if(nrReceived >0){ sprintf(buf, "received: %ld pks\nav. delay: %s s", nrReceived, (delaySum/nrReceived).format(-4).c_str()); } else { sprintf(buf, "received: 0 pks"); } getDisplayString().setTagArg("t", 0, buf); }

---------------------------------------------omnet.ini ---------------------------------------------------------------------------------- [General] cmdenv-express-mode = true cmdenv-autoflush = true image-path = ../../images network = simu5g.simulations.NR.VRUNR.Highway

##########################################################

Simulation parameters

########################################################## debug-on-errors = false print-undisposed = false

sim-time-limit = 20s

#########################################################

statistics

########################################################## *.alert.vector-recording = true .scalar-recording = false .vector-recording = false

.sctp..scalar-recording = false

.sctp..vector-recording = false

**.routingRecorder.enabled = false

output-scalar-file = ${resultdir}/${configname}/${iterationvars}-${repetition}.sca output-vector-file = ${resultdir}/${configname}/${iterationvars}-${repetition}.vec

.numUeCell = 0 .numUeD2D = 2

.playgroundSizeX = 20000m .playgroundSizeY = 20000m *.playgroundSizeZ = 50m

##########################################################

VeinsManager parameters

########################################################## .veinsManager.host = "localhost" # if traci-launchd runs on localhost .veinsManager.moduleType = "simu5g.nodes.cars.NRCar" .veinsManager.moduleName = "car" .veinsManager.launchConfig = xmldoc("heterogeneous.launchd.xml") *.veinsManager.updateInterval = 0.1s

##########################################################

Mobility

########################################################## .car[].mobilityType = "VeinsInetMobility"

##########################################################

LTE specific parameters

##########################################################

Number of Resource Blocks

**.numBands = 25

Transmission Power

.ueTxPower = 26 .eNodeBTxPower = 46

Enable dynamic association of UEs (based on best SINR)

.car[].cellularNic.nrPhy.dynamicCellAssociation = true .car[].masterId = 0 # ignored if dynamic association is disabled .car[].macCellId = 0 # ignored if dynamic association is disabled .car[].nrMasterId = 1 # ignored if dynamic association is disabled .car[].nrMacCellId = 1 # ignored if dynamic association is disabled

eNodeB configuration

.gNodeB1.macCellId = 1 .gNodeB1.macNodeId = 1 .gNodeB2.macCellId = 2 .gNodeB2.macNodeId = 2

Enable handover

.car[].cellularNic.nrPhy.enableHandover = true .gNodeB.cellularNic.phy.enableHandover = true .gNodeB.cellularNic.phy.handoverLatency = 50ms .gNodeB.cellInfo.broadcastMessageInterval = 1s # eNB will sends broadcast triggers every second

X2 and SCTP configuration

.gNodeB.numX2Apps = 1 # one x2App per peering eNodeB .gNodeB.x2App[].server.localPort = 5000 + ancestorIndex(1) # Server ports (x2App[0]=5000, x2App[1]=5001, ...) .gNodeB1.x2App[0].client.connectAddress = "gNodeB2%x2ppp0" *.gNodeB2.x2App[0].client.connectAddress = "gNodeB1%x2ppp0" .sctp.nagleEnabled = false # if true, transmission of small packets will be delayed on the X2 .sctp.enableHeartbeats = false

-----------------------------------------------------------------------------

Config "D2DMulticast"

#

In this configuration, a transmitting car sends periodic alert messages to neighboring vehicles

# [Config D2DMulticast]

.ue[].macCellId = 1 .ue[].masterId = 1 .ue[*].mobility.initFromDisplayString = false

Transmitter

.ueD2D[0].mobility.initialX = 250m .ueD2D[0].mobility.initialY = 250m

.ueD2D[1].mobility.initialX = 251m .ueD2D[1].mobility.initialY = 250m

Traffic configuration

.ueD2D[].numApps = 1 **.ueTxPower = 23

One-to-Many traffic between UEs (ueD2D[0] --> ueD2DRx[1..2])

Transmitter

.ueD2D[].app[].typename = "AlertSender" .ueD2D[].app[].localPort = 3088+ancestorIndex(0) .ueD2D[].app[].startTime = uniform(0s,0.02s) .ueD2D[].app[].stopTime = 4.9s .ueD2D[].app[].destAddress = "224.0.0.10" # IP address of the multicast group .ueD2D[].app[].destPort = 1000

Enable D2D for the eNodeB and the UEs involved in direct communications

**.amcMode = "D2D"

Select CQI for D2D transmissions

One-to-Many communications work with fixed CQI values only.

Set the parameter .usePreconfiguredTxParams and select the desired CQI using the parameter .d2dCqi

.enableD2DCqiReporting = false .usePreconfiguredTxParams = true **.d2dCqi = ${cqi=7}

Traffic configuration: one-to-many traffic between UEs (car[0] --> car[1..9])

.car[].numApps = 1

Receivers (they must belong to the above multicast group)

.car[0..7].app[].typename = "AlertReceiver" .car[0..7].app[].localPort = 1000

enrolled multicast groups must be set in the HostAutoConfigurator (instead of demo.xml), seperated by a single space character

.car[].configurator.mcastGroups = "224.0.0.10"

giovanninardini commented 1 year ago

Hello,

I think that you might have mistakenly disabled the metrics using this line in the omnetpp.ini file:

*.alert.vector-recording = true

Try to change it to something like:

**.alert**.vector-recording=true

Best regards. Giovanni

helamarouane commented 1 year ago

Hello,

Thank you for response. To calculate the delay of an alert message this code it's right simtime_t delayVal = simTime() - msg->getCreationTime();

void AlertReceiver::handleMessage(cMessage *msg) { if (msg->isSelfMessage()) return;

Packet pPacket = check_and_cast<Packet>(msg);

// read Alert header auto alert = pPacket->popAtFront();

// emit statistics simtimet delay = simTime() - alert->getPayloadTimestamp(); emit(alertDelay, delay); emit(alertRcvdMsg_, (long)1); nrReceived++; delaySum+=delay;

simtimet delayVal = simTime() - msg->getCreationTime(); emit(alertEndToEndDelay, delayVal); EV << "AlertReceiver::handleMessage - Packet received: SeqNo[" << alert->getSno() << "] Delay[" << delay << "]" << "] EndToEndDelay [" << delayVal << endl;

delete msg;

helamarouane commented 1 year ago

ello all, we have implemented a Vulnerable Road Users scenario that consists of users sending an alert message to nearby vehicles to inform them of their status. We aim in our simulation to study the effect of enabling mobile edge computing (MEC) on the average end to end latency. We have added the E2E delay statistics in the following files: AlertReceiver.ned, AlertReceiver.h, AlertReceiver.cc

I have changed *.alert.vector-recording = true to .alert.vector-recording=true But, the problem, in the result file (.vec), we don’t have the endToEnd delay. Can you help me please ?

In the vector file I have only two vectors Screenshot from 2023-03-22 10-14-20

In the attachements the different files Screenshot from 2023-03-22 10-20-14 Screenshot from 2023-03-22 10-19-56 Screenshot from 2023-03-22 10-19-44 Screenshot from 2023-03-22 10-18-27 Screenshot from 2023-03-22 10-18-01

giovanninardini commented 1 year ago

Hello,

looking at the result file, there is only the metrics related to the message transmission (alertSentMsg). Considering this, maybe the problem is not how you collect statistics, but it might be that the receivers do not receive the messages at all. Make sure, for example, that the receiving UEs are in the transmission range of the sender.

helamarouane commented 1 year ago

Hello, Thank you for the response. I Have a question : It is necessary to implement the statistics of the end to end delay in the sender.cc and the receiver

helamarouane commented 1 year ago

Hello,

I deleted the .alert.vector-recording = true and I changed **.vector-recording=true. So, I have the results but not the end to end delay. I don't know what is the problem I attached the following files : Screenshot from 2023-03-22 16-40-04 Screenshot from 2023-03-22 16-39-32

helamarouane commented 1 year ago

Hello, Thank you for the response. I Have two questions :

helamarouane commented 1 year ago

Hello,

How we know that the receiver has received the alert message ? And how we know that the receiving UEs are in the transmission range of the sender ?

Thanks for your help

helamarouane commented 1 year ago

Hello,

Please how we can calculate the creation time of an alert message (in AlertReceiver.cc)

giovanninardini commented 1 year ago

The creation time is not calculated. You can retrieve by adding the following line in the handleMessage() function: alert->getTag<CreationTimeTag>()->getCreationTime();

To do that you also need to include the required library: #include <inet/common/TimeTag_m.h>

helamarouane commented 1 year ago

Hello,

What is the condition for sending an alert message (the distance is less than a threshold ?). For example, if a car sends an alert message to another car to its inform that an ue is approaching, what is the condition ?

giovanninardini commented 1 year ago

I am not sure I get your question. If you refer to the AlertSender app in the apps folder, there are no conditions. The sender just sends one small packet periodically, possibly using a multicast IP address.

helamarouane commented 1 year ago

Hello,

iI it possible to implement a scenario where a vehicle sends an alert message to others when an UE approaches the vehicle?

giovanninardini commented 1 year ago

If you modify the application code to that effect.... yes

helamarouane commented 1 year ago

Hello, I have created a module obstacleDetector in order to a car[0] sends an alert to other vehicles when it detects an obstacle This the following file // obstacleDetector. ned package simu5g.apps.obstacle;

import inet.physicallayer.contract.packetlevel.IRadioMedium; import inet.physicallayer.contract.packetlevel.IRadioMediumControl; import inet.physicallayer.contract.packetlevel.IRadioMediumListener; import inet.physicallayer.contract.packetlevel.Packet; import inet.physicallayer.packetlevel.RadioMedium; import inet.applications.contract.IApp;

// Définition du module obstacleDetector module obstacleDetector like IApp { // Définir les ports d'entrée et de sortie input in; output out;

// Ajouter un attribut pour détecter les obstacles
bool obstacleDetected;

// Définir les paramètres de simulation
parameters:
    double detectionRange @unit(m); // Portée de détection de l'obstacle

submodules:
    // Ajouter un sous-module pour la voiture
    car0: car {
        @display("p=50,50");
        gates:
            inout radio;
    }

connections:
    // Connecter le sous-module car0 à la sortie "out" du module obstacleDetector
    out --> car0.in;

    // Connecter la voiture "car0" à tous les autres véhicules via un canal sans fil
    for i=1..7 {
        WirelessChannel.channel++ <--> car0.radio <--> WirelessChannel.channel++;
    }

    // Mettre à jour l'attribut obstacleDetected en fonction de l'entrée "in"
    car0.obstacleDetected <== (in.value() <= detectionRange);

}

In this file I have the error : unexpected INPUT_. I don't understand this error.

Thanks

helamarouane commented 1 year ago

Hello,

I have three questions :

Please help me ?

giovanninardini commented 1 year ago

1 - it means that the car sends the first message at a random time between 0 and 20 ms 2 - yes 3 - in the omnetpp.ini, you can set *.cars[0].app[*].period = exponential(1s) , assuming lambda = 1s