How to Start Drone Based VANET Projects Using NS2

To start a Drone-based VANET (Vehicular Ad Hoc Network) project within Network Simulator 2 (NS2), we will require replicating a network in which drones (UAVs) and vehicles interact with each other. In the network, drones are often utilised for improving the network connectivity, which is function like relay nodes, or offer aerial-based interaction to the vehicles and roadside units (RSUs).

Following is a brief procedure to get started Drone-based VANET projects using NS2.

Steps to Start Drone-based VANET Projects in NS2

Step 1: Understand the Components of Drone-based VANETs

Below are key components of Drone-based VANET:

  1. Vehicles: To transfer nodes, which interact with each other and infrastructure (RSUs).
  2. Drones (UAVs): Unmanned aerial vehicles are leveraged to prolong the network coverage, transmitting communication, or observing the traffic.
  3. Roadside Units (RSUs): Fixed infrastructure nodes are positioned beside the roadways, which offer interaction points among the vehicles and the network.
  4. Communication Links: It might be wireless communication links such as Wi-Fi, DSRC, and LTE among the vehicles, drones, and RSUs.

Focus on replicate the interaction among the drones and vehicles that can utilise for tasks such as traffic monitoring, vehicle-to-vehicle (V2V) communication, and vehicle-to-infrastructure (V2I) communication.

Step 2: Install NS2

Make sure that we have installed the NS2 on the system. Unless, we can follow the installation instruction based on the operating system such as Linux, Windows via Cygwin, or macOS. When NS2 is installed then we can verify it by typing:

ns

If the installation is effectively done then it should expose the NS2 command prompt.

Step 3: Define Your Drone-based VANET Topology

We can replicate some moving vehicles and a drone, which performs like a mobile relay or base station for prolonging the interaction range for the vehicles in the context of a Drone-based VANET. The topology will normally have:

  • Vehicles: Mobile nodes which are denoting the cars or other vehicles.
  • Drones (UAVs): Mobile nodes can soar over the vehicles that performing like relays.
  • Roadside Units (RSUs): Infrastructure nodes, which vehicles can be interacted with the RSUs.
  • Communication Links: It provides wireless interaction connections among the nodes like vehicle-to-vehicle, vehicle-to-infrastructure.

Step 4: Create Your Simulation Scenario in NS2

Below is a basic example in which:

  • We need 2 vehicles, a drone (UAV), and an RSU.
  • For communication among the vehicles and RSU, drone will perform like a relay node.

Example of a Basic Drone-based VANET Simulation in NS2

# Create the simulator object

set ns [new Simulator]

# Create nodes (Vehicle 1, Vehicle 2, RSU, and UAV)

set vehicle1 [$ns node]          ;# Vehicle 1

set vehicle2 [$ns node]          ;# Vehicle 2

set rsu_node [$ns node]          ;# Roadside Unit (RSU)

set drone_node [$ns node]        ;# UAV (Drone)

# Define the mobility model for vehicles (random movement)

$ns node-config -motion “random” -speed 20 -x 500 -y 500 -z 0

# Define the mobility model for the UAV (drone) – flying in the air

$ns node-config -motion “random” -speed 15 -x 200 -y 200 -z 100   ;# Drone at height 100 meters

# Create the links between the nodes (duplex communication links)

$ns duplex-link $vehicle1 $rsu_node 1Mb 50ms DropTail    ;# Vehicle 1 to RSU

$ns duplex-link $vehicle2 $rsu_node 1Mb 50ms DropTail    ;# Vehicle 2 to RSU

$ns duplex-link $drone_node $rsu_node 1Mb 50ms DropTail   ;# UAV to RSU

$ns duplex-link $vehicle1 $drone_node 1Mb 50ms DropTail   ;# Vehicle 1 to UAV

$ns duplex-link $vehicle2 $drone_node 1Mb 50ms DropTail   ;# Vehicle 2 to UAV

# Set up communication (UDP agents for simplicity)

set udp_vehicle1 [new Agent/UDP]

set udp_vehicle2 [new Agent/UDP]

set udp_rsu [new Agent/UDP]

# Attach UDP agents to vehicles and RSU

$ns attach-agent $vehicle1 $udp_vehicle1

$ns attach-agent $vehicle2 $udp_vehicle2

$ns attach-agent $rsu_node $udp_rsu

# Create applications for vehicles to generate traffic

set cbr_vehicle1 [new Application/Traffic/CBR]

$cbr_vehicle1 attach-agent $udp_vehicle1

$cbr_vehicle1 set packetSize_ 512

$cbr_vehicle1 set interval_ 0.1

$cbr_vehicle1 set random_ 1

$ns at 1.0 “$cbr_vehicle1 start”   ;# Start CBR at time 1s

$ns at 4.0 “$cbr_vehicle1 stop”    ;# Stop CBR at time 4s

set cbr_vehicle2 [new Application/Traffic/CBR]

$cbr_vehicle2 attach-agent $udp_vehicle2

$cbr_vehicle2 set packetSize_ 512

$cbr_vehicle2 set interval_ 0.1

$cbr_vehicle2 set random_ 1

$ns at 1.0 “$cbr_vehicle2 start”   ;# Start CBR at time 1s

$ns at 4.0 “$cbr_vehicle2 stop”    ;# Stop CBR at time 4s

# Set finish time for simulation

$ns at 5.0 “finish”

# Define finish procedure

proc finish {} {

global ns

$ns flush-trace

exit 0

}

# Run the simulation

$ns run

Explanation of the Script:

  1. Simulator Setup:
    • set ns [new Simulator]: It makes the NS2 simulator entity.
  2. Node Creation:
    • set vehicle1 [$ns node]: It helps to make Vehicle 1 node.
    • set vehicle2 [$ns node]: Generates Vehicle 2 node.
    • set rsu_node [$ns node]: Provides the RSU node.
    • set drone_node [$ns node]: To make the UAV (drone) node.
  3. Mobility Model:
    • Vehicles arbitrarily transfer on a 2D plane (x and y) whereas the UAV (drone) flies on the z-axis at a height of 100 meters.
    • The speed of vehicles is fixed to 20 m/s, and the drone transfers at 15 meter per second.
  4. Link Setup:
    • duplex-link: It supports to make bidirectional links among the UAV, vehicles, and RSU. The bandwidth is configured to 1 Mbps including a 50 ms delay.
  5. Communication Setup:
    • UDP Agents: Basic UDP agents are utilised for replicating the agents’ interaction among the vehicles and RSU via the drone. The CBR (Constant Bit Rate) application makes endless traffic.
    • set cbr_vehicle1: Describes the CBR application for Vehicle 1.
    • set cbr_vehicle2: For Vehicle 2, we need to specify the CBR application.
  6. Traffic Generation:
    • To make traffic from the vehicles to the RSU including packets to be transmitted every 0.1 seconds using CBR application.
  7. Simulation Events:
    • The traffic simulation events begin at 1 second and end at 4 seconds.
  8. Finish Procedure:
    • finish: To clear the trace file and departing the simulation.

Step 5: Run the Simulation

We need to store the script like drone_vanet_simulation.tcl and then execute the simulation using below command line:

ns drone_vanet_simulation.tcl

Step 6: Analyze the Results

NS2 environment will be leveraged a trace file (*.tr), which needs to record every network events with packet transmission and reception. Envision and examine these outcomes with the support of AWK or Xgraph.

For instance, Obtain the packet reception data with AWK:

awk ‘{ if ($1 == “r”) print $0 }’ tracefile.tr > received_packets.txt

Also, we can envision network traffic to utilise Xgraph:

xgraph tracefile.tr

Step 7: Experiment with Advanced Scenarios

After the basic configuration is executed then we will test with more complex simulation scenarios:

  • Routing Protocols: Replicate the VANET routing protocols such as AODV or DSR for handling the vehicle-to-vehicle (V2V) and vehicle-to-infrastructure (V2I) interaction.
  • Mobility Models: Make use of diverse mobility patterns as VanetMobiSim for more realistic vehicle movement or we can utilise Random Waypoint Model.
  • Security: In VANETs, execute the security protocols and replicate the attacks like Man-in-the-Middle (MitM) or Denial-of-Service (DoS).
  • Vehicle-to-Vehicle Communication: We need to allow direct interaction among the vehicles devoid of connecting the RSU or UAV.

Step 8: Documentation and Reporting

It provides detailed project reports or documentations like:

  • Topology Diagram: Indicate how the UAV, vehicles, and RSU are associated.
  • Communication Models: Define the traffic protocols are utilised like UDP, CBR.
  • Simulation Results: Examine the simulation performance parameters such as throughput, delay, packet loss.
  • Use Cases: It is frequently utilised in real-time traffic monitoring, intelligent transportation, or UAV-assisted interaction.

Step 9: Further Improvements

  • Integration with UAV Simulators: Replicating more realistic behavior of UAV then we need to combine the NS2 including UAV simulators such as AirSim or Gazebo.
  • Cross-Layer Simulation: Replicate physical and network layers for realistic interaction performance in cross-layer.
  • Multi-UAV Support: Mimic scenarios including numerous drones that offering coverage to vehicles and RSUs.

This demonstration includes an in-depth methodology for creating and simulating the Drone-based VANET projects using NS2, which supports to design and examine the effect of drones on vehicular networks for diverse transportation and communication applications, with the option to delve deeper into specifies if required.