├── .cproject
├── .gitignore
├── .nedexclusions
├── .nedfolders
├── .oppbuildspec
├── .project
├── Makefile
├── README.md
├── simulations
├── aodv
│ ├── AODVNetwork.ned
│ ├── AODVSmallNetworks.ned
│ ├── README
│ ├── dynamic.xml
│ ├── moreDynamic.xml
│ ├── omnetpp.ini
│ └── simpleLifecycle.xml
├── package.ned
├── routing
│ ├── RoutingScenario.ned
│ ├── omnetpp.ini
│ ├── square.launchd.xml
│ ├── square.net.xml
│ ├── square.poly.xml
│ ├── square.rou.xml
│ └── square.sumocfg
├── veins
│ ├── README
│ ├── RSUExampleScenario.ned
│ ├── antenna.xml
│ ├── config.xml
│ ├── erlangen.launchd.xml
│ ├── erlangen.net.xml
│ ├── erlangen.png
│ ├── erlangen.poly.xml
│ ├── erlangen.rou.xml
│ ├── erlangen.sumo.cfg
│ ├── omnetpp.ini
│ └── run
├── veins_inet
│ ├── Scenario.ned
│ ├── omnetpp.ini
│ ├── square.launchd.xml
│ ├── square.net.xml
│ ├── square.poly.xml
│ ├── square.rou.xml
│ └── square.sumocfg
└── wirelessnetwork
│ ├── WirelessNetwork.ned
│ └── omnetpp.ini
└── src
├── Makefile
├── makefrag
├── package.ned
└── veins_inet
├── VeinsInetApplicationBase.cc
├── VeinsInetApplicationBase.h
├── VeinsInetApplicationBase.ned
├── VeinsInetCar.ned
├── VeinsInetManager.cc
├── VeinsInetManager.h
├── VeinsInetManager.ned
├── VeinsInetMobility.cc
├── VeinsInetMobility.h
├── VeinsInetMobility.ned
├── VeinsInetRoutingCar.ned
├── VeinsInetSampleApplication.cc
├── VeinsInetSampleApplication.h
├── VeinsInetSampleApplication.ned
├── VeinsInetSampleMessage.msg
├── package.ned
└── veins_inet.h
/.cproject:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | out/
2 |
3 | #################
4 | ## Eclipse
5 | #################
6 |
7 | *.pydevproject
8 | .metadata
9 | bin/
10 | tmp/
11 | *.tmp
12 | *.bak
13 | *.swp
14 | *~.nib
15 | local.properties
16 | .classpath
17 | .settings/
18 | .loadpath
19 |
20 | # External tool builders
21 | .externalToolBuilders/
22 |
23 | # Locally stored "Eclipse launch configurations"
24 | *.launch
25 |
26 | # CDT-specific
27 | # .cproject
28 |
29 | # PDT-specific
30 | .buildpath
31 |
32 |
33 | #################
34 | ## Visual Studio
35 | #################
36 |
37 | ## Ignore Visual Studio temporary files, build results, and
38 | ## files generated by popular Visual Studio add-ons.
39 |
40 | # User-specific files
41 | *.suo
42 | *.user
43 | *.sln.docstates
44 |
45 | # Build results
46 |
47 | [Dd]ebug/
48 | [Rr]elease/
49 | x64/
50 | build/
51 | [Bb]in/
52 | [Oo]bj/
53 |
54 | # MSTest test Results
55 | [Tt]est[Rr]esult*/
56 | [Bb]uild[Ll]og.*
57 |
58 | *_i.c
59 | *_p.c
60 | *.ilk
61 | *.meta
62 | *.obj
63 | *.pch
64 | *.pdb
65 | *.pgc
66 | *.pgd
67 | *.rsp
68 | *.sbr
69 | *.tlb
70 | *.tli
71 | *.tlh
72 | *.tmp
73 | *.tmp_proj
74 | *.log
75 | *.vspscc
76 | *.vssscc
77 | .builds
78 | *.pidb
79 | *.log
80 | *.scc
81 |
82 | # Visual C++ cache files
83 | ipch/
84 | *.aps
85 | *.ncb
86 | *.opensdf
87 | *.sdf
88 | *.cachefile
89 |
90 | # Visual Studio profiler
91 | *.psess
92 | *.vsp
93 | *.vspx
94 |
95 | # Guidance Automation Toolkit
96 | *.gpState
97 |
98 | # ReSharper is a .NET coding add-in
99 | _ReSharper*/
100 | *.[Rr]e[Ss]harper
101 |
102 | # TeamCity is a build add-in
103 | _TeamCity*
104 |
105 | # DotCover is a Code Coverage Tool
106 | *.dotCover
107 |
108 | # NCrunch
109 | *.ncrunch*
110 | .*crunch*.local.xml
111 |
112 | # Installshield output folder
113 | [Ee]xpress/
114 |
115 | # DocProject is a documentation generator add-in
116 | DocProject/buildhelp/
117 | DocProject/Help/*.HxT
118 | DocProject/Help/*.HxC
119 | DocProject/Help/*.hhc
120 | DocProject/Help/*.hhk
121 | DocProject/Help/*.hhp
122 | DocProject/Help/Html2
123 | DocProject/Help/html
124 |
125 | # Click-Once directory
126 | publish/
127 |
128 | # Publish Web Output
129 | *.Publish.xml
130 | *.pubxml
131 |
132 | # NuGet Packages Directory
133 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
134 | #packages/
135 |
136 | # Windows Azure Build Output
137 | csx
138 | *.build.csdef
139 |
140 | # Windows Store app package directory
141 | AppPackages/
142 |
143 | # Others
144 | sql/
145 | *.Cache
146 | ClientBin/
147 | [Ss]tyle[Cc]op.*
148 | ~$*
149 | *~
150 | *.dbmdl
151 | *.[Pp]ublish.xml
152 | *.pfx
153 | *.publishsettings
154 |
155 | # RIA/Silverlight projects
156 | Generated_Code/
157 |
158 | # Backup & report files from converting an old project file to a newer
159 | # Visual Studio version. Backup files are not needed, because we have git ;-)
160 | _UpgradeReport_Files/
161 | Backup*/
162 | UpgradeLog*.XML
163 | UpgradeLog*.htm
164 |
165 | # SQL Server files
166 | App_Data/*.mdf
167 | App_Data/*.ldf
168 |
169 | #############
170 | ## Windows detritus
171 | #############
172 |
173 | # Windows image file caches
174 | Thumbs.db
175 | ehthumbs.db
176 |
177 | # Folder config file
178 | Desktop.ini
179 |
180 | # Recycle Bin used on file shares
181 | $RECYCLE.BIN/
182 |
183 | # Mac crap
184 | .DS_Store
185 |
186 |
187 | #############
188 | ## Python
189 | #############
190 |
191 | *.py[co]
192 |
193 | # Packages
194 | *.egg
195 | *.egg-info
196 | dist/
197 | build/
198 | eggs/
199 | parts/
200 | var/
201 | sdist/
202 | develop-eggs/
203 | .installed.cfg
204 |
205 | # Installer logs
206 | pip-log.txt
207 |
208 | # Unit test / coverage reports
209 | .coverage
210 | .tox
211 |
212 | #Translations
213 | *.mo
214 |
215 | #Mr Developer
216 | .mr.developer.cfg
217 | .tmp*
218 | *.dat
219 | *.tkenvlog
220 | *.tkenvrc
221 | *.cmdenv-log
222 | *_m.cc
223 | *_m.h
224 | *.dll
225 | *.qtenvrc
226 | *.rt
227 | *.sca
228 | *.vci
229 | *.vec
230 |
--------------------------------------------------------------------------------
/.nedexclusions:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chaotictoejam/VANETTutorials/71bb13b74970478eaa61e103f673becf9dcda0ad/.nedexclusions
--------------------------------------------------------------------------------
/.nedfolders:
--------------------------------------------------------------------------------
1 | simulations
2 | src
3 |
--------------------------------------------------------------------------------
/.oppbuildspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | VANETTutorials
4 |
5 |
6 | inet
7 | veins
8 | veins_inet
9 |
10 |
11 |
12 | org.omnetpp.cdt.MakefileBuilder
13 |
14 |
15 |
16 |
17 | org.omnetpp.scave.builder.vectorfileindexer
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
23 | clean,full,incremental,
24 |
25 |
26 |
27 |
28 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
29 | full,incremental,
30 |
31 |
32 |
33 |
34 |
35 | org.eclipse.cdt.core.cnature
36 | org.eclipse.cdt.core.ccnature
37 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
38 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
39 | org.omnetpp.main.omnetppnature
40 |
41 |
42 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | all: checkmakefiles
2 | cd src && $(MAKE)
3 |
4 | clean: checkmakefiles
5 | cd src && $(MAKE) clean
6 |
7 | cleanall: checkmakefiles
8 | cd src && $(MAKE) MODE=release clean
9 | cd src && $(MAKE) MODE=debug clean
10 | rm -f src/Makefile
11 |
12 | makefiles:
13 | cd src && opp_makemake -f --deep
14 |
15 | checkmakefiles:
16 | @if [ ! -f src/Makefile ]; then \
17 | echo; \
18 | echo '======================================================================='; \
19 | echo 'src/Makefile does not exist. Please use "make makefiles" to generate it!'; \
20 | echo '======================================================================='; \
21 | echo; \
22 | exit 1; \
23 | fi
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # :exclamation: :exclamation: :exclamation: Notice :exclamation: :exclamation: :exclamation:
2 |
3 | I am no longer activly researching VANETs - I am keeping this repo open though so that it can be used as references when needed (although this is most likely out of date)
4 |
5 | # VANET Tutorials
6 | This repository will hold the code used in my VANET YouTube Series (OMNET++, INET, Veins, and SUMO)
7 |
8 | ## What you need
9 |
10 | In order to run this project you need the latest version of:
11 | * INET (https://github.com/inet-framework/inet) -Latest on master as of 8/25/2020
12 | * Veins (https://github.com/sommer/veins) -Latest on master as of 8/25/2020
13 | * SUMO (http://sumo.sourceforge.net/) - Latest (v1.6.0)
14 |
15 | ## Videos in Series
16 |
17 | ### Introduction to VANETs
18 |
19 | This video will give you a short introduction to VANETs (vehicular ad-hoc networks). You will learn what are VANETs, VANET architecture, potential applications, and research needs.
20 |
21 | You can watch the video here: https://youtu.be/tCs-K9AkDrQ
22 |
23 | ### Getting Started with OMNET++, INET, Veins, and SUMO
24 |
25 | In this video, you will learn how to set up your OMNET++ environment, create your own workspace, and learn how to run INET, VEINs, and SUMO.
26 |
27 | You can watch the video here: https://youtu.be/PfAWhrmoYgM
28 |
29 | ### How to Create a new OMNET++ Project that references INET and Veins
30 |
31 | This video will show you how to create a new OMNET++ project that works with both INET and Veins.
32 |
33 | You can watch the video here: https://youtu.be/mGvhbrw05sQ
34 |
35 | ### An Overview of OMNET++
36 |
37 | In this video, we are going to review OMNET++. Specifically, we will learn how OMNET++ works and how .ned files and .ini work together.
38 |
39 | You can watch the video here: https://youtu.be/Ez8tTS9iXe4
40 |
41 | ### How to Make Mobile Hosts Communicate Wirelessly in OMNET++
42 |
43 | In this video, we are going to learn how to set up a simulation where the mobile hosts communicate with each other wirelessly. This will be done using INET's standard host in OMNET++. You will learn how to make two hosts communicate with each other wirelessly, use INET's visualizer, and make your host move.
44 |
45 | You can watch the video here: https://youtu.be/9xDqjRd1DpA
46 |
47 | ### How To Create a Network and Simulation in SUMO
48 |
49 | In this video, you will learn about SUMO networks, how to create a SUMO network (by hand and using NETGENERATE), and how to create a simulation in SUMO.
50 |
51 | You can watch the video here: https://youtu.be/eXW4D32ePpE
52 |
53 | ### How to Simulate a V2V Network using OMNET++, INET, and Veins
54 |
55 | In this video, we are going to learn how to use INET and VEINs together to simulate a V2V network. This video will review the veins_inet subproject and also show you how to use AODV in your simulation. AODV is a manet routing protocol available in INET.
56 |
57 | You can watch the video here: https://youtu.be/6GG1rPvfagU
58 |
59 | ### How to Create a Network and Simulation in SUMO Using OpenStreetMap
60 |
61 | In this video, we will learn how to take a map from OpenStreetMap and turn in into a SUMO simulation (which we then can use in our VANET simulations).
62 |
63 | You can watch the video here: https://youtu.be/wZycufsTEGU
64 |
65 | ### How to Add A Custom Sumo Simulation to OMNET++
66 |
67 | In this video, you will learn how to utilize a custom map created in SUMO in your OMNET++ veins_inet simulation.
68 |
69 | You can watch the video here: https://youtu.be/7MLPVfPqFc8
70 |
--------------------------------------------------------------------------------
/simulations/aodv/AODVNetwork.ned:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2014 OpenSim Ltd.
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU Lesser General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU Lesser General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU Lesser General Public License
15 | // along with this program. If not, see http://www.gnu.org/licenses/.
16 | //
17 |
18 | package vanettutorials.simulations.aodv;
19 |
20 | import inet.common.scenario.ScenarioManager;
21 | import inet.networklayer.configurator.ipv4.Ipv4NetworkConfigurator;
22 | import inet.networklayer.ipv4.RoutingTableRecorder;
23 | import inet.node.aodv.AodvRouter;
24 | import inet.physicallayer.unitdisk.UnitDiskRadioMedium;
25 |
26 |
27 | network AODVNetwork
28 | {
29 | parameters:
30 | int numHosts;
31 | @display("bgb=650,650");
32 | submodules:
33 | radioMedium: UnitDiskRadioMedium {
34 | parameters:
35 | @display("p=100,200;is=s");
36 | }
37 | configurator: Ipv4NetworkConfigurator {
38 | parameters:
39 | config = xml("");
40 | @display("p=100,100;is=s");
41 | }
42 | routingTableRecorder: RoutingTableRecorder {
43 | parameters:
44 | @display("p=100,300;is=s");
45 | }
46 | scenarioManager: ScenarioManager {
47 | parameters:
48 | script = default(xml(""));
49 | @display("p=100,400;is=s");
50 | }
51 | host[numHosts]: AodvRouter {
52 | parameters:
53 | @display("i=device/pocketpc_s;r=,,#707070");
54 | }
55 | connections allowunconnected:
56 | }
57 |
--------------------------------------------------------------------------------
/simulations/aodv/AODVSmallNetworks.ned:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2014
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU Lesser General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU Lesser General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU Lesser General Public License
15 | // along with this program. If not, see http://www.gnu.org/licenses/.
16 | //
17 |
18 | package vanettutorials.simulations.aodv;
19 |
20 | import inet.common.scenario.ScenarioManager;
21 | import inet.networklayer.configurator.ipv4.Ipv4NetworkConfigurator;
22 | import inet.networklayer.ipv4.RoutingTableRecorder;
23 | import inet.node.aodv.AodvRouter;
24 | import inet.physicallayer.unitdisk.UnitDiskRadioMedium;
25 |
26 |
27 | network SimpleRREQ
28 | {
29 | parameters:
30 | submodules:
31 | radioMedium: UnitDiskRadioMedium {
32 | parameters:
33 | @display("p=100,200;is=s");
34 | }
35 | configurator: Ipv4NetworkConfigurator {
36 | parameters:
37 | addDefaultRoutes = false;
38 | addStaticRoutes = false;
39 | addSubnetRoutes = false;
40 | config = xml("");
41 | @display("p=100,100;is=s");
42 | }
43 | routingTableRecorder: RoutingTableRecorder {
44 | parameters:
45 | @display("p=100,300;is=s");
46 | }
47 | scenarioManager: ScenarioManager {
48 | parameters:
49 | script = default(xml(""));
50 | @display("p=100,400;is=s");
51 | }
52 | sender: AodvRouter {
53 | parameters:
54 | @display("i=device/pocketpc_s;r=,,#707070;p=270,51");
55 | }
56 | intermediateNode: AodvRouter {
57 | parameters:
58 | @display("i=device/pocketpc_s;r=,,#707070;p=270,214");
59 | }
60 | receiver: AodvRouter {
61 | parameters:
62 | @display("i=device/pocketpc_s;r=,,#707070;p=270,377");
63 | }
64 | connections allowunconnected:
65 | }
66 |
67 | network SimpleRREQ2
68 | {
69 | parameters:
70 | submodules:
71 | radioMedium: UnitDiskRadioMedium {
72 | parameters:
73 | @display("p=100,200;is=s");
74 | }
75 | configurator: Ipv4NetworkConfigurator {
76 | parameters:
77 | addDefaultRoutes = false;
78 | addStaticRoutes = false;
79 | addSubnetRoutes = false;
80 | config = xml("");
81 | @display("p=100,100;is=s");
82 | }
83 | routingTableRecorder: RoutingTableRecorder {
84 | parameters:
85 | @display("p=100,300;is=s");
86 | }
87 | scenarioManager: ScenarioManager {
88 | parameters:
89 | script = default(xml(""));
90 | @display("p=100,400;is=s");
91 | }
92 | sender: AodvRouter {
93 | parameters:
94 | @display("i=device/pocketpc_s;r=,,#707070;p=284,51");
95 | }
96 | intermediateNodeA: AodvRouter {
97 | parameters:
98 | @display("i=device/pocketpc_s;r=,,#707070;p=203,206");
99 | }
100 | intermediateNodeB: AodvRouter {
101 | parameters:
102 | @display("i=device/pocketpc_s;r=,,#707070;p=386,206");
103 | }
104 | receiver: AodvRouter {
105 | parameters:
106 | @display("i=device/pocketpc_s;r=,,#707070;p=284,378");
107 | }
108 | connections allowunconnected:
109 | }
110 |
111 | network ShortestPath
112 | {
113 | parameters:
114 | @display("bgb=650,550");
115 | submodules:
116 | radioMedium: UnitDiskRadioMedium {
117 | parameters:
118 | @display("p=100,200;is=s");
119 | }
120 | configurator: Ipv4NetworkConfigurator {
121 | parameters:
122 | addDefaultRoutes = false;
123 | addStaticRoutes = false;
124 | addSubnetRoutes = false;
125 | config = xml("");
126 | @display("p=100,100;is=s");
127 | }
128 | routingTableRecorder: RoutingTableRecorder {
129 | parameters:
130 | @display("p=100,300;is=s");
131 | }
132 | scenarioManager: ScenarioManager {
133 | parameters:
134 | script = default(xml(""));
135 | @display("p=100,400;is=s");
136 | }
137 | sender: AodvRouter {
138 | parameters:
139 | @display("i=device/pocketpc_s;r=,,#707070;p=283,63");
140 | }
141 | intermediateNodeA: AodvRouter {
142 | parameters:
143 | @display("i=device/pocketpc_s;r=,,#707070;p=203,206");
144 | }
145 | intermediateNodeB: AodvRouter {
146 | parameters:
147 | @display("i=device/pocketpc_s;r=,,#707070;p=385,256");
148 | }
149 | intermediateNodeC: AodvRouter {
150 | parameters:
151 | @display("i=device/pocketpc_s;r=,,#707070;p=292,325");
152 | }
153 | receiver: AodvRouter {
154 | parameters:
155 | @display("i=device/pocketpc_s;r=,,#707070;p=292,454");
156 | }
157 | connections allowunconnected:
158 | }
159 |
--------------------------------------------------------------------------------
/simulations/aodv/README:
--------------------------------------------------------------------------------
1 | Ad hoc On-Demand Distance Vector (AODV) Routing Examples
2 | ========================================================
3 |
4 | 1. StaticIPv4
5 | -------------
6 |
7 | In this example, static means that there is no mobility, the
8 | hosts are uniformly distributed in a 600m X 600m square.
9 |
10 | As the simulations starts, host[0] continuously tries to send
11 | ping requests to host[1]. However, at the beginning of the
12 | simulation, host[0] and the other hosts in network do not have
13 | any routing information, so host[0] broadcasts a route request
14 | for host[1].
15 |
16 | While the RREQ propagates in network, host[0] is sending more and
17 | more ping requests destined to host[1]. The AODV can consult
18 | with the IP-layer via Netfilter hooks, and can buffer these pings
19 | until it gets an appropriate RREP with valid routing information
20 | for the requested destination. Then host[0] takes these delayed
21 | pings out from the buffer and sends to host[1] as it now has
22 | information to make routing decisions.
23 |
24 | In this scenario, host[0] and host[1] are not far from each other,
25 | so AODV builds routing tables up in a very short time. Actually, it
26 | finds the shortest path (host[0] -> host[16] -> host[1]) between the
27 | two hosts.
28 |
29 | As the path is constructed, the subsequent pings and their replies
30 | arrive without any problems. The constructed path will never be
31 | outdated since it is constantly used to forward data packets (pings),
32 | so in the rest of the simulation there won't be other route request.
33 |
34 | The simulation ends without any packet loss.
35 |
36 | 2. IPv4SlowMobility, IPv4ModerateFastMobility, IPv4FastMobility
37 | ---------------------------------------------------------------
38 |
39 | The only difference in these scenarios is the speed of hosts and
40 | the ACTIVE_ROUTE_TIMEOUT parameter. In these simulations, we use
41 | MassMobility model with speeds 2m/s, 8m/s, 15m/s and with 3s, 2s, 1s
42 | ACTIVE_ROUTE_TIMEOUTs, respectively. Of course, the communicating
43 | hosts (host[0], host[1]) are staying in fixed places.
44 |
45 | The communicating scheme is inherited from the previous scenario.
46 |
47 | Since the hosts are moving, link breaks and topology changes occur, so
48 | AODV may use RERR messages, originate new route requests to establish
49 | valid paths in the changed network topology and expunge old routing table
50 | records.
51 |
52 | The user may note that the packet loss rate is growing with the speed.
53 | However, we try to compensate this "speed handicap" with lower
54 | ACTIVE_ROUTE_TIMEOUTs.
55 |
56 | 3. Dynamic
57 | ----------
58 |
59 | The Dynamic simulation is similar to StaticIPv4. It comes without mobility,
60 | and with the same communicating scheme.
61 |
62 | First, it finds the same host[0] -> host[16] -> host[1] path. However,
63 | host[16] shuts down at 25s, thus AODV has to find a different path to
64 | host[1], which will be host[0] -> host[10] -> host[17] -> host[1]. This new
65 | path is longer then the previous one, but you can see in the animation that
66 | there is no shorter route in the changed topology.
67 |
68 | We have one packet loss in this example, when host[16] stopped, host[0] have
69 | already started to originate a new ping request with the next hop host[16].
70 | Therefore, this packet will never arrive.
71 |
72 | As a result of this sending, host[0] receives a link break signal, so it can
73 | invalidate routes and inform its neighbors by initiating Route Error process.
74 |
75 | At the next ping request, host[0] has just an invalidated route to host[1],
76 | so it starts over again the Route Request process for host[1] which finds
77 | the new route mentioned above.
78 |
79 | host[16] reboots at 40s, but it will have no effect on the current route, since
80 | the new path will never be outdated due to its constant usage.
81 |
82 | 4. MoreDynamic
83 | --------------
84 |
85 | The communicating scheme is same as usual, that is, host[0] sends pings to host[1].
86 | AODV finds the shortest host[0] -> host[16] -> host[1] path. Then hosts 16, 19, 10,
87 | 17, 4, 7, 14 shut down, visually, all neighbors, except host[6], of host[1] will be
88 | unreachable. Thus, AODV has to find a bypass and it does it by finding a new path:
89 | host[0] -> host[8] -> host[2] -> host[15] -> host[6] -> host[1].
90 |
--------------------------------------------------------------------------------
/simulations/aodv/dynamic.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/simulations/aodv/moreDynamic.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/simulations/aodv/omnetpp.ini:
--------------------------------------------------------------------------------
1 | [General]
2 | network = AODVNetwork
3 | num-rngs = 3
4 | **.mobility.rng-0 = 1
5 | **.wlan[*].mac.rng-0 = 2
6 |
7 | # channel physical parameters
8 | **.wlan[*].typename = "AckingWirelessInterface"
9 | **.wlan[*].bitrate = 2Mbps
10 | **.wlan[*].mac.headerLength = 23B
11 | **.wlan[*].radio.typename = "UnitDiskRadio"
12 | **.wlan[*].radio.transmitter.headerLength = 96b
13 | **.wlan[*].radio.transmitter.communicationRange = 250m
14 | **.wlan[*].radio.transmitter.interferenceRange = 0m
15 | **.wlan[*].radio.transmitter.detectionRange = 0m
16 | **.wlan[*].radio.receiver.ignoreInterference = true
17 | *.numHosts = 20
18 |
19 | # mobility
20 | **.host[*].mobility.typename = "StationaryMobility"
21 | **.mobility.constraintAreaMinZ = 0m
22 | **.mobility.constraintAreaMaxZ = 0m
23 | **.mobility.constraintAreaMinX = 0m
24 | **.mobility.constraintAreaMinY = 0m
25 | **.mobility.constraintAreaMaxX = 600m
26 | **.mobility.constraintAreaMaxY = 600m
27 |
28 | # ping app (host[0] pinged by others)
29 | *.host[0].numApps = 1
30 | *.host[0].app[0].typename = "PingApp"
31 | *.host[0].app[0].startTime = uniform(1s,5s)
32 | *.host[0].app[0].printPing = true
33 |
34 | # nic settings
35 | **.wlan[*].bitrate = 2Mbps
36 |
37 | # lifecycle
38 | **.hasStatus = true
39 |
40 | [Config Static]
41 | description = routing without mobility
42 | *.host[*].wlan[*].radio.transmitter.communicationRange = 250m
43 | *.host[0].app[0].destAddr = "host[1](ipv4)"
44 |
45 | [Config IPv4SlowMobility]
46 | description = two fixed communicating nodes with low speed mobile nodes
47 | extends = Static
48 | # mobility
49 | **.aodv.activeRouteTimeout = 3s
50 | **.host[2..20].mobility.typename = "MassMobility"
51 | **.host[0].mobility.typename = "StationaryMobility"
52 | **.host[1].mobility.typename = "StationaryMobility"
53 |
54 | **.host[*].mobility.changeInterval = normal(5s, 0.1s)
55 | **.host[*].mobility.angleDelta = normal(0deg, 30deg)
56 | **.host[*].mobility.speed = normal(2mps, 0.01mps)
57 | **.host[1].mobility.initialX = 600m
58 | **.host[1].mobility.initialY = 600m
59 |
60 | [Config IPv4ModerateFastMobility]
61 | description = two fixed communicating nodes with moderate speed mobile nodes
62 | extends = IPv4SlowMobility
63 | # mobility
64 | **.aodv.activeRouteTimeout = 2s
65 | **.host[*].mobility.speed = normal(8mps, 0.01mps)
66 |
67 | [Config IPv4FastMobility]
68 | description = two fixed communicating nodes with high speed mobile nodes
69 | extends = IPv4SlowMobility
70 | # mobility
71 | **.aodv.activeRouteTimeout = 1s
72 | **.host[*].mobility.speed = normal(15mps, 0.01mps)
73 |
74 | [Config Dynamic]
75 | description = one node is shut down and restarted trigger route changes
76 | extends = Static
77 | *.host[*].hasStatus = true
78 | *.scenarioManager.script = xmldoc("dynamic.xml")
79 |
80 | [Config MoreDynamic]
81 | description = some nodes are shut down trigger route changes
82 | extends = Static
83 | *.host[*].hasStatus = true
84 | *.scenarioManager.script = xmldoc("moreDynamic.xml")
85 |
--------------------------------------------------------------------------------
/simulations/aodv/simpleLifecycle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/simulations/package.ned:
--------------------------------------------------------------------------------
1 | package vanettutorials.simulations;
2 |
3 | @license(LGPL);
4 |
--------------------------------------------------------------------------------
/simulations/routing/RoutingScenario.ned:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2006-2017 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 |
23 | package vanettutorials.simulations.routing;
24 |
25 | import inet.physicallayer.ieee80211.packetlevel.Ieee80211ScalarRadioMedium;
26 | import vanettutorials.veins_inet.VeinsInetRoutingCar;
27 | import vanettutorials.veins_inet.VeinsInetManager;
28 |
29 | network RoutingScenario
30 | {
31 | submodules:
32 | radioMedium: Ieee80211ScalarRadioMedium;
33 | manager: VeinsInetManager;
34 | node[0]: VeinsInetRoutingCar;
35 | }
36 |
--------------------------------------------------------------------------------
/simulations/routing/omnetpp.ini:
--------------------------------------------------------------------------------
1 | [General]
2 | network = RoutingScenario
3 | sim-time-limit = 600s
4 | debug-on-errors = true
5 | cmdenv-express-mode = true
6 | image-path = ../../../../images
7 |
8 | # UDPBasicApp
9 | *.node[*].numApps = 1
10 | *.node[*].app[0].typename = "UdpBasicApp"
11 | *.node[*].app[0].destAddresses = "node[*]"
12 | *.node[*].app[0].destPort = 5000
13 | *.node[*].app[0].messageLength = 1000B
14 | *.node[*].app[0].sendInterval = exponential(12ms)
15 | *.node[*].app[0].packetName = "UDPData"
16 |
17 | # Ieee80211Interface
18 | *.node[*].wlan[0].opMode = "p"
19 | *.node[*].wlan[0].radio.bandName = "5.9 GHz"
20 | *.node[*].wlan[0].radio.channelNumber = 3
21 | *.node[*].wlan[0].radio.transmitter.power = 20mW
22 | *.node[*].wlan[0].radio.bandwidth = 10 MHz
23 |
24 | # HostAutoConfigurator
25 | *.node[*].ipv4.configurator.typename = "HostAutoConfigurator"
26 | *.node[*].ipv4.configurator.interfaces = "wlan0"
27 | *.node[*].ipv4.configurator.mcastGroups = "224.0.0.1"
28 |
29 | # VeinsInetMobility
30 | *.node[*].mobility.typename = "VeinsInetMobility"
31 |
32 | # VeinsInetManager
33 | *.manager.updateInterval = 0.1s
34 | *.manager.host = "localhost"
35 | *.manager.port = 9999
36 | *.manager.autoShutdown = true
37 | *.manager.launchConfig = xmldoc("square.launchd.xml")
38 | *.manager.moduleType = "vanettutorials.veins_inet.VeinsInetRoutingCar"
39 |
40 | **.vector-recording = true
41 |
42 | # Routing
43 | **.router = "Aodv"
--------------------------------------------------------------------------------
/simulations/routing/square.launchd.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/simulations/routing/square.net.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
33 |
34 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
--------------------------------------------------------------------------------
/simulations/routing/square.poly.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/simulations/routing/square.rou.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/simulations/routing/square.sumocfg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/simulations/veins/README:
--------------------------------------------------------------------------------
1 | Veins tutorial example.
2 |
3 | This simulation requires sumo-launchd to be started and listening for
4 | connections on a TCP socket, e.g. using "~/src/veins/sumo-launchd.py -vv".
5 |
6 |
--------------------------------------------------------------------------------
/simulations/veins/RSUExampleScenario.ned:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2017 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 | package vanettutorials.simulations.veins;
23 |
24 | import org.car2x.veins.nodes.RSU;
25 | import org.car2x.veins.nodes.Scenario;
26 |
27 | network RSUExampleScenario extends Scenario
28 | {
29 | submodules:
30 | rsu[1]: RSU {
31 | @display("p=150,140;i=veins/sign/yellowdiamond;is=vs");
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/simulations/veins/antenna.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/simulations/veins/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/simulations/veins/erlangen.launchd.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/simulations/veins/erlangen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chaotictoejam/VANETTutorials/71bb13b74970478eaa61e103f673becf9dcda0ad/simulations/veins/erlangen.png
--------------------------------------------------------------------------------
/simulations/veins/erlangen.rou.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
33 |
34 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/simulations/veins/erlangen.sumo.cfg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/simulations/veins/omnetpp.ini:
--------------------------------------------------------------------------------
1 | [General]
2 | cmdenv-express-mode = true
3 | cmdenv-autoflush = true
4 | cmdenv-status-frequency = 1s
5 | **.cmdenv-log-level = info
6 |
7 | image-path = ../../images
8 |
9 | network = RSUExampleScenario
10 |
11 | ##########################################################
12 | # Simulation parameters #
13 | ##########################################################
14 | debug-on-errors = true
15 | print-undisposed = true
16 |
17 | sim-time-limit = 200s
18 |
19 | **.scalar-recording = true
20 | **.vector-recording = true
21 |
22 | *.playgroundSizeX = 2500m
23 | *.playgroundSizeY = 2500m
24 | *.playgroundSizeZ = 50m
25 |
26 |
27 | ##########################################################
28 | # Annotation parameters #
29 | ##########################################################
30 | *.annotations.draw = true
31 |
32 | ##########################################################
33 | # Obstacle parameters #
34 | ##########################################################
35 | *.obstacles.obstacles = xmldoc("config.xml", "//AnalogueModel[@type='SimpleObstacleShadowing']/obstacles")
36 |
37 | ##########################################################
38 | # TraCIScenarioManager parameters #
39 | ##########################################################
40 | *.manager.updateInterval = 1s
41 | *.manager.host = "localhost"
42 | *.manager.port = 9999
43 | *.manager.autoShutdown = true
44 | *.manager.launchConfig = xmldoc("erlangen.launchd.xml")
45 |
46 | ##########################################################
47 | # RSU SETTINGS #
48 | # #
49 | # #
50 | ##########################################################
51 | *.rsu[0].mobility.x = 2000
52 | *.rsu[0].mobility.y = 2000
53 | *.rsu[0].mobility.z = 3
54 |
55 | *.rsu[*].applType = "TraCIDemoRSU11p"
56 | *.rsu[*].appl.headerLength = 80 bit
57 | *.rsu[*].appl.sendBeacons = false
58 | *.rsu[*].appl.dataOnSch = false
59 | *.rsu[*].appl.beaconInterval = 1s
60 | *.rsu[*].appl.beaconUserPriority = 7
61 | *.rsu[*].appl.dataUserPriority = 5
62 | *.rsu[*].nic.phy80211p.antennaOffsetZ = 0 m
63 |
64 | ##########################################################
65 | # 11p specific parameters #
66 | # #
67 | # NIC-Settings #
68 | ##########################################################
69 | *.connectionManager.sendDirect = true
70 | *.connectionManager.maxInterfDist = 2600m
71 | *.connectionManager.drawMaxIntfDist = false
72 |
73 | *.**.nic.mac1609_4.useServiceChannel = false
74 |
75 | *.**.nic.mac1609_4.txPower = 20mW
76 | *.**.nic.mac1609_4.bitrate = 6Mbps
77 | *.**.nic.phy80211p.minPowerLevel = -110dBm
78 |
79 | *.**.nic.phy80211p.useNoiseFloor = true
80 | *.**.nic.phy80211p.noiseFloor = -98dBm
81 |
82 | *.**.nic.phy80211p.decider = xmldoc("config.xml")
83 | *.**.nic.phy80211p.analogueModels = xmldoc("config.xml")
84 | *.**.nic.phy80211p.usePropagationDelay = true
85 |
86 | *.**.nic.phy80211p.antenna = xmldoc("antenna.xml", "/root/Antenna[@id='monopole']")
87 | *.node[*].nic.phy80211p.antennaOffsetY = 0 m
88 | *.node[*].nic.phy80211p.antennaOffsetZ = 1.895 m
89 |
90 | ##########################################################
91 | # App Layer #
92 | ##########################################################
93 | *.node[*].applType = "TraCIDemo11p"
94 | *.node[*].appl.headerLength = 80 bit
95 | *.node[*].appl.sendBeacons = false
96 | *.node[*].appl.dataOnSch = false
97 | *.node[*].appl.beaconInterval = 1s
98 |
99 | ##########################################################
100 | # Mobility #
101 | ##########################################################
102 | *.node[*].veinsmobility.x = 0
103 | *.node[*].veinsmobility.y = 0
104 | *.node[*].veinsmobility.z = 0
105 | *.node[*].veinsmobility.setHostSpeed = false
106 | *.node[*0].veinsmobility.accidentCount = 1
107 | *.node[*0].veinsmobility.accidentStart = 73s
108 | *.node[*0].veinsmobility.accidentDuration = 50s
109 |
110 | [Config Default]
111 |
112 | [Config WithBeaconing]
113 | *.rsu[*].appl.sendBeacons = true
114 | *.node[*].appl.sendBeacons = true
115 |
116 | [Config WithChannelSwitching]
117 | *.**.nic.mac1609_4.useServiceChannel = true
118 | *.node[*].appl.dataOnSch = true
119 | *.rsu[*].appl.dataOnSch = true
120 |
121 |
--------------------------------------------------------------------------------
/simulations/veins/run:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright (C) 2011 Christoph Sommer
5 | #
6 | # Documentation for these modules is at http://veins.car2x.org/
7 | #
8 | # SPDX-License-Identifier: GPL-2.0-or-later
9 | #
10 | # This program is free software; you can redistribute it and/or modify
11 | # it under the terms of the GNU General Public License as published by
12 | # the Free Software Foundation; either version 2 of the License, or
13 | # (at your option) any later version.
14 | #
15 | # This program is distributed in the hope that it will be useful,
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | # GNU General Public License for more details.
19 | #
20 | # You should have received a copy of the GNU General Public License
21 | # along with this program; if not, write to the Free Software
22 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | #
24 |
25 | exec ../../run "$@"
26 |
--------------------------------------------------------------------------------
/simulations/veins_inet/Scenario.ned:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2006-2017 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 |
23 | package vanettutorials.simulations.veins_inet;
24 |
25 | import inet.physicallayer.ieee80211.packetlevel.Ieee80211ScalarRadioMedium;
26 | import vanettutorials.veins_inet.VeinsInetCar;
27 | import vanettutorials.veins_inet.VeinsInetManager;
28 |
29 | network Scenario
30 | {
31 | submodules:
32 | radioMedium: Ieee80211ScalarRadioMedium;
33 | manager: VeinsInetManager;
34 | node[0]: VeinsInetCar;
35 | }
36 |
--------------------------------------------------------------------------------
/simulations/veins_inet/omnetpp.ini:
--------------------------------------------------------------------------------
1 | [General]
2 | network = Scenario
3 | sim-time-limit = 60s
4 | debug-on-errors = true
5 | cmdenv-express-mode = true
6 | image-path = ../../../../images
7 |
8 | # UDPBasicApp
9 | *.node[*].numApps = 1
10 | *.node[*].app[0].typename = "vanettutorials.veins_inet.VeinsInetSampleApplication"
11 | *.node[*].app[0].interface = "wlan0"
12 |
13 | # Ieee80211Interface
14 | *.node[*].wlan[0].opMode = "p"
15 | *.node[*].wlan[0].radio.bandName = "5.9 GHz"
16 | *.node[*].wlan[0].radio.channelNumber = 3
17 | *.node[*].wlan[0].radio.transmitter.power = 20mW
18 | *.node[*].wlan[0].radio.bandwidth = 10 MHz
19 |
20 | # HostAutoConfigurator
21 | *.node[*].ipv4.configurator.typename = "HostAutoConfigurator"
22 | *.node[*].ipv4.configurator.interfaces = "wlan0"
23 | *.node[*].ipv4.configurator.mcastGroups = "224.0.0.1"
24 |
25 | # VeinsInetMobility
26 | *.node[*].mobility.typename = "VeinsInetMobility"
27 |
28 | # VeinsInetManager
29 | *.manager.updateInterval = 0.1s
30 | *.manager.host = "localhost"
31 | *.manager.port = 9999
32 | *.manager.autoShutdown = true
33 | *.manager.launchConfig = xmldoc("square.launchd.xml")
34 | *.manager.moduleType = "vanettutorials.veins_inet.VeinsInetCar"
35 |
36 | **.vector-recording = true
--------------------------------------------------------------------------------
/simulations/veins_inet/square.launchd.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/simulations/veins_inet/square.net.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
33 |
34 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
--------------------------------------------------------------------------------
/simulations/veins_inet/square.poly.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/simulations/veins_inet/square.rou.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/simulations/veins_inet/square.sumocfg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/simulations/wirelessnetwork/WirelessNetwork.ned:
--------------------------------------------------------------------------------
1 | //
2 | // This program is free software: you can redistribute it and/or modify
3 | // it under the terms of the GNU Lesser General Public License as published by
4 | // the Free Software Foundation, either version 3 of the License, or
5 | // (at your option) any later version.
6 | //
7 | // This program is distributed in the hope that it will be useful,
8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | // GNU Lesser General Public License for more details.
11 | //
12 | // You should have received a copy of the GNU Lesser General Public License
13 | // along with this program. If not, see http://www.gnu.org/licenses/.
14 | //
15 |
16 | package vanettutorials.simulations.wirelessnetwork;
17 |
18 | import inet.networklayer.configurator.ipv4.Ipv4NetworkConfigurator;
19 | import inet.physicallayer.contract.packetlevel.IRadioMedium;
20 | import inet.node.inet.WirelessHost;
21 | import inet.visualizer.integrated.IntegratedCanvasVisualizer;
22 |
23 | //
24 | // TODO auto-generated type
25 | //
26 | network WirelessNetwork
27 | {
28 | parameters:
29 | @display("bgb=600,600");
30 | submodules:
31 | visualizer: IntegratedCanvasVisualizer;
32 | configurator: Ipv4NetworkConfigurator;
33 | radioMedium: like IRadioMedium {
34 | @display("p=30,98");
35 | }
36 | hostA: WirelessHost{
37 | @display("p=50,195");
38 | }
39 | hostB: WirelessHost {
40 | @display("p=450,195");
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/simulations/wirelessnetwork/omnetpp.ini:
--------------------------------------------------------------------------------
1 | [General]
2 | description = Simple sim where two host communicate wirelessly
3 | network = WirelessNetwork
4 | sim-time-limit = 60s
5 |
6 | *.host*.ipv4.arp.typename = "GlobalArp"
7 |
8 | # HostA Configuration
9 | *.hostA.numApps = 1
10 | *.hostA.app[0].typename = "UdpBasicApp"
11 | *.hostA.app[0].destAddresses = "hostB"
12 | *.hostA.app[0].destPort = 5000
13 | *.hostA.app[0].messageLength = 1000B
14 | *.hostA.app[0].sendInterval = exponential(12ms)
15 | *.hostA.app[0].packetName = "UDPData"
16 |
17 | # HostB Configuration
18 | *.hostB.numApps = 1
19 | *.hostB.app[0].typename = "UdpSink"
20 | *.hostB.app[0].localPort = 5000
21 |
22 | # WLAN Configuration
23 | *.host*.wlan[0].typename = "AckingWirelessInterface"
24 | *.host*.wlan[0].mac.useAck = false
25 | *.host*.wlan[0].mac.fullDuplex = false
26 | *.host*.wlan[0].radio.transmitter.communicationRange = 500m
27 | *.host*.wlan[0].radio.receiver.ignoreInterference = true
28 | *.host*.wlan[0].mac.headerLength = 23B
29 |
30 | *.host*.**.bitrate = 1Mbps
31 |
32 | # Visualizer Configuration
33 | **.radio.displayCommunicationRange = true
34 | *.visualizer.mediumVisualizer.displaySignals = true
35 | *.visualizer.physicalLinkVisualizer.displayLinks = true
36 | *.visualizer.physicalLinkVisualizer.packetFilter = "UDPData*"
37 | *.visualizer.mobilityVisualizer.displayVelocities = true
38 | *.visualizer.mobilityVisualizer.displayMovementTrails = true
39 |
40 | # Add Mobility to Hosts
41 | *.hostA.mobility.typename = "LinearMobility"
42 | *.hostA.mobility.speed = 12mps
43 | *.hostA.mobility.initialMovementHeading = 200deg
--------------------------------------------------------------------------------
/src/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # OMNeT++/OMNEST Makefile for $(LIB_PREFIX)VANETTutorials
3 | #
4 | # This file was generated with the command:
5 | # opp_makemake --make-so -f --deep -KINET_PROJ=../../inet -KVEINS_PROJ=../../veins -DINET_IMPORT -I. -I$$\(INET_PROJ\)/src -I$$\(VEINS_PROJ\)/src -I. -L$$\(INET_PROJ\)/src -L$$\(VEINS_PROJ\)/src -lINET$$\(D\) -lveins$$\(D\)
6 | #
7 |
8 | # Name of target to be created (-o option)
9 | TARGET = $(LIB_PREFIX)VANETTutorials$(D)$(SHARED_LIB_SUFFIX)
10 | TARGET_DIR = .
11 |
12 | # C++ include paths (with -I)
13 | INCLUDE_PATH = -I. -I$(INET_PROJ)/src -I$(VEINS_PROJ)/src -I.
14 |
15 | # Additional object and library files to link with
16 | EXTRA_OBJS =
17 |
18 | # Additional libraries (-L, -l options)
19 | LIBS = $(LDFLAG_LIBPATH)$(INET_PROJ)/src $(LDFLAG_LIBPATH)$(VEINS_PROJ)/src -lINET$(D) -lveins$(D)
20 |
21 | # Output directory
22 | PROJECT_OUTPUT_DIR = ../out
23 | PROJECTRELATIVE_PATH = src
24 | O = $(PROJECT_OUTPUT_DIR)/$(CONFIGNAME)/$(PROJECTRELATIVE_PATH)
25 |
26 | # Object files for local .cc, .msg and .sm files
27 | OBJS = $O/veins_inet/VeinsInetApplicationBase.o $O/veins_inet/VeinsInetManager.o $O/veins_inet/VeinsInetMobility.o $O/veins_inet/VeinsInetSampleApplication.o $O/veins_inet/VeinsInetSampleMessage_m.o
28 |
29 | # Message files
30 | MSGFILES = \
31 | veins_inet/VeinsInetSampleMessage.msg
32 |
33 | # SM files
34 | SMFILES =
35 |
36 | # Other makefile variables (-K)
37 | INET_PROJ=../../inet
38 | VEINS_PROJ=../../veins
39 |
40 | #------------------------------------------------------------------------------
41 |
42 | # Pull in OMNeT++ configuration (Makefile.inc)
43 |
44 | ifneq ("$(OMNETPP_CONFIGFILE)","")
45 | CONFIGFILE = $(OMNETPP_CONFIGFILE)
46 | else
47 | ifneq ("$(OMNETPP_ROOT)","")
48 | CONFIGFILE = $(OMNETPP_ROOT)/Makefile.inc
49 | else
50 | CONFIGFILE = $(shell opp_configfilepath)
51 | endif
52 | endif
53 |
54 | ifeq ("$(wildcard $(CONFIGFILE))","")
55 | $(error Config file '$(CONFIGFILE)' does not exist -- add the OMNeT++ bin directory to the path so that opp_configfilepath can be found, or set the OMNETPP_CONFIGFILE variable to point to Makefile.inc)
56 | endif
57 |
58 | include $(CONFIGFILE)
59 |
60 | # Simulation kernel and user interface libraries
61 | OMNETPP_LIBS = -loppenvir$D $(KERNEL_LIBS) $(SYS_LIBS)
62 | ifneq ($(TOOLCHAIN_NAME),clangc2)
63 | LIBS += -Wl,-rpath,$(abspath $(INET_PROJ)/src) -Wl,-rpath,$(abspath $(VEINS_PROJ)/src)
64 | endif
65 |
66 | COPTS = $(CFLAGS) $(IMPORT_DEFINES) -DINET_IMPORT $(INCLUDE_PATH) -I$(OMNETPP_INCL_DIR)
67 | MSGCOPTS = $(INCLUDE_PATH)
68 | SMCOPTS =
69 |
70 | # we want to recompile everything if COPTS changes,
71 | # so we store COPTS into $COPTS_FILE and have object
72 | # files depend on it (except when "make depend" was called)
73 | COPTS_FILE = $O/.last-copts
74 | ifneq ("$(COPTS)","$(shell cat $(COPTS_FILE) 2>/dev/null || echo '')")
75 | $(shell $(MKPATH) "$O" && echo "$(COPTS)" >$(COPTS_FILE))
76 | endif
77 |
78 | #------------------------------------------------------------------------------
79 | # User-supplied makefile fragment(s)
80 | # >>>
81 | # inserted from file 'makefrag':
82 | #
83 | # Use the new message compiler introduced in OMNeT++ 5.3
84 | #
85 | MSGC:=$(MSGC) --msg6
86 |
87 | ifeq ($(PLATFORM),win32.x86_64)
88 | #
89 | # on windows we have to link with the ws2_32 (winsock2) library as it is no longer added
90 | # to the omnetpp system libraries by default (as of OMNeT++ 5.1)
91 | #
92 | LIBS += -lws2_32
93 | DEFINES += -DINET_EXPORT
94 | ENABLE_AUTO_IMPORT=-Wl,--enable-auto-import
95 | LDFLAGS := $(filter-out $(ENABLE_AUTO_IMPORT), $(LDFLAGS))
96 |
97 | endif
98 |
99 | # <<<
100 | #------------------------------------------------------------------------------
101 |
102 | # Main target
103 | all: $(TARGET_DIR)/$(TARGET)
104 |
105 | $(TARGET_DIR)/% :: $O/%
106 | @mkdir -p $(TARGET_DIR)
107 | $(Q)$(LN) $< $@
108 | ifeq ($(TOOLCHAIN_NAME),clangc2)
109 | $(Q)-$(LN) $(<:%.dll=%.lib) $(@:%.dll=%.lib)
110 | endif
111 |
112 | $O/$(TARGET): $(OBJS) $(wildcard $(EXTRA_OBJS)) Makefile $(CONFIGFILE)
113 | @$(MKPATH) $O
114 | @echo Creating shared library: $@
115 | $(Q)$(SHLIB_LD) -o $O/$(TARGET) $(OBJS) $(EXTRA_OBJS) $(AS_NEEDED_OFF) $(WHOLE_ARCHIVE_ON) $(LIBS) $(WHOLE_ARCHIVE_OFF) $(OMNETPP_LIBS) $(LDFLAGS)
116 | $(Q)$(SHLIB_POSTPROCESS) $O/$(TARGET)
117 |
118 | .PHONY: all clean cleanall depend msgheaders smheaders
119 |
120 | .SUFFIXES: .cc
121 |
122 | $O/%.o: %.cc $(COPTS_FILE) | msgheaders smheaders
123 | @$(MKPATH) $(dir $@)
124 | $(qecho) "$<"
125 | $(Q)$(CXX) -c $(CXXFLAGS) $(COPTS) -o $@ $<
126 |
127 | %_m.cc %_m.h: %.msg
128 | $(qecho) MSGC: $<
129 | $(Q)$(MSGC) -s _m.cc -MD -MP -MF $O/$(basename $<)_m.h.d $(MSGCOPTS) $?
130 |
131 | %_sm.cc %_sm.h: %.sm
132 | $(qecho) SMC: $<
133 | $(Q)$(SMC) -c++ -suffix cc $(SMCOPTS) $?
134 |
135 | msgheaders: $(MSGFILES:.msg=_m.h)
136 |
137 | smheaders: $(SMFILES:.sm=_sm.h)
138 |
139 | clean:
140 | $(qecho) Cleaning $(TARGET)
141 | $(Q)-rm -rf $O
142 | $(Q)-rm -f $(TARGET_DIR)/$(TARGET)
143 | $(Q)-rm -f $(TARGET_DIR)/$(TARGET:%.dll=%.lib)
144 | $(Q)-rm -f $(call opp_rwildcard, . , *_m.cc *_m.h *_sm.cc *_sm.h)
145 |
146 | cleanall:
147 | $(Q)$(MAKE) -s clean MODE=release
148 | $(Q)$(MAKE) -s clean MODE=debug
149 | $(Q)-rm -rf $(PROJECT_OUTPUT_DIR)
150 |
151 | # include all dependencies
152 | -include $(OBJS:%=%.d) $(MSGFILES:%.msg=$O/%_m.h.d)
153 |
--------------------------------------------------------------------------------
/src/makefrag:
--------------------------------------------------------------------------------
1 | #
2 | # Use the new message compiler introduced in OMNeT++ 5.3
3 | #
4 | MSGC:=$(MSGC) --msg6
5 |
6 | ifeq ($(PLATFORM),win32.x86_64)
7 | #
8 | # on windows we have to link with the ws2_32 (winsock2) library as it is no longer added
9 | # to the omnetpp system libraries by default (as of OMNeT++ 5.1)
10 | #
11 | LIBS += -lws2_32
12 | DEFINES += -DINET_EXPORT
13 | ENABLE_AUTO_IMPORT=-Wl,--enable-auto-import
14 | LDFLAGS := $(filter-out $(ENABLE_AUTO_IMPORT), $(LDFLAGS))
15 |
16 | endif
--------------------------------------------------------------------------------
/src/package.ned:
--------------------------------------------------------------------------------
1 | package vanettutorials;
2 |
3 | @license(LGPL);
4 |
--------------------------------------------------------------------------------
/src/veins_inet/VeinsInetApplicationBase.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2018 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 |
23 | //
24 | // Veins "application layer" module for the INET Framework
25 | // Based on inet::UdpBasicApp of INET Framework v4.0.0
26 | //
27 |
28 | #include "veins_inet/VeinsInetApplicationBase.h"
29 |
30 | #include "inet/common/lifecycle/ModuleOperations.h"
31 | #include "inet/common/ModuleAccess.h"
32 | #include "inet/common/packet/Packet.h"
33 | #include "inet/common/TagBase_m.h"
34 | #include "inet/common/TimeTag_m.h"
35 | #include "inet/networklayer/common/L3AddressResolver.h"
36 | #include "inet/networklayer/common/L3AddressTag_m.h"
37 | #include "inet/transportlayer/contract/udp/UdpControlInfo_m.h"
38 |
39 | namespace veins {
40 |
41 | using namespace inet;
42 |
43 | Define_Module(VeinsInetApplicationBase);
44 |
45 | VeinsInetApplicationBase::VeinsInetApplicationBase()
46 | {
47 | }
48 |
49 | int VeinsInetApplicationBase::numInitStages() const
50 | {
51 | return inet::NUM_INIT_STAGES;
52 | }
53 |
54 | void VeinsInetApplicationBase::initialize(int stage)
55 | {
56 | ApplicationBase::initialize(stage);
57 |
58 | if (stage == INITSTAGE_LOCAL) {
59 | }
60 | }
61 |
62 | void VeinsInetApplicationBase::handleStartOperation(LifecycleOperation* operation)
63 | {
64 | mobility = veins::VeinsInetMobilityAccess().get(getParentModule());
65 | traci = mobility->getCommandInterface();
66 | traciVehicle = mobility->getVehicleCommandInterface();
67 |
68 | L3AddressResolver().tryResolve("224.0.0.1", destAddress);
69 | ASSERT(!destAddress.isUnspecified());
70 |
71 | socket.setOutputGate(gate("socketOut"));
72 | socket.bind(L3Address(), portNumber);
73 |
74 | const char* interface = par("interface");
75 | ASSERT(interface[0]);
76 | IInterfaceTable* ift = getModuleFromPar(par("interfaceTableModule"), this);
77 | #if INET_VERSION >= 0x0402
78 | InterfaceEntry* ie = ift->findInterfaceByName(interface);
79 | #else
80 | InterfaceEntry* ie = ift->getInterfaceByName(interface);
81 | #endif
82 | ASSERT(ie);
83 | socket.setMulticastOutputInterface(ie->getInterfaceId());
84 |
85 | MulticastGroupList mgl = ift->collectMulticastGroups();
86 | socket.joinLocalMulticastGroups(mgl);
87 |
88 | socket.setCallback(this);
89 |
90 | bool ok = startApplication();
91 | ASSERT(ok);
92 | }
93 |
94 | bool VeinsInetApplicationBase::startApplication()
95 | {
96 | return true;
97 | }
98 |
99 | bool VeinsInetApplicationBase::stopApplication()
100 | {
101 | return true;
102 | }
103 |
104 | void VeinsInetApplicationBase::handleStopOperation(LifecycleOperation* operation)
105 | {
106 | bool ok = stopApplication();
107 | ASSERT(ok);
108 |
109 | socket.close();
110 | }
111 |
112 | void VeinsInetApplicationBase::handleCrashOperation(LifecycleOperation* operation)
113 | {
114 | socket.destroy();
115 | }
116 |
117 | void VeinsInetApplicationBase::finish()
118 | {
119 | ApplicationBase::finish();
120 | }
121 |
122 | VeinsInetApplicationBase::~VeinsInetApplicationBase()
123 | {
124 | }
125 |
126 | void VeinsInetApplicationBase::refreshDisplay() const
127 | {
128 | ApplicationBase::refreshDisplay();
129 |
130 | char buf[100];
131 | sprintf(buf, "okay");
132 | getDisplayString().setTagArg("t", 0, buf);
133 | }
134 |
135 | void VeinsInetApplicationBase::handleMessageWhenUp(cMessage* msg)
136 | {
137 | if (timerManager.handleMessage(msg)) return;
138 |
139 | if (msg->isSelfMessage()) {
140 | throw cRuntimeError("This module does not use custom self messages");
141 | return;
142 | }
143 |
144 | socket.processMessage(msg);
145 | }
146 |
147 | void VeinsInetApplicationBase::socketDataArrived(UdpSocket* socket, Packet* packet)
148 | {
149 | auto pk = std::shared_ptr(packet);
150 |
151 | // ignore local echoes
152 | auto srcAddr = pk->getTag()->getSrcAddress();
153 | if (srcAddr == Ipv4Address::LOOPBACK_ADDRESS) {
154 | EV_DEBUG << "Ignored local echo: " << pk.get() << endl;
155 | return;
156 | }
157 |
158 | // statistics
159 | emit(packetReceivedSignal, pk.get());
160 |
161 | // process incoming packet
162 | processPacket(pk);
163 | }
164 |
165 | void VeinsInetApplicationBase::socketErrorArrived(UdpSocket* socket, Indication* indication)
166 | {
167 | EV_WARN << "Ignoring UDP error report " << indication->getName() << endl;
168 | delete indication;
169 | }
170 |
171 | void VeinsInetApplicationBase::socketClosed(UdpSocket* socket)
172 | {
173 | if (operationalState == State::STOPPING_OPERATION) {
174 | startActiveOperationExtraTimeOrFinish(-1);
175 | }
176 | }
177 |
178 | void VeinsInetApplicationBase::timestampPayload(inet::Ptr payload)
179 | {
180 | payload->removeTagIfPresent(b(0), b(-1));
181 | auto creationTimeTag = payload->addTag();
182 | creationTimeTag->setCreationTime(simTime());
183 | }
184 |
185 | void VeinsInetApplicationBase::sendPacket(std::unique_ptr pk)
186 | {
187 | emit(packetSentSignal, pk.get());
188 | socket.sendTo(pk.release(), destAddress, portNumber);
189 | }
190 |
191 | std::unique_ptr VeinsInetApplicationBase::createPacket(std::string name)
192 | {
193 | return std::unique_ptr(new Packet(name.c_str()));
194 | }
195 |
196 | void VeinsInetApplicationBase::processPacket(std::shared_ptr pk)
197 | {
198 | }
199 |
200 | } // namespace veins
201 |
--------------------------------------------------------------------------------
/src/veins_inet/VeinsInetApplicationBase.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2018 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 |
23 | #pragma once
24 |
25 | #include
26 |
27 | #include "veins_inet/veins_inet.h"
28 |
29 | #include "inet/common/INETDefs.h"
30 |
31 | #include "inet/applications/base/ApplicationBase.h"
32 | #include "inet/transportlayer/contract/udp/UdpSocket.h"
33 | #include "veins_inet/VeinsInetMobility.h"
34 | #include "veins/modules/utility/TimerManager.h"
35 |
36 | namespace veins {
37 |
38 | class VEINS_INET_API VeinsInetApplicationBase : public inet::ApplicationBase, public inet::UdpSocket::ICallback {
39 | protected:
40 | veins::VeinsInetMobility* mobility;
41 | veins::TraCICommandInterface* traci;
42 | veins::TraCICommandInterface::Vehicle* traciVehicle;
43 | veins::TimerManager timerManager{this};
44 |
45 | inet::L3Address destAddress;
46 | const int portNumber = 9001;
47 | inet::UdpSocket socket;
48 |
49 | protected:
50 | virtual int numInitStages() const override;
51 | virtual void initialize(int stage) override;
52 | virtual void handleStartOperation(inet::LifecycleOperation* doneCallback) override;
53 | virtual bool startApplication();
54 | virtual bool stopApplication();
55 | virtual void handleStopOperation(inet::LifecycleOperation* doneCallback) override;
56 | virtual void handleCrashOperation(inet::LifecycleOperation* doneCallback) override;
57 | virtual void finish() override;
58 |
59 | virtual void refreshDisplay() const override;
60 | virtual void handleMessageWhenUp(inet::cMessage* msg) override;
61 |
62 | virtual void socketDataArrived(inet::UdpSocket* socket, inet::Packet* packet) override;
63 | virtual void socketErrorArrived(inet::UdpSocket* socket, inet::Indication* indication) override;
64 | virtual void socketClosed(inet::UdpSocket* socket) override;
65 |
66 | virtual std::unique_ptr createPacket(std::string name);
67 | virtual void processPacket(std::shared_ptr pk);
68 | virtual void timestampPayload(inet::Ptr payload);
69 | virtual void sendPacket(std::unique_ptr pk);
70 |
71 | public:
72 | VeinsInetApplicationBase();
73 | ~VeinsInetApplicationBase();
74 | };
75 |
76 | } // namespace veins
77 |
--------------------------------------------------------------------------------
/src/veins_inet/VeinsInetApplicationBase.ned:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2018 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 |
23 | package vanettutorials.veins_inet;
24 |
25 | import inet.applications.contract.IApp;
26 |
27 | simple VeinsInetApplicationBase like IApp
28 | {
29 | parameters:
30 | string interfaceTableModule; // The path to the InterfaceTable module
31 | string interface = default("wlan0"); // The interface name of where to send packets (via multicast)
32 |
33 | @display("i=block/app");
34 | @class(veins::VeinsInetApplicationBase);
35 | @signal[packetSent](type=inet::Packet);
36 | @signal[packetReceived](type=inet::Packet);
37 | @statistic[packetReceived](title="packets received"; source=packetReceived; record=count,"sum(packetBytes)","vector(packetBytes)"; interpolationmode=none);
38 | @statistic[throughput](title="throughput"; unit=bps; source="throughput(packetReceived)"; record=vector);
39 | @statistic[packetSent](title="packets sent"; source=packetSent; record=count,"sum(packetBytes)","vector(packetBytes)"; interpolationmode=none);
40 | @statistic[rcvdPkLifetime](title="received packet lifetime"; source="dataAge(packetReceived)"; unit=s; record=stats,vector; interpolationmode=none);
41 | gates:
42 | input socketIn @labels(UdpControlInfo/up);
43 | output socketOut @labels(UdpControlInfo/down);
44 | }
45 |
--------------------------------------------------------------------------------
/src/veins_inet/VeinsInetCar.ned:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2006-2017 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 |
23 | package vanettutorials.veins_inet;
24 |
25 | import inet.networklayer.configurator.ipv4.HostAutoConfigurator;
26 | import inet.node.inet.AdhocHost;
27 |
28 | //
29 | // Wireless-enabled Host
30 | //
31 | module VeinsInetCar extends AdhocHost
32 | {
33 | parameters:
34 | @display("i=device/cellphone");
35 |
36 | submodules:
37 |
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/src/veins_inet/VeinsInetManager.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2006-2017 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 |
23 | #include "veins_inet/VeinsInetManager.h"
24 |
25 | #include "veins/base/utils/Coord.h"
26 | #include "veins_inet/VeinsInetMobility.h"
27 |
28 | #include "inet/common/scenario/ScenarioManager.h"
29 |
30 | using veins::VeinsInetManager;
31 |
32 | Define_Module(veins::VeinsInetManager);
33 |
34 | VeinsInetManager::~VeinsInetManager()
35 | {
36 | }
37 |
38 | void VeinsInetManager::initialize(int stage)
39 | {
40 | TraCIScenarioManagerLaunchd::initialize(stage);
41 |
42 | if (stage != 1)
43 | return;
44 |
45 | #if INET_VERSION >= 0x0402
46 | signalManager.subscribeCallback(this, TraCIScenarioManager::traciModulePreInitSignal, [this](SignalPayload payload) {
47 | cModule* module = dynamic_cast(payload.p);
48 | ASSERT(module);
49 |
50 | // The INET visualizer listens to model change notifications on the
51 | // network object by default. We assume this is our parent.
52 | cModule* root = getParentModule();
53 |
54 | auto* notification = new inet::cPreModuleInitNotification();
55 | notification->module = module;
56 | root->emit(POST_MODEL_CHANGE, notification, NULL);
57 | });
58 | #endif
59 | }
60 |
61 | void VeinsInetManager::preInitializeModule(cModule* mod, const std::string& nodeId, const Coord& position, const std::string& road_id, double speed, Heading heading, VehicleSignalSet signals)
62 | {
63 | // pre-initialize VeinsInetMobility
64 | auto mobilityModules = getSubmodulesOfType(mod);
65 | for (auto inetmm : mobilityModules) {
66 | inetmm->preInitialize(nodeId, inet::Coord(position.x, position.y), road_id, speed, heading.getRad());
67 | }
68 | }
69 |
70 | void VeinsInetManager::updateModulePosition(cModule* mod, const Coord& p, const std::string& edge, double speed, Heading heading, VehicleSignalSet signals)
71 | {
72 | // update position in VeinsInetMobility
73 | auto mobilityModules = getSubmodulesOfType(mod);
74 | for (auto inetmm : mobilityModules) {
75 | inetmm->nextPosition(inet::Coord(p.x, p.y), edge, speed, heading.getRad());
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/veins_inet/VeinsInetManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2006-2017 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 |
23 | #pragma once
24 |
25 | #include "veins_inet/veins_inet.h"
26 |
27 | #include "veins/modules/mobility/traci/TraCIScenarioManagerLaunchd.h"
28 | #include "veins/modules/utility/SignalManager.h"
29 |
30 | namespace veins {
31 |
32 | /**
33 | * @brief
34 | * Creates and manages network nodes corresponding to cars.
35 | *
36 | * See the Veins website for a tutorial, documentation, and publications .
37 | *
38 | * @author Christoph Sommer
39 | *
40 | */
41 | class VEINS_INET_API VeinsInetManager : public veins::TraCIScenarioManagerLaunchd {
42 | public:
43 | virtual ~VeinsInetManager();
44 |
45 | void initialize(int stage) override;
46 |
47 | virtual void preInitializeModule(cModule* mod, const std::string& nodeId, const Coord& position, const std::string& road_id, double speed, Heading heading, VehicleSignalSet signals) override;
48 | virtual void updateModulePosition(cModule* mod, const Coord& p, const std::string& edge, double speed, Heading heading, VehicleSignalSet signals) override;
49 |
50 | protected:
51 | SignalManager signalManager;
52 | };
53 |
54 | class VEINS_INET_API VeinsInetManagerAccess {
55 | public:
56 | VeinsInetManager* get()
57 | {
58 | return FindModule::findGlobalModule();
59 | };
60 | };
61 |
62 | } // namespace veins
63 |
--------------------------------------------------------------------------------
/src/veins_inet/VeinsInetManager.ned:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2006-2017 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 |
23 | package vanettutorials.veins_inet;
24 |
25 | import org.car2x.veins.modules.mobility.traci.TraCIScenarioManagerLaunchd;
26 |
27 |
28 | //
29 | // Creates and manages network nodes corresponding to cars.
30 | //
31 | // See the Veins website for a tutorial, documentation, and publications .
32 | //
33 | // @author Christoph Sommer
34 | //
35 | simple VeinsInetManager extends TraCIScenarioManagerLaunchd
36 | {
37 | parameters:
38 | @class(veins::VeinsInetManager);
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/src/veins_inet/VeinsInetMobility.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2006-2018 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 |
23 | //
24 | // Veins Mobility module for the INET Framework
25 | // Based on inet::MovingMobilityBase of INET Framework v4.0.0
26 | //
27 |
28 | #include "veins_inet/VeinsInetMobility.h"
29 |
30 | #include "inet/common/INETMath.h"
31 | #include "inet/common/Units.h"
32 | #include "inet/common/geometry/common/GeographicCoordinateSystem.h"
33 |
34 | namespace veins {
35 |
36 | using namespace inet::units::values;
37 |
38 | Register_Class(VeinsInetMobility);
39 |
40 | VeinsInetMobility::VeinsInetMobility()
41 | {
42 | }
43 |
44 | VeinsInetMobility::~VeinsInetMobility()
45 | {
46 | delete vehicleCommandInterface;
47 | }
48 |
49 | void VeinsInetMobility::preInitialize(std::string external_id, const inet::Coord& position, std::string road_id, double speed, double angle)
50 | {
51 | Enter_Method_Silent();
52 | this->external_id = external_id;
53 | lastPosition = position;
54 | lastVelocity = inet::Coord(cos(angle), -sin(angle)) * speed;
55 | lastOrientation = inet::Quaternion(inet::EulerAngles(rad(-angle), rad(0.0), rad(0.0)));
56 | }
57 |
58 | void VeinsInetMobility::initialize(int stage)
59 | {
60 | MobilityBase::initialize(stage);
61 |
62 | // We patch the OMNeT++ Display String to set the initial position. Make sure this works.
63 | ASSERT(hasPar("initFromDisplayString") && par("initFromDisplayString"));
64 | }
65 |
66 | void VeinsInetMobility::nextPosition(const inet::Coord& position, std::string road_id, double speed, double angle)
67 | {
68 | Enter_Method_Silent();
69 |
70 | lastPosition = position;
71 | lastVelocity = inet::Coord(cos(angle), -sin(angle)) * speed;
72 | lastOrientation = inet::Quaternion(inet::EulerAngles(rad(-angle), rad(0.0), rad(0.0)));
73 |
74 | // Update display string to show node is getting updates
75 | auto hostMod = getParentModule();
76 | if (std::string(hostMod->getDisplayString().getTagArg("veins", 0)) == ". ") {
77 | hostMod->getDisplayString().setTagArg("veins", 0, " .");
78 | }
79 | else {
80 | hostMod->getDisplayString().setTagArg("veins", 0, ". ");
81 | }
82 |
83 | emitMobilityStateChangedSignal();
84 | }
85 |
86 | #if INET_VERSION >= 0x0402
87 | const inet::Coord& VeinsInetMobility::getCurrentPosition()
88 | {
89 | return lastPosition;
90 | }
91 |
92 | const inet::Coord& VeinsInetMobility::getCurrentVelocity()
93 | {
94 | return lastVelocity;
95 | }
96 |
97 | const inet::Coord& VeinsInetMobility::getCurrentAcceleration()
98 | {
99 | throw cRuntimeError("Invalid operation");
100 | }
101 |
102 | const inet::Quaternion& VeinsInetMobility::getCurrentAngularPosition()
103 | {
104 | return lastOrientation;
105 | }
106 |
107 | const inet::Quaternion& VeinsInetMobility::getCurrentAngularVelocity()
108 | {
109 | return lastAngularVelocity;
110 | }
111 |
112 | const inet::Quaternion& VeinsInetMobility::getCurrentAngularAcceleration()
113 | {
114 | throw cRuntimeError("Invalid operation");
115 | }
116 | #else
117 |
118 | inet::Coord VeinsInetMobility::getCurrentPosition()
119 | {
120 | return lastPosition;
121 | }
122 |
123 | inet::Coord VeinsInetMobility::getCurrentVelocity()
124 | {
125 | return lastVelocity;
126 | }
127 |
128 | inet::Coord VeinsInetMobility::getCurrentAcceleration()
129 | {
130 | throw cRuntimeError("Invalid operation");
131 | }
132 |
133 | inet::Quaternion VeinsInetMobility::getCurrentAngularPosition()
134 | {
135 | return lastOrientation;
136 | }
137 |
138 | inet::Quaternion VeinsInetMobility::getCurrentAngularVelocity()
139 | {
140 | return lastAngularVelocity;
141 | }
142 |
143 | inet::Quaternion VeinsInetMobility::getCurrentAngularAcceleration()
144 | {
145 | throw cRuntimeError("Invalid operation");
146 | }
147 | #endif
148 | void VeinsInetMobility::setInitialPosition()
149 | {
150 | subjectModule->getDisplayString().setTagArg("p", 0, lastPosition.x);
151 | subjectModule->getDisplayString().setTagArg("p", 1, lastPosition.y);
152 | MobilityBase::setInitialPosition();
153 | }
154 |
155 | void VeinsInetMobility::handleSelfMessage(cMessage* message)
156 | {
157 | }
158 |
159 | std::string VeinsInetMobility::getExternalId() const
160 | {
161 | if (external_id == "") throw cRuntimeError("TraCIMobility::getExternalId called with no external_id set yet");
162 | return external_id;
163 | }
164 |
165 | TraCIScenarioManager* VeinsInetMobility::getManager() const
166 | {
167 | if (!manager) manager = TraCIScenarioManagerAccess().get();
168 | return manager;
169 | }
170 |
171 | TraCICommandInterface* VeinsInetMobility::getCommandInterface() const
172 | {
173 | if (!commandInterface) commandInterface = getManager()->getCommandInterface();
174 | return commandInterface;
175 | }
176 |
177 | TraCICommandInterface::Vehicle* VeinsInetMobility::getVehicleCommandInterface() const
178 | {
179 | if (!vehicleCommandInterface) vehicleCommandInterface = new TraCICommandInterface::Vehicle(getCommandInterface()->vehicle(getExternalId()));
180 | return vehicleCommandInterface;
181 | }
182 |
183 | } // namespace veins
184 |
--------------------------------------------------------------------------------
/src/veins_inet/VeinsInetMobility.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2006-2018 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 |
23 | //
24 | // Veins Mobility module for the INET Framework
25 | // Based on inet::MovingMobilityBase of INET Framework v4.0.0
26 | //
27 |
28 | #pragma once
29 |
30 | namespace omnetpp {
31 | }
32 | using namespace omnetpp;
33 |
34 | #include "inet/mobility/base/MobilityBase.h"
35 |
36 | #include "veins_inet/veins_inet.h"
37 |
38 | #include "veins/modules/mobility/traci/TraCIScenarioManager.h"
39 | #include "veins/modules/mobility/traci/TraCICommandInterface.h"
40 |
41 | namespace veins {
42 |
43 | class VEINS_INET_API VeinsInetMobility : public inet::MobilityBase {
44 | public:
45 | VeinsInetMobility();
46 |
47 | virtual ~VeinsInetMobility();
48 |
49 | /** @brief called by class VeinsInetManager */
50 | virtual void preInitialize(std::string external_id, const inet::Coord& position, std::string road_id, double speed, double angle);
51 |
52 | virtual void initialize(int stage) override;
53 |
54 | /** @brief called by class VeinsInetManager */
55 | virtual void nextPosition(const inet::Coord& position, std::string road_id, double speed, double angle);
56 |
57 | #if INET_VERSION >= 0x0402
58 | virtual const inet::Coord& getCurrentPosition() override;
59 | virtual const inet::Coord& getCurrentVelocity() override;
60 | virtual const inet::Coord& getCurrentAcceleration() override;
61 |
62 | virtual const inet::Quaternion& getCurrentAngularPosition() override;
63 | virtual const inet::Quaternion& getCurrentAngularVelocity() override;
64 | virtual const inet::Quaternion& getCurrentAngularAcceleration() override;
65 | #else
66 | virtual inet::Coord getCurrentPosition() override;
67 | virtual inet::Coord getCurrentVelocity() override;
68 | virtual inet::Coord getCurrentAcceleration() override;
69 |
70 | virtual inet::Quaternion getCurrentAngularPosition() override;
71 | virtual inet::Quaternion getCurrentAngularVelocity() override;
72 | virtual inet::Quaternion getCurrentAngularAcceleration() override;
73 | #endif
74 |
75 | virtual std::string getExternalId() const;
76 | virtual TraCIScenarioManager* getManager() const;
77 | virtual TraCICommandInterface* getCommandInterface() const;
78 | virtual TraCICommandInterface::Vehicle* getVehicleCommandInterface() const;
79 |
80 | protected:
81 | /** @brief The last velocity that was set by nextPosition(). */
82 | inet::Coord lastVelocity;
83 |
84 | /** @brief The last angular velocity that was set by nextPosition(). */
85 | inet::Quaternion lastAngularVelocity;
86 |
87 | mutable TraCIScenarioManager* manager = nullptr; /**< cached value */
88 | mutable TraCICommandInterface* commandInterface = nullptr; /**< cached value */
89 | mutable TraCICommandInterface::Vehicle* vehicleCommandInterface = nullptr; /**< cached value */
90 |
91 | std::string external_id; /**< identifier used by TraCI server to refer to this node */
92 |
93 | protected:
94 | virtual void setInitialPosition() override;
95 |
96 | virtual void handleSelfMessage(cMessage* message) override;
97 | };
98 |
99 | } // namespace veins
100 |
101 | namespace veins {
102 | class VEINS_INET_API VeinsInetMobilityAccess {
103 | public:
104 | VeinsInetMobility* get(cModule* host)
105 | {
106 | VeinsInetMobility* m = FindModule::findSubModule(host);
107 | ASSERT(m);
108 | return m;
109 | };
110 | };
111 | } // namespace veins
112 |
--------------------------------------------------------------------------------
/src/veins_inet/VeinsInetMobility.ned:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2006-2017 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 |
23 | //
24 | // Veins Mobility module for the INET Framework
25 | // Based on inet::MovingMobilityBase of INET Framework v4.0.0
26 | //
27 |
28 | package vanettutorials.veins_inet;
29 |
30 | import inet.mobility.base.MobilityBase;
31 |
32 | simple VeinsInetMobility extends MobilityBase
33 | {
34 | parameters:
35 | @class(veins::VeinsInetMobility);
36 | @display("i=block/cogwheel");
37 | @signal[mobilityStateChanged](type=inet::MobilityBase);
38 | bool initFromDisplayString = default(true); // do not change this to false
39 | }
40 |
--------------------------------------------------------------------------------
/src/veins_inet/VeinsInetRoutingCar.ned:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2006-2017 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 |
23 | package vanettutorials.veins_inet;
24 |
25 | import inet.networklayer.configurator.ipv4.HostAutoConfigurator;
26 | import inet.node.inet.AdhocHost;
27 | import inet.applications.contract.IApp;
28 |
29 | //
30 | // Wireless-enabled Host
31 | //
32 | module VeinsInetRoutingCar extends AdhocHost
33 | {
34 | parameters:
35 | @display("i=device/cellphone");
36 | string router;
37 | submodules:
38 | routing: like IApp {
39 | @display("p=558,307");
40 | }
41 | connections allowunconnected:
42 | routing.socketOut --> at.in++;
43 | routing.socketIn <-- at.out++;
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/src/veins_inet/VeinsInetSampleApplication.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2018 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 |
23 | #include "veins_inet/VeinsInetSampleApplication.h"
24 |
25 | #include "inet/common/ModuleAccess.h"
26 | #include "inet/common/packet/Packet.h"
27 | #include "inet/common/TagBase_m.h"
28 | #include "inet/common/TimeTag_m.h"
29 | #include "inet/networklayer/common/L3AddressResolver.h"
30 | #include "inet/networklayer/common/L3AddressTag_m.h"
31 | #include "inet/transportlayer/contract/udp/UdpControlInfo_m.h"
32 |
33 | #include "veins_inet/VeinsInetSampleMessage_m.h"
34 |
35 | using namespace inet;
36 |
37 | Define_Module(VeinsInetSampleApplication);
38 |
39 | VeinsInetSampleApplication::VeinsInetSampleApplication()
40 | {
41 | }
42 |
43 | bool VeinsInetSampleApplication::startApplication()
44 | {
45 | // host[0] should stop at t=20s
46 | if (getParentModule()->getIndex() == 0) {
47 | auto callback = [this]() {
48 | getParentModule()->getDisplayString().setTagArg("i", 1, "red");
49 |
50 | traciVehicle->setSpeed(0);
51 |
52 | auto payload = makeShared();
53 | timestampPayload(payload);
54 | payload->setChunkLength(B(100));
55 | payload->setRoadId(traciVehicle->getRoadId().c_str());
56 |
57 | auto packet = createPacket("accident");
58 | packet->insertAtBack(payload);
59 | sendPacket(std::move(packet));
60 | };
61 | timerManager.create(veins::TimerSpecification(callback).oneshotAt(SimTime(20, SIMTIME_S)));
62 | }
63 |
64 | return true;
65 | }
66 |
67 | bool VeinsInetSampleApplication::stopApplication()
68 | {
69 | return true;
70 | }
71 |
72 | VeinsInetSampleApplication::~VeinsInetSampleApplication()
73 | {
74 | }
75 |
76 | void VeinsInetSampleApplication::processPacket(std::shared_ptr pk)
77 | {
78 | auto payload = pk->peekAtFront();
79 |
80 | EV_INFO << "Received packet: " << payload << endl;
81 |
82 | getParentModule()->getDisplayString().setTagArg("i", 1, "green");
83 |
84 | traciVehicle->changeRoute(payload->getRoadId(), 999.9);
85 |
86 | if (haveForwarded) return;
87 |
88 | auto packet = createPacket("relay");
89 | packet->insertAtBack(payload);
90 | sendPacket(std::move(packet));
91 |
92 | haveForwarded = true;
93 | }
94 |
--------------------------------------------------------------------------------
/src/veins_inet/VeinsInetSampleApplication.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2018 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 |
23 | #pragma once
24 |
25 | #include "veins_inet/veins_inet.h"
26 |
27 | #include "veins_inet/VeinsInetApplicationBase.h"
28 |
29 | class VEINS_INET_API VeinsInetSampleApplication : public veins::VeinsInetApplicationBase {
30 | protected:
31 | bool haveForwarded = false;
32 |
33 | protected:
34 | virtual bool startApplication() override;
35 | virtual bool stopApplication() override;
36 | virtual void processPacket(std::shared_ptr pk) override;
37 |
38 | public:
39 | VeinsInetSampleApplication();
40 | ~VeinsInetSampleApplication();
41 | };
42 |
--------------------------------------------------------------------------------
/src/veins_inet/VeinsInetSampleApplication.ned:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2018 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 |
23 | package vanettutorials.veins_inet;
24 |
25 | import vanettutorials.veins_inet.VeinsInetApplicationBase;
26 |
27 | simple VeinsInetSampleApplication extends VeinsInetApplicationBase
28 | {
29 | parameters:
30 | @class(VeinsInetSampleApplication);
31 | gates:
32 | }
33 |
--------------------------------------------------------------------------------
/src/veins_inet/VeinsInetSampleMessage.msg:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2018 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 |
23 | //
24 | // This .msg definition file requires opp_msgc of OMNeT++ 5.3 or newer with the --msg6 option set (e.g., via a makefrag file)
25 | //
26 |
27 | import inet.common.INETDefs;
28 | import inet.common.packet.chunk.Chunk;
29 |
30 | //
31 | // Example message definition
32 | //
33 | class VeinsInetSampleMessage extends inet::FieldsChunk
34 | {
35 | string roadId;
36 | }
37 |
--------------------------------------------------------------------------------
/src/veins_inet/package.ned:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2018 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 |
23 | package vanettutorials.veins_inet;
24 |
--------------------------------------------------------------------------------
/src/veins_inet/veins_inet.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019 Christoph Sommer
3 | //
4 | // Documentation for these modules is at http://veins.car2x.org/
5 | //
6 | // SPDX-License-Identifier: GPL-2.0-or-later
7 | //
8 | // This program is free software; you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation; either version 2 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | //
22 |
23 | #pragma once
24 |
25 | #include "veins/veins.h"
26 |
27 | // Version number of last release ("major.minor.patch") or an alpha version, if nonzero
28 | #define VEINS_INET_VERSION_MAJOR 4
29 | #define VEINS_INET_VERSION_MINOR 0
30 | #define VEINS_INET_VERSION_PATCH 0
31 | #define VEINS_INET_VERSION_ALPHA 0
32 |
33 | // Explicitly check Veins version number
34 | #if !(VEINS_VERSION_MAJOR == 5 && VEINS_VERSION_MINOR >= 0)
35 | #error Veins version 5.0 or compatible required
36 | #endif
37 |
38 | // VEINS_INET_API macro. Allows us to use the same .h files for both building a .dll and linking against it
39 | #if defined(VEINS_INET_EXPORT)
40 | #define VEINS_INET_API OPP_DLLEXPORT
41 | #elif defined(VEINS_INET_IMPORT)
42 | #define VEINS_INET_API OPP_DLLIMPORT
43 | #else
44 | #define VEINS_INET_API
45 | #endif
46 |
--------------------------------------------------------------------------------