通过静脉发送消息和路边到路边(R2R)通信

时间:2019-03-15 17:49:10

标签: veins

我是Omnet Veins的新手。我尝试创建自己的应用程序。因此,首先,我在现有的TraciDemo11p文件中做到了这一点(我只是保留了文件名并修改了代码)。 第一步,我要使所有节点都发送一个HelloMsg(我创建了.msg .h和.cc的新数据包)。

为了很好地理解节点之间如何交换消息,我启动了模拟,一切都很好,但是我无法意识到消息是否被节点接收。

这是我所拥有的屏幕截图: enter image description here

我跟踪了应用程序,mac和phy层之间的消息传输。我可以看到例如该消息已通过节点1成功传输。但是节点[0]上的消息“卡未检测到数据包。电源低于敏感度阈值”是否意味着该数据包未由节点[0]接收?如果是这样,我该如何解决?另外,我找不到此消息的源文件(显然,在PhyLayer80211p.cc或BasehyLayer.cc中,但找不到)。

第二步,我要使用两个RSU。节点广播helloMessage,然后每个RSU将重复接收到的信号。为了澄清更多,这正是我所拥有的: 首先。我将另一个RSU添加到静脉示例中,如下所示:

##########################################################
#                       RSU SETTINGS                     #
#                                                        #
#                                                        #
##########################################################
*.rsu[0].mobility.x = 6490
*.rsu[0].mobility.y = 1000
*.rsu[0].mobility.z = 3

*.rsu[1].mobility.x = 7491
*.rsu[1].mobility.y = 1000
*.rsu[1].mobility.z = 3

*.rsu[*].applType = "TraCIDemoRSU11p"
*.rsu[*].appl.headerLength = 80 bit
*.rsu[*].appl.sendBeacons = false
*.rsu[*].appl.dataOnSch = false
*.rsu[*].appl.beaconInterval = 1s
*.rsu[*].appl.beaconUserPriority = 7
*.rsu[*].appl.dataUserPriority = 5

我还创建了两个maxInterferenceDistance,一个是节点,另一个是RSU:

##########################################################
#            11p specific parameters                     #
#                                                        #
#                    NIC-Settings                        #
##########################################################
*.connectionManager.sendDirect = true
*.connectionManager.maxInterfDist = 1000m  #2600m
*.connectionManager.drawMaxIntfDist = false #false
*.connectionManager.maxInterfDistNodes = 300m
*.connectionManager.drawMaxIntfDistNodes = false

*.**.nic.mac1609_4.useServiceChannel = false

*.**.nic.mac1609_4.txPower = 20mW
*.**.nic.mac1609_4.bitrate = 6Mbps
*.**.nic.phy80211p.sensitivity = -89dBm

*.**.nic.phy80211p.useThermalNoise = true
*.**.nic.phy80211p.thermalNoise = -110dBm

*.**.nic.phy80211p.decider = xmldoc("config.xml")
*.**.nic.phy80211p.analogueModels = xmldoc("config.xml")
*.**.nic.phy80211p.usePropagationDelay = true

*.**.nic.phy80211p.antenna = xmldoc("antenna.xml", "/root/Antenna[@id='monopole']")

为了使RSU的传输范围在节点上有所不同,我对baseConnectionMannager的isInRange函数进行了此更改:

bool BaseConnectionManager::isInRange(BaseConnectionManager::NicEntries::mapped_type pFromNic, BaseConnectionManager::NicEntries::mapped_type pToNic)
{
    double dDistance = 0.0;

    if ((pFromNic->hostId == 7) || (pFromNic->hostId == 8)) {
        EV<<"RSU In range from: "<<pFromNic->getName()<<" "<<pFromNic->hostId<<" to: "<<pToNic->getName()<<" "<<pToNic->hostId<<"\n";
    if(useTorus) {
        dDistance = sqrTorusDist(pFromNic->pos, pToNic->pos, *playgroundSize);
    } else {
        dDistance = pFromNic->pos.sqrdist(pToNic->pos);
    }
    return (dDistance <= maxDistSquared);
    } else {
        if(useTorus) {
                dDistance = sqrTorusDist(pFromNic->pos, pToNic->pos, *playgroundSize);
            } else {
                dDistance = pFromNic->pos.sqrdist(pToNic->pos);
            }
            return (dDistance <= maxDistSquaredNodes);
    }
}

在我运行的场景中,节点ID 7和8是RSU。

此外,我对TraciDemo11p(用于节点)和TraciDemoRSU11p(对于RSU)进行了如下修改: -在TraciDemo11p中,进入网络的节点向其所有邻居广播Hello消息。代码是:

void TraCIDemo11p::initialize(int stage) {

    BaseWaveApplLayer::initialize(stage);
    if (stage == 0) {
        HelloMsg *msg = createMsg();
        SendHello(msg);
    }
}

HelloMsg* TraCIDemo11p::createMsg() {
    int source_id = myId;
    double t0 = 0;
    int port = 0;

    char msgName[20];
    sprintf(msgName, "send Hello from %d at %f from gate %d",source_id, t0, port);

    HelloMsg* msg = new HelloMsg(msgName);
    populateWSM(msg);
    return msg;
}

void TraCIDemo11p::SendHello(HelloMsg* msg) {
    findHost()->getDisplayString().updateWith("r=16,green");
    msg->setSource_id(myId);
    cMessage* mm = dynamic_cast<cMessage*>(msg);
    scheduleAt(simTime() + 10 + uniform(0.01, 0.02), mm);
}

void TraCIDemo11p::handleSelfMsg(cMessage* msg) {

    if (dynamic_cast<HelloMsg*>(msg)) {
        HelloMsg* recv = dynamic_cast<HelloMsg*>(msg);
        ASSERT(recv);
        int sender = recv->getSource_id();
        if (sender == myId) {
            EV <<myId <<" broadcasting Hello Message \n";
            recv->setT0(SIMTIME_DBL(simTime()));
            sendDown(recv->dup());
        }
    }
    else {
        BaseWaveApplLayer::handleSelfMsg(msg);
    }
}

void TraCIDemo11p::onHelloMsg(HelloMsg* hmsg) {
    if ((hmsg->getSource_id() == 7) || (hmsg->getSource_id() == 8)) {
        EV <<"Node: "<<myId<<" receiving HelloMsg from rsu: "<<hmsg->getSource_id()<<"\n";
    } else {
    EV <<"Node: "<<myId<<" receiving HelloMsg "<<hmsg->getKind()<<" from node: "<<hmsg->getSource_id()<<"\n";
    NBneighbors++;
    neighbors.push_back(hmsg->getSource_id());
    EV <<"Node: "<<myId<<" neighbors list: ";
    list<int>::iterator it = neighbors.begin();
    while (it != neighbors.end()) {
        EV <<*it<<" ";
        it++;
    }
    }
}

void TraCIDemo11p::handlePositionUpdate(cObject* obj) {
    BaseWaveApplLayer::handlePositionUpdate(obj);
}

另一方面,RSU仅重复从节点接收到的消息。所以,我在TraciDemoRSU11p上:

void TraCIDemoRSU11p::onHelloMsg(HelloMsg* hmsg) {

    if ((hmsg->getSource_id() != 7) && (hmsg->getSource_id() != 8))
    {
        EV <<"RSU: "<<myId<<" receiving HelloMsg "<<hmsg->getKind()<<" from node: "<<hmsg->getSource_id()<<" at: "<<SIMTIME_DBL(simTime())<<" \n";
        //HelloMsg *msg = createMsg();
        //SendHello(msg);
        hmsg->setSenderAddress(myId);
        hmsg->setSource_id(myId);
        sendDelayedDown(hmsg->dup(), 2 + uniform(0.01,0.2));
    }
    else {
        EV<<"Successful connection between RSUs \n";
        EV <<"RSU: "<<myId<<" receiving HelloMsg "<<hmsg->getKind()<<" from node: "<<hmsg->getSource_id()<<"\n";
    }
}

执行此代码后,我可以看到:

  • 一些车辆从邻居那里收到问候消息。

  • 而且,两个RSU仅接收到一些消息。

  • 每个RSU都重复接收到的信号,但是两个RSU之间没有通信,这在彼此的传输中是应该假定的。

  • 我的屏幕上总是出现很多这样的消息:“卡未检测到数据包。电源低于灵敏度阈值”。

传输范围是否存在问题,或者是否存在干扰问题?另外,我想提一下,在分析中没有数据包丢失。 提前致谢。 请帮忙。

0 个答案:

没有答案
相关问题