How to Start UAS Based VANET Projects Using NS2

To create a UAS (Unmanned Aerial System) based VANET (Vehicular Ad Hoc Network) project using Network Simulator 2 (NS2) has includes the replicate of network in which the drones (UAS) and vehicles communicate by every other using VANET protocols. This protocol is ensuring the vehicles for modify the data about traffic, road conditions, and other factors that are vital for effective transportation and safety.

Steps to Start UAS Based VANET Projects Using NS2

Step 1: Understand the Concepts of UAS and VANET

Previously we dive into NS2, it’s essential to understand the simple of UAS-based VANETs:

  • VANET (Vehicular Ad Hoc Network): A network in that vehicles and road infrastructure such as traffic lights, roadside units communicate wirelessly to transfer the data. It typically uses DSRC (Dedicated Short Range Communications), Wi-Fi, or LTE technologies.
  • UAS (Unmanned Aerial System): Drones or UAVs (Unmanned Aerial Vehicles) can be amount of the network, support by aerial data collection, tracking, or improving communication among the ground vehicles.

In UAS-based VANETs, UAVs can be used for:

  • It offers the connectivity to remote range or beyond line-of-sight.
  • Perform as relays or mobile base stations to encompass the network range.
  • Improve the data collection for traffic tracking or environmental sensing.

Step 2: Install NS2

Assure we have the NS2 installed on the system. If not, we can follow the installation guide for Linux, Windows (via Cygwin), or macOS.

Validate the installation by typing:

ns

Step 3: Define the UAS-based VANET Topology

Intended for the replication we require describing the topology that includes:

  • Vehicles: These nodes are transfer on the road.
  • UAVs (UAS): This will perform an aerial nodes in the VANET, either fixed or tranfer for offers the connectivity.
  • Roadside Units (RSUs): These are stable units placed on the roadside to facilitate communication by vehicles and UAVs.
  • Links: Communication connection among the UAVs, vehicles, and RSUs.

In VANETs, nodes (vehicles and UAVs) often have mobility patterns defined by mobility models.

Step 4: Create Your Simulation Scenario in NS2

We will replicate the UAVs and vehicles communicating by every other using VANET protocols. The following procedures express on how the build a basic UAS-based VANET project in NS2.

Example of a Simple UAS-based VANET Simulation in NS2:

# Create the simulator object

set ns [new Simulator]

# Create nodes for UAV (drone), vehicles, and RSU

set uav_node [$ns node]         ;# UAV node (drone)

set vehicle1 [$ns node]         ;# Vehicle 1

set vehicle2 [$ns node]         ;# Vehicle 2

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

# Set the mobility model for the UAV (drone)

# UAV can move freely in a 3D space, for simplicity, we use a 2D model here

$ns node-config -motion “random” -speed 10 -x 500 -y 500 -z 100

# Set the mobility model for vehicles

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

# Create links between the UAV, vehicles, and RSU

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

$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 $vehicle1 $vehicle2 1Mb 50ms DropTail    ;# Vehicle to Vehicle communication

# Set up the communication protocols

# UAV will act as a relay or data collector for the vehicles

set udp_uav [new Agent/UDP]

set null_uav [new Agent/Null]

$ns attach-agent $uav_node $udp_uav

$ns attach-agent $rsu_node $null_uav

$ns connect $udp_uav $null_uav

# Vehicle communication setup (using CBR traffic)

set udp_vehicle1 [new Agent/UDP]

set null_vehicle1 [new Agent/Null]

$ns attach-agent $vehicle1 $udp_vehicle1

$ns attach-agent $rsu_node $null_vehicle1

$ns connect $udp_vehicle1 $null_vehicle1

 

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 traffic at time 1s

$ns at 4.0 “$cbr_vehicle1 stop”    ;# Stop traffic 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]: Builds a NS2 simulator object.
  2. Node Creation:
    • set uav_node [$ns node]: Describes the UAV node (drone).
    • set vehicle1, set vehicle2, and set rsu_node: Describe the vehicle and RSU nodes.
  3. Mobility Model:
    • The UAV is configuring to transfer the 3D space such as though simplified to 2D for this example.
    • Vehicles have arbitrary mobility defined in the 2D space by a speed of 20 m/s.
  4. Link Setup:
    • duplex-link: Generates a bidirectional communication connection among the nodes, e.g., UAV to RSU and vehicles to RSU.
  5. Communication Setup:
    • UDP agents are used for communication among the UAV, vehicles, and RSU.
    • A CBR (Constant Bit Rate) application creates a continuous traffic among vehicles and RSU.
  6. Traffic Generation:
    • A CBR application is involved the UDP agent on Vehicle 1 to replicate the data transmission.
  7. Simulation Events:
    • $ns at 1.0 “$cbr_vehicle1 start”: The CBR traffic starts at 1 second.
    • $ns at 4.0 “$cbr_vehicle1 stop”: The CBR traffic stops at 4 seconds.
  8. Finish Procedure:
    • finish: Flushing the trace file and previous replication.

Step 5: Run and Analyze the Simulation

  1. Store the script to a .tcl file (e.g., uas_vanet_simulation.tcl).
  2. Process for the replication:

ns uas_vanet_simulation.tcl

Step 6: Analyze the Results

Next process for the replication, NS2 will creates a trace file (*.tr) by data about packet transmission, reception, and delays.

We can use tools such as AWK or Xgraph to analyze the outcomes:

  1. AWK to filter specific movements:

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

  1. Xgraph to envision the traffic:

xgraph tracefile.tr

Step 7: Experiment with More Complex Scenarios

After we have the simple setting, we can research through further complex environment:

  • VANET Routing Protocols: Replicate the protocols such as AODV Ad hoc On-demand Distance Vector or DSR Dynamic Source Routing for routing among UAVs and vehicles.
  • Vehicle-to-Vehicle Communication (V2V): Ensure the direct communication among vehicles without involving RSUs or UAVs.
  • UAV Relay: Use the UAVs as relays to encompass the network range among the vehicles and RSUs.
  • Traffic Management Applications: Replicate the VANET-based traffic management and coordination techniques.
  • Security in VANET: Research by attacks such as DoS, MitM and execute the security protocols for VANETs.

Step 8: Documentation and Reporting

Document the replication setting, including:

  • Topology Diagram: View on how the vehicles, UAVs, and RSUs are connected.
  • Communication Models: Define the protocols used for communication for instance UDP, CBR.
  • Simulation Results: Examine the performance in according to throughput, delay, and packet loss.
  • Use Cases: Deliberate the potential applications of UAS-based VANETs for sample real-time traffic management, remote sensing.

Step 9: Further Improvements

  • Integration with Other Tools: NS2 is mostly concentrate on networking; for further advanced UAV replication such as flight path, altitude, we can incorporate the NS2 through UAV replicators such as AirSim or Gazebo.
  • Cross-layer Simulation: Replicate the several layers of communication, including application, network, and physical layers, for further realistic replication.

By following these steps, you can start a UAS-based VANET project in NS2 and simulate communication between UAVs and vehicles in an intelligent transportation system.

In the whole, we clearly discussed about how the UAS-BASED VANET link network can interact directly with each other vehicle in wireless technology using the ns2 framework. We provide and support elaborated information regarding the UAS-BASED VANET.