Veins(车载通信仿真框架)入门教程

2023-05-16

Veins是一款用于车载移动环境下无线通信仿真的开源框架,其对于车载无线网的底层结构,如物理层、MAC层等基于802.11p协议已基本开发完善,因此在此基础上进行二次开发,如改进MAC层协议或者路由协议等研究都是非常便携的。甚至如果是进行应用层上的研究,如车联网环境下的车辆自动驾驶、编队行驶、路径规划、信号灯区域协调等则更加方便,因为底层的结构可以直接使用,不必再浪费时间精力在这些并不是需要主要研究但却又对仿真结果影响重大的部分。

 

首先在OMNeT++的IDE左侧有如下图所示的窗口,打开veins的项目,veins内置的示例就在文件夹examples内:

antenna.xml:对车辆天线做出配置,不用管;
config.xml:配置物理层无线电传播相关参数,如示例中将信号路径衰落的模型配置为“SmiplePathlossModel”,障碍物引起的信号衰落模型设置为“SimpleObstacleShadowing”,一般使用默认的即可;

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <AnalogueModels>
        <AnalogueModel type="SimplePathlossModel">
            <parameter name="alpha" type="double" value="2.0"/>
            <parameter name="carrierFrequency" type="double" value="5.890e+9"/>
        </AnalogueModel>
        <AnalogueModel type="SimpleObstacleShadowing">
            <parameter name="carrierFrequency" type="double" value="5.890e+9"/>
            <obstacles>
                <type id="building" db-per-cut="9" db-per-meter="0.4" />
            </obstacles>
        </AnalogueModel>
    </AnalogueModels>
    <Decider type="Decider80211p">
        <!-- The center frequency on which the phy listens-->
        <parameter name="centerFrequency" type="double" value="5.890e9"/>
    </Decider>
</root>


debug:调试信息,不用管;
erlangen.launchd.xml:建立与SUMO的通信,不能更改;
erlangen.net.xml: SUMO路网文件,跑自己的仿真时需要替换,至于如何生成请参考SUMO官网文档;
erlangen.poly.xml:如果SUMO路网文件是由地图转化而来的,如从OpenStreetMap导入的,则路网文件中还将包含所选地区的建筑物的信息,通过SUMO提供的OpenStreetMap Web接口便可生成记录这些建筑物形状、大小和位置信息的配置文件,作为config.xml内信号衰落模型的输入;如果不考虑建筑物对于信号传播的影响则无需此文件,当然config.xml内的信号衰落模型的配置也要删去;

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <AnalogueModels>
        <AnalogueModel type="SimplePathlossModel">
            <parameter name="alpha" type="double" value="2.0"/>
            <parameter name="carrierFrequency" type="double" value="5.890e+9"/>
        </AnalogueModel>
    </AnalogueModels>
    <Decider type="Decider80211p">
        <!-- The center frequency on which the phy listens-->
        <parameter name="centerFrequency" type="double" value="5.890e9"/>
    </Decider>
</root>


erlangen.rou.xml:交通流文件,如何生成也请查阅SUMO官网文档,不再赘述;
erlangen.sumo.cfg: SUMO运行文件,可对运行时长等运行参数进行配置;
omnetpp.ini: OMNeT++运行文件,后文重点讲解;
RSUExampleScnario.ned: OMNeT++类似于积木,一个工程项目是由多个ned文件互相嵌套组合而成的。veins作为一个基于OMNeT++的框架,其便是由层次分明的ned文件组合而成的,如果学过面向对象编程的话可能会容易理解一些,这些ned文件就类似一个个类。但是OMNeT++中更为特殊,因为ned文件只是定义了组件的结构,比如定义一辆车,ned只是描述了它包含几个对外通信的接口,这些接口的参数之类的,具体的功能还需要与ned文件同名的C++文件进行定义,比如用这些接口选择与谁进行通信,专业点就叫路由。对于OMNet++独特的ned网络语言大家还是踏踏实实看OMNeT++官方手册学习吧。一开始可能找不到头绪,所以建议大家去听听这个OMNeT++基础讲解的视频课程(要学的东西是不是很多?是不是很烦?)。这里的RSUExampleScnario.ned定义了OMNeT++中最大的结构——网络(network),可以看到在omnetpp.ini中的[General]部分对于本次仿真所运行的网络定义为RSUExampleScenario;

[General]
cmdenv-express-mode = true
cmdenv-autoflush = true
cmdenv-status-frequency = 1s
**.cmdenv-log-level = info

ned-path = .
image-path = ../../images

network = RSUExampleScenario


讲解omnetpp.ini!(挑关键的)
network:非常关键的参数,需要替换成自己的network级ned文件;
sim-time-limit: 网络仿真时间限制,注意与SUMO生成的交通流运行时长对应;
RSU SETTINGS:RSUExampleScnario.ned中的路侧单元ned中的参数做出设置。其中最重要的就是applType,它指定了RSU的应用层,也就是RSU会做什么。其实RSU也是一个ned文件,比network级低,它是由另外几个更低级的ned组成的,包括作为应用层的ned(appl),作为MAC层的ned(nic),作为移动驱动的ned(mobility)。applType指定的就是应用层的ned,而应用层ned的功能又由其同名且在同一个文件夹的C++文件定义,这样RSU的功能也就确定了,做应用层研究的要改变的就是这个应用层的ned与对应的C++文件。至于后面那些参数都是对于应用层ned中的一些参数做出设置,比如.rsu[*].appl.beaconUserPriority = 7就是令所有RSU应用层的信标优先级为7,这个就不要再问了,做车联网的这个还不懂就别玩了。

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

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



11p specific parameters NIC-Settings:对MAC层ned(nic)相关参数做出设置,nic包含两个子ned(mac1609_4和phy80211p)。至于connectionManager基本保持不变,如果要研究信号传播范围的影响的话,需要改变maxInterfDist

##########################################################
#            11p specific parameters                     #
#                                                        #
#                    NIC-Settings                        #
##########################################################
*.connectionManager.sendDirect = true
*.connectionManager.maxInterfDist = 2600m
*.connectionManager.drawMaxIntfDist = 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']")


WaveAppLayer: 对移动节点(车辆)的应用层做出设置,和RSU一个道理;

##########################################################
#                    WaveAppLayer                        #
##########################################################
*.node[*].applType = "TraCIDemo11p"
*.node[*].appl.headerLength = 80 bit
*.node[*].appl.sendBeacons = true
*.node[*].appl.dataOnSch = false
*.node[*].appl.beaconInterval = 1s


Mobility: 对移动节点的移动模块做出设置。其中accidentCount、accidentStart、accidentDuration这三个参数是对移动节点发生事故的事件做出设置,这是veins的examples演示的功能(事故预警消息的传播),我们用不到直接令accidentCount=0即可。

##########################################################
#                      Mobility                          #
##########################################################
*.node[*].veinsmobilityType.debug = true
*.node[*].veinsmobility.x = 0
*.node[*].veinsmobility.y = 0
*.node[*].veinsmobility.z = 1.895
*.node[*0].veinsmobility.accidentCount = 1
*.node[*0].veinsmobility.accidentStart = 75s
*.node[*0].veinsmobility.accidentDuration = 50s


讲解RSUExampleScnario.ned!
这里只挑最重要的讲,其余的自己看ned文件的import、extends往上慢慢捋就行。

看代码可以发现RSUExampleScnario内加入了一个RSU单元。

import org.car2x.veins.nodes.RSU;
import org.car2x.veins.nodes.Scenario;

network RSUExampleScenario extends Scenario
{
    submodules:
        rsu[1]: RSU {
            @display("p=150,140;i=veins/sign/yellowdiamond;is=vs");
        }
}


那么下面官网上的示例动图里的移动节点是怎么加入的呢?


其实是通过TraCIScenarioManagerLaunchd.ned这个模块加入的

package org.car2x.veins.modules.mobility.traci;

//
// Extends the TraCIScenarioManager for use with sumo-launchd.py and SUMO.
//
// Connects to a running instance of the sumo-launchd.py script
// to automatically launch/kill SUMO when the simulation starts/ends.
//
// All other functionality is provided by the TraCIScenarioManager.

simple TraCIScenarioManagerLaunchd
{
    parameters:
        @display("i=block/network2");
        @class(Veins::TraCIScenarioManagerLaunchd);
        bool debug = default(false);  // emit debug messages?
        double connectAt @unit("s") = default(0s);  // when to connect to TraCI server (must be the initial timestep of the server)
        double firstStepAt @unit("s") = default(-1s);  // when to start synchronizing with the TraCI server (-1: immediately after connecting)
        double updateInterval @unit("s") = default(1s);  // time interval of hosts' position updates
        string moduleType = default("org.car2x.veins.nodes.Car");  // module type to be used in the simulation for each managed vehicle
        string moduleName = default("node");  // module name to be used in the simulation for each managed vehicle
        // module displayString to be used in the simulation for each managed vehicle
        // display strings key-value pairs needs to be protected with single quotes, as they use an = sign as the type mappings. For example
        // <pre>
        // *.manager.moduleDisplayString = "'i=block/process'"
        // *.manager.moduleDisplayString = "a='i=block/process' b='i=misc/sun'"
        // </pre>
        //
        // moduleDisplayString can also be left empty:
        // <pre>
        // *.manager.moduleDisplayString = ""
        // </pre>
        string moduleDisplayString = default("*='i=veins/node/car;is=vs'");
        string host = default("localhost");  // sumo-launchd.py server hostname
        int port = default(9999);  // sumo-launchd.py server port
        xml launchConfig; // launch configuration to send to sumo-launchd.py
        int seed = default(-1); // seed value to set in launch configuration, if missing (-1: current run number)
        bool autoShutdown = default(true);  // Shutdown module as soon as no more vehicles are in the simulation
        int margin = default(25);  // margin to add to all received vehicle positions
        string roiRoads = default("");  // which roads (e.g. "hwy1 hwy2") are considered to consitute the region of interest, if not empty
        string roiRects = default("");  // which rectangles (e.g. "0,0-10,10 20,20-30,30) are considered to consitute the region of interest, if not empty. Note that these rectangles have to use TraCI (SUMO) coordinates and not OMNeT++. They can be easily read from sumo-gui.
        double penetrationRate = default(1); //the probability of a vehicle being equipped with Car2X technology
        int numVehicles = default(0);
        bool useRouteDistributions = default(false);
        int vehicleRngIndex = default(0); // index of the RNG stream to be used, all random numbers concerning the managed vehicles
}


其中下面一行代码定义了RSUExampleScnario.ned这个network中加入的移动节点。往上一层层捋就很容易发现,RSUExampleScnario继承自Scnario,Scnario又import了TraCIScenarioManagerLaunchd。

string moduleType = default("org.car2x.veins.nodes.Car");


到此为止,入门结束,剩下的具体功能实现请进入src/veins/nodes文件夹,仔细琢磨其中的ned文件并一层层往上捋即可。最后再啰嗦一句,ned定义结构,同名C++文件定义功能,明白这一点其实就没问题了。
 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Veins(车载通信仿真框架)入门教程 的相关文章

  • 计算机网络-拥塞控制/HTTP/URL

    滑动窗口和流量控制 TCP利用滑动窗口实现流量控制 xff0c 流量控制就是为了控制发送方发送速率 xff0c 保证接收方来得及接收 接收方发送的确认报文中的窗口字段可以来控制发送方窗口大小 xff0c 从而影响发送方的发送速率 xff0c
  • Integer和int进行==比较

    Integer amp int int是Java的基本数据类型 xff0c 而Integer是它的包装类 xff0c 61 61 在进行比较时 xff0c 如果是基本类型 xff0c 比较的是值 xff0c 如果是引用类型 xff0c 比较
  • deepin恢复出厂设置_如何恢复出厂设置

    deepin恢复出厂设置 There comes a time in every user s life when they have to reset something back to its factory default Perha
  • JUC-JMM/Volatile/单例模式

    JMM Java内存模型 xff0c 是一个概念 xff0c 不存在的东西 xff0c 概念 约定 关于JMM的一些同步约定 xff1a 线程解锁前 xff0c 必须把共享变量刷回主存线程加锁前 xff0c 必须读取主存中的最新值到工作内存
  • 设计模式-六大原则/单例模式

    设计模式 概念 xff1a 是一套被反复使用 多数人知晓的 经过分类编目的 代码设计经验的总结 作用 xff1a 为了可重用代码 让代码更容易被他人理解 保证代码可靠性 程序的重用性 JDK Spring等源码中许多地方用到了设计模式 设计
  • 设计模式-工厂模式/代理模式

    工厂模式 创建对象时不会对客户端暴露创建逻辑 xff0c 并且通过使用一个共同的接口来指向新创建的对象 xff0c 实现创建者和调用者分离 xff0c 工厂模式分为简单工厂 工厂方法 抽象工厂 xff0c Spring中的IOC容器创建be
  • WSL2+VcXsrv 打开图形窗口实现可视化

    前些天有个朋友拜托我帮忙看看 老师让配置的 Cygwin 安装 gnuplot 用 XLaunch 做图形界面 始终画不出图来 这个问题我研一的时候也遇到过 走了许多弯路 所以在电脑上一阵鼓捣 现在做一个如下记录 Cygwin 43 XLa
  • gitlab 安装/卸载/备份/迁移/汉化/重置root密码 全套教程

    服务器环境 centos7 4 gitlab版本 gitlab span class token operator span ce span class token operator span 11 span class token pun
  • bash: line 5: bgzip: command not found

    报错信息 xff1a bash line 5 bgzip command not found 解决方式 xff1a conda install tabix
  • linux之chgrp命令

    chgrp 命令更改 目录或文件所属的组 chgrp R 目录 或 文件 R xff1a 递归式改变指定目录及目录下所有文件和子目录 chgrp eg chgrp group2 file2 将file2的属组更改为group2 以空格分开
  • PageHelper limit自定义位置

    package com sgcc base common rest model import com github pagehelper Page import com github pagehelper dialect helper My
  • Ubuntu20.04 执行nvidia-smi命令,显示不能连接到显卡驱动

    错误 xff1a NVIDIA SMI has failed because it couldn t communicate with the NVIDIA driver 解决这个问题的一般方法 xff1a nvidia smi 报错 xf
  • nginx安装windows服务

    进入nginx安装目录列如 D code nginx 1 6 3 将WinSW NET4 exe复制到 nginx安装目录下 将WinSW NET4 exe重名为install service exe xff0c 并创建立install s
  • 贝塞尔曲线 弯曲动画ios_用贝塞尔曲线弯曲

    贝塞尔曲线 弯曲动画ios by Nash Vail 由Nash Vail 用贝塞尔曲线弯曲 Nerding Out With Bezier Curves Since the past few days I have been trying
  • MySQL随机获取10条数据-多种方式

    MySQL随机获取10条数据 多种方式 测试表有 254 万条数据 xff0c 各个SQL的执行效率如下 方式一 最简单 xff0c 但是效率最低 执行时间 xff1a 9 845s SELECT FROM 96 table 96 ORDE
  • ESXI克隆虚拟主机

    目录 一 通过命令克隆主机 二 通过网页端克隆主机 一 通过命令克隆主机 1 启用esxi的ssh 2 ssh登录esxi 3 找到虚拟机所在目录 4 建立新虚拟机目录 5 拷贝vmx文件 6 克隆vmdk 7 修改vmx文件 8 esxi
  • SqlServer 查询JSON 数据

    https www cnblogs com whitebai p 13614024 html
  • 一篇文章带你发中文核心期刊《计算机科学》

    中文核心期刊 计算机科学 发论文过程分享 目录 中文核心期刊 计算机科学 发论文过程分享 1 写论文 xff0c 找杂志发表 2 寻找投稿的杂志社 xff0c 修改论文 3 论文审核流程 4 关于怎么联系杂志的编辑部 投稿的大致过程如下 x
  • unity 安装踩坑

    此贴unity安装版本为2019 1 9f1 xff0c 基本项目都是向下兼容 xff01 xff01 xff01 话不多说直接上干货 1 卸载unity hub 2 卸载unity 3 删除C ProgramData Unity文件夹 4
  • Intellij IDEA 部署Web项目后运行出现HTTP Status 404(找不到对应的路径文件,不是无法访问此网站)

    之前抽空搭建了一个java的环境做了个项目 xff0c 结果重装系统以后 xff0c 重新部署项目能够运行的时候发现了项目调试404 xff08 找不到实际的页面 xff0c 后来csdn查了一下很常见的问题 xff09 给大家推荐一下这个

随机推荐