How to Simulate Mobile Communication Networks Using NS2

To simulate Mobile Communication Networks using NS2 (Network Simulator 2) that encompasses setting up mobile nodes, wireless protocols, mobility models, and communication among the nodes over wireless channels. NS2 delivers support for replicating mobile ad-hoc networks (MANETs), cellular networks, and other kinds of mobile communication systems. We can replicate several mobile communication protocols such as AODV, DSR, and TORA for routing, along with distinct traffic patterns using TCP, UDP, or CBR (Constant Bit Rate).

We will demonstrate you through a step-by-step instructions to simulate Mobile Communication Networks projects in NS2:

Steps for Simulating Mobile Communication Networks in NS2

  1. Install NS2: If we haven’t installed NS2 that we can install it on a Linux system (recommended) using the below command:

sudo apt-get install ns2

  1. Understand NS2 Mobile Node Setup: The simulator NS2 has built-in support for mobile nodes that utilize wireless channels and mobility models. The significant modules for simulating mobile communication networks in NS2 are:
    • Wireless Channel: The shared communication medium for wireless nodes.
    • MobileNode: NS2’s class for denoting mobile nodes.
    • Routing Protocols: General mobile routing protocols such as AODV, DSR, and TORA.
    • Mobility Models: NS2 supports models such as Random Waypoint, Random Walk, and so on, for node mobility.
  1. Create a Mobile Communication Scenario Using Tcl Script: We can be mimicked a basic Mobile Ad Hoc Network (MANET) with mobile nodes using a Tcl script. The following instance establishes a basic configuration.

Example Tcl Script for Simulating a Mobile Network:

# Create a new simulator object

set ns [new Simulator]

# Define options for the wireless communication channel

set val(chan)           Channel/WirelessChannel  ;# Channel type

set val(prop)           Propagation/TwoRayGround ;# Propagation model

set val(netif)          Phy/WirelessPhy          ;# Network interface type

set val(mac)            Mac/802_11               ;# MAC type

set val(ifq)            Queue/DropTail/PriQueue  ;# Interface Queue

set val(ll)             LL                       ;# Link Layer

set val(ant)            Antenna/OmniAntenna      ;# Antenna model

set val(ifqlen)         50                       ;# Max packet in ifq

set val(nn)             10                       ;# Number of mobile nodes

set val(rp)             AODV                     ;# Routing protocol

set val(x)              500                      ;# X dimension of the topography

set val(y)              500                      ;# Y dimension of the topography

# Set up trace and NAM output files

set tracefile [open out.tr w]

set namfile [open out.nam w]

$ns trace-all $tracefile

$ns namtrace-all-wireless $namfile $val(x) $val(y)

# Set up the topology object

set topo [new Topography]

$topo load_flatgrid $val(x) $val(y)

# Create the God object to store information about the network topology

create-god $val(nn)

# Configure the channel, propagation model, and network interface parameters

$ns node-config -adhocRouting $val(rp) \

-llType $val(ll) \

-macType $val(mac) \

-ifqType $val(ifq) \

-ifqLen $val(ifqlen) \

-antType $val(ant) \

-propType $val(prop) \

-phyType $val(netif) \

-channelType $val(chan) \

-topoInstance $topo \

-agentTrace ON \

-routerTrace ON \

-macTrace ON \

-movementTrace ON

# Create the mobile nodes

for {set i 0} {$i < $val(nn)} {incr i} {

set node_($i) [$ns node]

$node_($i) random-motion 0 ;# Disable random motion

}

# Define mobility for the nodes (Random Waypoint Model)

$node_(0) set X_ 20.0

$node_(0) set Y_ 30.0

$node_(0) set Z_ 0.0

$node_(1) set X_ 100.0

$node_(1) set Y_ 200.0

$node_(1) set Z_ 0.0

# Define node movements

$ns at 10.0 “$node_(0) setdest 250.0 250.0 15.0”

$ns at 20.0 “$node_(1) setdest 400.0 400.0 10.0”

# Set up traffic flow between the nodes using CBR over UDP

set udp0 [new Agent/UDP]

$ns attach-agent $node_(0) $udp0

set sink [new Agent/Null]

$ns attach-agent $node_(1) $sink

$ns connect $udp0 $sink

set cbr0 [new Application/Traffic/CBR]

$cbr0 set packetSize_ 512

$cbr0 set interval_ 0.05

$cbr0 attach-agent $udp0

# Start traffic and simulation

$ns at 5.0 “$cbr0 start”

$ns at 100.0 “$cbr0 stop”

$ns at 110.0 “finish”

# Define finish procedure

proc finish {} {

global ns tracefile namfile

$ns flush-trace

close $tracefile

close $namfile

exec nam out.nam &

exit 0

}

# Run the simulation

$ns run

Explanation of the Tcl Script:

  1. Simulator Object:
    • The set ns [new Simulator] command makes an NS2 simulator object.
  2. Wireless Configuration:
    • Parameters like the wireless channel (Channel/WirelessChannel), propagation model (Propagation/TwoRayGround), and MAC protocol (Mac/802_11) are described to model a wireless mobile network.
  3. Node Configuration:
    • The node-config command sets up the metrics for mobile nodes, like the routing protocol (AODV in this case), link layer (LL), MAC layer (802.11), and antenna type (OmniAntenna).
  4. Mobile Nodes:
    • Mobile nodes are made in a loop using the node-config settings. Each node’s first position is indicated using the set X_, set Y_, and set Z_ commands.
    • Mobility: The setdest command is utilized to describe the mobility of nodes. For instance, node 0 moves to the destination (250, 250) at a speed of 15 units for each second after 10 seconds.
  5. Traffic Source:
    • A UDP agent is connected to node 0, and a sink agent is connected to node 1. A CBR (Constant Bit Rate) traffic generator is utilized to transmit packets from node 0 to node 1 at regular intervals.
  6. Traffic Scheduling:
    • The traffic begins at 5.0 seconds and ends at 100.0 seconds. The simulation stops at 110 seconds.
  7. Trace and NAM File Output:
    • Simulation events are recorded in the trace file (out.tr), and the network animation is saved in the NAM file (out.nam).
  1. Running the Simulation:

We can save the script as mobile_simulation.tcl and we run it in NS2:

ns mobile_simulation.tcl

After the simulation completes then observe the outcomes in NAM:

nam out.nam

  1. Analyzing the Results:
  • Trace File Analysis: The trace file (out.tr) includes data regarding packet transmission, reception, packet drops, routing decisions, and more. We can examine this file to estimate parameters like packet delivery ratio, end-to-end delay, throughput, and packet loss.
  • NAM Visualization: The NAM tool permits to envision node mobility, traffic flows, and packet exchanges among the nodes.

Extending the Model:

  1. Mobility Models:
    • Test with distinct mobility models, like Random Waypoint, Random Walk, and Gauss-Markov mobility, to replicate realistic node movements.
  2. Traffic Models:
    • We can use distinct traffic patterns such as FTP over TCP, CBR over UDP, or Exponential Traffic to model several kinds of network traffic.
  3. Routing Protocols:
    • Alter the routing protocol to replicate distinct scenarios (e.g., use DSR, TORA, OLSR, or DSDV in place of AODV).
  4. Scalability:
    • Maximizes the amount of nodes and area size to mimic larger networks. Examine the performance influence on the network as the scale increases.
  5. Performance Metrics:
    • Assess performance parameters such as throughput, packet delivery ratio, latency, and energy consumption by processing the trace file using AWK scripts or other tools.

We had presented the simulation process to simulate the Mobile Communication Networks and analyse the outcomes using NS2 simulation tool. If desired, we can offer expanded details and comprehensive information on this topic.

phdprime.com possess the latest tools and resources to offer you good guidance on Mobile Communication Networks Projects. You can receive tailored services from us to meet your specific needs we provide you original topics in your interested area that attracts the readers.

Opening Time

9:00am

Lunch Time

12:30pm

Break Time

4:00pm

Closing Time

6:30pm

  • award1
  • award2