How to Simulate Vehicular NDN Projects Using NS2

To simulate Vehicular Named Data Networking (NDN) projects using NS2 has needs to design both the vehicular environment and the NDN communication model. NS2 doesn’t have built-in support for NDN; however we can expand its capabilities by establishing NDN-like communication ideas such as Interest and Data packets, caching, and forwarding into simulation. Preferably, ndnSIM, which is an NDN extension for NS3, is better appropriate for NDN-based simulations, nevertheless with some customizations; we can simulate NDN concepts in NS2.

Below is a step-by-step guide on how to simulate Vehicular NDN projects in NS2

Steps to Simulate Vehicular NDN Projects Using NS2

  1. Install NS2:

Make sure that NS2 is installed and processing on system. We can download it from the NS2 official site.

  1. Define the Vehicular Network Topology:

In a Vehicular NDN, nodes denote vehicles equipped with communication capabilities, and data is routed in the form of Interest and Data packets (similar to NDN). We need to generate wireless nodes for vehicles and describe the communication topology among them.

Example of defining a basic vehicular network:

set ns [new Simulator]

# Define vehicular nodes (vehicles equipped with NDN communication capabilities)

set vehicle1 [$ns node]

set vehicle2 [$ns node]

set vehicle3 [$ns node]

# Set up communication between the vehicles

$ns node-config -adhocRouting DSDV -llType LL -macType Mac/802_11 -ifqType Queue/DropTail/PriQueue \

-ifqLen 50 -antType Antenna/OmniAntenna -propType Propagation/TwoRayGround \

-phyType Phy/WirelessPhy -channelType Channel/WirelessChannel

  1. Simulate Vehicular Mobility:

While this is a vehicular network, mobility plays an important role. We can describe random or trace-based mobility models to replicate vehicles moving in a city or highway environment.

Example of defining random waypoint mobility for vehicles:

# Generate random waypoint mobility for vehicles

setdest -n 3 -p 0.0 -s 20 -t 100 -x 1000 -y 1000 > mobility.tcl

source mobility.tcl

We can also utilize realistic mobility traces, like those created by SUMO (Simulation of Urban Mobility), to design realistic vehicle movement in the simulation.

  1. Simulate NDN Packets (Interest and Data):

In NDN, nodes (vehicles in this case) interchange Interest packets to request data and Data packets to fulfil those requests. We can replicate these packets by adapting NS2 packet structures and using UDP or TCP for packet transmission.

Example of simulating NDN-like packet structures:

# Define Interest and Data packets as custom packet types (simulated using UDP agents)

set interestPkt [new Agent/UDP]

set dataPkt [new Agent/UDP]

# Attach agents to vehicles to simulate Interest and Data packet transmission

$ns attach-agent $vehicle1 $interestPkt

$ns attach-agent $vehicle2 $dataPkt

In this case, the Interest packet is denoted as a UDP packet sent from one vehicle to another, and the Data packet is a response to that Interest.

  1. Implement NDN Forwarding and Caching:

NDN nodes cache data to meet the upcoming requests locally. To replicate this, we can execute simple forwarding and caching logic within the nodes (vehicles) using Tcl or by expanding NS2 with C++ code.

Example of simulating NDN forwarding and caching:

Class NDNVehicle {

variable CS   ;# Content Store (cache for Data)

variable PIT  ;# Pending Interest Table

# Function to handle incoming Interest packets

procedure handleInterest {interest} {

if {[$this cacheContains $interest]} {

puts “Data found in cache, sending Data packet”

$this sendDataPacket

} else {

puts “Forwarding Interest to other nodes”

$this forwardInterest $interest

}

}

# Function to cache Data packets

procedure cacheData {data} {

lappend CS $data

}

# Helper function to check if content is in cache

procedure cacheContains {interest} {

return [lsearch -exact $CS $interest]

}

}

# Create vehicle objects with NDN capabilities

set vehicleNDN1 [new NDNVehicle]

set vehicleNDN2 [new NDNVehicle]

# Attach these NDN objects to NS2 nodes (vehicles)

$vehicleNDN1 attach-agent $vehicle1

$vehicleNDN2 attach-agent $vehicle2

This simple implementation validates if a vehicle has the requested data in its cache. If so, it responds with a Data packet; otherwise, it forwards the Interest to neighbouring nodes.

  1. Generate Traffic (Interest and Data Flow):

In a vehicular NDN, vehicles create Interest packets to request data (like maps, traffic information, or entertainment), and other vehicles respond with Data packets. We can replicate these flows by configured traffic models.

Example of generating Interest packets and receiving Data packets:

# Simulate Interest packet flow from vehicle1 to vehicle2

set udp1 [new Agent/UDP]

set sink1 [new Agent/Null]

$ns attach-agent $vehicle1 $udp1

$ns attach-agent $vehicle2 $sink1

$ns connect $udp1 $sink1

set cbr1 [new Application/Traffic/CBR]

$cbr1 set packetSize_ 512

$cbr1 set interval_ 1.0   ;# Interest packets generated every second

$cbr1 attach-agent $udp1

# Simulate Data packet flow from vehicle2 to vehicle1

set udp2 [new Agent/UDP]

set sink2 [new Agent/Null]

$ns attach-agent $vehicle2 $udp2

$ns attach-agent $vehicle1 $sink2

$ns connect $udp2 $sink2

set cbr2 [new Application/Traffic/CBR]

$cbr2 set packetSize_ 1024   ;# Larger Data packet

$cbr2 set interval_ 2.0

$cbr2 attach-agent $udp2

  1. Simulate NDN Data Propagation and Caching Efficiency:

Evaluate on how efficiently data propagates via the vehicular NDN and measure the benefits of caching at the vehicles (content store). We can track on how usual vehicles retrieve data from their cache rather than requesting it from other vehicles.

  1. Run the Simulation:

Once everything is configured, we can execute the simulation to measure the network’s performance and track on how the vehicles (nodes) exchange Interest and Data packets.

Example of running the simulation:

ns vehicular_ndn_simulation.tcl

We can utilize NAM (Network Animator) to envision the vehicular network and track on how Interest and Data packets move among vehicles:

nam vehicular_ndn_simulation.nam

  1. Analyse the Results:

After the simulation is done, we can evaluate the create trace file (*.tr) to measure parameters like:

  • Cache Hit Rate: How usual the vehicles retrieve content from their cache.
  • Data Delivery Latency: Assess the time taken for Interest packets to be satisfied by Data packets.
  • Packet Delivery Ratio (PDR): Evaluate the percentage of successfully delivered packets.
  • Bandwidth Utilization: measure on how efficiently bandwidth is utilized by NDN traffic in the vehicular network.

Utilize tools such as AWK or Python to parse the trace file and extract parameters.

  1. Advanced Features (Optional):
  • Dynamic Caching Strategies: Execute advanced caching approaches such as least-recently-used or probabilistic caching in the vehicles to enhance performance.
  • Vehicular Mobility Models: Utilize more realistic mobility models like those created by SUMO to replicate complex urban or highway vehicular environment.
  • Data Aggregation: Apply data aggregation approaches to minimize the amount of data interchanged among vehicles.
  • Security Mechanisms: Establish security mechanisms such as authentication and data integrity verification for NDN content in the vehicular network.

In the above brief procedure will teach you how to simulate and evaluate the results using the tool of ns2 to vehicular named data networks projects in the network scenario. Additional specific details regarding this project will update in another manual. phdprime.com is your go-to resource for completing Vehicular NDN simulations using the ns2 tool. We also offer assistance with project evaluation to ensure your success.

Opening Time

9:00am

Lunch Time

12:30pm

Break Time

4:00pm

Closing Time

6:30pm

  • award1
  • award2