Hi everybody, welcome back to another VANET tutorial. In this video, we're going
to learn how to use INET and Veins together
to simulate a V2V network. Thankfully, Veins
has a subproject already created called veins_inet and we're going to be using
this. So here is my workspace. I have INET, my VANET
tutorials project, and Veins, and they're all in it. My VANET
tutorials repo is available on github and there's a link in the description
below to the repository. So let's expand
VANETTutorials under the source folder I have the
veins_inet folder and this is the veins_inet source code
you don't need to do this you can import the veins_inet sub project but this is
my preferred way with veins_inet because as you're
simulating vanet environments you may find yourself
modifying this code just so you know that if you
opened up veins under subprojects there
is the veins inet this works with 4.0 and then veins_inet3 works with
inet 3. The veins_inet sub project as you can see is included in veins and
it allows for us to use veins as a mobility module
in either inet 3 or inet4 and the version that we're working with
is inet 4. So the veins_inet project helps us
use the full feature set of the inet framework in a
vein simulation. With this we can access full ipv4
ipv6 stacks, wired networking, mobile ad hoc
network protocols, bit-precise PCAP traces,
or network emulation. So using veins_inet we can also model libraries
based on the INET framework, which is really useful.
And so now that we could use things like SimuLTE
which is a 4G simulation. So this is the veins_inet subproject
I've also put in my simulations the veins_inet example simulation
this example illustrates how veins_inet is used
so let's look at this network so if we go into the scenario
you can see that we have our radio medium set up
we have a manager which is using the veins inet manager and then we have
nodes which are the veins inet car if we inspect the veins inet car
you can see that it extends ad hoc host so these nodes represent our
cars and they actually inherit the standard inet
wireless host and they'll use a regular inet
network card so each car uses a mobility module
of the type veins inet mobility this is set in the omnetpp.ini file
so here you can see that the vein's inet mobility
it's accessing the node setting the mobility type
to veins inet mobility which is defined in our source so veins inet mobility
this is the ned file for the veins inet ability and
the code for the mobility is available right here
the veins inet mobility ends up implement implements the inet mobility
base and it also accesses the traci
scenario manager which is how veins normally works so this is our
tie-in from veins to inet
last but not least you can see that there is a manager this is a global
module veins inet manager and it creates and
manages cars in our simulation so let's go back to
our omnetpp.ini file. So this is the general
configurations for the veins_inet example simulation
it sets the network to scenario it sets up the
sim time limit to be 60 seconds it has some other settings for debugging on
errors and the image path the important part is our udp basic app
so the node inherits our wireless host so in this case it is setting up our udp
app to be using the veins inet sample application we're going to look
at the code for this in a minute but let's finish looking
through the settings on our ini file it sets the interface to
a wireless lan and with that setup it sets up the wireless lane interface the
operation mode the radio band the bandwidth
all that information as well this is the host auto configurator in order
to configure a network stack for our cars
entering a simulation an additional host auto configurator
model needs to be included with each car this is very similar to how when the
dynamic version of aodv is simulated it has to
have its own auto configurator this is
setting the veins inet mobility which you pointed
out before and these are the settings for the inet
manager so this will do the update interval the location the local host
connection the host connection to the sumo
environment the port that is connecting to so when
you run this simulation you need to be sure that
you're also starting up sumo all right so now let's
look into the veins inet sample application
so the veins inet sample application has the
ned file which just registers the class veins inet sample application so this
is the header file the header file extends the
veins inet application base inside the c++ file the start
application checks if the node is
the first node so host zero and just sets the display to be
red and then sets the speed to b0 to stop it so this is actually how it
accesses the vehicle to stop it and then that host
will create a veins inet sample map message with the size of a hundred bytes
it sets the road id and then creates a packet called
accident and then sends that packet along
it calls the send packet which is part of the veins in
application base when it receives a packet which is process packet
it colors the vehicle as green and then it'll change the route to
whatever road id was given it's just a very
simple application that shows you how you can
manipulate different items in veins and inet so the
application base extends our inet udp socket and also inet's application base
so this is doing all the udp and networking
for us so now that we've looked at all this let's
run our inapplication first we need to make sure that we're running
sumo so let's run sumo so launch the sumo launch python launch
our sumo application and now it will be listening on port
9999 which was set in our veins inet manager
right here so let's run our simulation
so this is the startup for our simulation there are no
vehicles on there we have our radio medium and
our manager and actually if you want to you can
inspect the settings for your manager and your radio medium on
the side here and you can see the different settings
that have been set up so we start running
so you can see that our vehicles are now traveling and we have node 0
node 1 node 2 slowly coming in eventually node 0 is going to stop
at 20 seconds in there he goes he stops he send out a
packet and also received the packet now is
sending the packets to the other nodes and you
can see the packet name was accident it's being
sent along our udp protocol and node one received it so it turned
green node 2 received the packet so it turned
green node 2 sends a relay to node 0 and node 1.
that was received when the packet was accepted we
created a real relay that ended up 40.
so you can watch this it will take a little a while you can speed it up to be
faster the simulation is only 60 seconds though so it ends very
quickly but now you can see how you have veins
and inet working together so now what we want to
do is extend this example
so that it will work using aodv so now let's look how to make the veins
inet example work with aodv
so this will be veins and inet working with a routing protocol which is
aodv so there is a new folder here called routing and you can get this code
on my github but we're going to walk through how it is set up
so within here i have a routing scenario this is
very much the same as the scenario earlier
the only difference is that we are using something called vanes inet routing
car now veins inet routing car is something that I created
the difference between vanes inec car and routing car
is that there is a routing sub module i expand
and go into veins inet routing car the same exact code as veins inet car except
there is a sub module called routing that takes in a parameter
called router and it's like iapp and that's
because aodv is like iapp and you can use different
interfaces as well so you can implement other
protocols it doesn't have to just be aodv
the other change is that we added some connections and that is the routing
socket out goes into the message dispatchers in
this is how we're connecting our gates together and the socket in
for routing is connected to the message dispatchers
out so this is very important because this is
how they're going to connect to each other so that we can
emulate the network this is the only changes that we have to do
for our ned files now let's go and look at the ini file
going into the omnetpp.ini file so what has been changed is instead of
using the veins inet sample application i'm
going to be using the udp basic app type
the destination address I'm going to talk to
any random node if you were doing an RSU simulation you would make an RSU
node and then you can add that node to your scenario and then here your
destination address could be an RSU then we're setting the
destination port the message length the interval and then
the packet name in this case packet name is just going to be UDPData
the rest of the configurations are the same as we did
earlier last part is routing I am setting the router to be
AODV this is going to then access the AODV sub module so now we are ready
to run our code we right click run as OMNET++
simulation so let's start our simulation and our
vehicles will start being added to the playground and they take about five
seconds each so we'll speed it up a little bit
so we have our vehicles being added and now they
are communicating back in four and if you scroll up you
can see that we send an AODV request
so this was node one sending AODV request to node 0. So now
you have AODV working with Veins and INET and you have connected
all these routing protocols together. Congratulations, you have now
learned how to make AODV work with Veins and INET in OMNET++. If you
like what you saw, please remember to subscribe to my channel so you can be
notified for more OMNET++ tutorials