A homepage subtitle here And an awesome description here!

29 July 2018

Energy Model in ns2 - NS2 Tutorial # 6

LEcture 6 - Ns2 Energy Model



Wireless NEtworking in ns2



By default, nodes have infinite energy, to make it finite, we need to implement energy model.



in the node config we need to include the following lines



-energyModel "EnergyModel" \

-initialEnergy 3.0 \

-txPower 0.9 \

-rxPower 0.5 \

-idlePower 0.45 \

-sleepPower 0.05 \



Energy (joules) = Power (Watts) * Time (sec)



www.nsnam.com for downloading the source codes

Also subscribe to my youtube channel



www.youtube.com/tspradeepkumar



Thanks for watching. Stay Tuned for more Lectures...



Subscribe and Share.











Copy the Source Code here



#Lecture 6 

#Example of Wireless networks

#Step 1 initialize variables

#Step 2 - Create a Simulator object

#step 3 - Create Tracing and animation file

#step 4 - topography

#step 5 - GOD - General Operations Director

#step 6 - Create nodes

#Step 7 - Create Channel (Communication PATH)

#step 8 - Position of the nodes (Wireless nodes needs a location)

#step 9 - Any mobility codes (if the nodes are moving)

#step 10 - TCP, UDP Traffic

#run the simulation


#initialize the variables

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

set val(prop)           Propagation/TwoRayGround   ;# radio-propagation model

set val(netif)          Phy/WirelessPhy            ;# network interface type WAVELAN DSSS 2.4GHz

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

set val(ifq)            Queue/DropTail/PriQueue    ;# interface queue type

set val(ll)             LL                         ;# link layer type

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

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

set val(nn)             6                          ;# number of mobilenodes

set val(rp)             AODV                       ;# routing protocol

set val(x) 500 ;# in metres

set val(y) 500 ;# in metres

#Adhoc OnDemand Distance Vector


#creation of Simulator

set ns [new Simulator]


#creation of Trace and namfile 

set tracefile [open wireless.tr w]

$ns trace-all $tracefile


#Creation of Network Animation file

set namfile [open wireless.nam w]

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


#create topography

set topo [new Topography]

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


#GOD Creation - General Operations Director

create-god $val(nn)


set channel1 [new $val(chan)]

set channel2 [new $val(chan)]

set channel3 [new $val(chan)]


#configure the node

$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) \

-energyModel "EnergyModel" \

-initialEnergy 3.0 \

-txPower 0.9 \

-rxPower 0.5 \

-idlePower 0.45 \

-sleepPower 0.05 \

-topoInstance $topo \

-agentTrace ON \

-macTrace ON \

-routerTrace ON \

-movementTrace ON \

-channel $channel1 


#Energy Model

# the unit of energy is joules = Power (Watts) * time (Seconds)


set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

set n3 [$ns node]

set n4 [$ns node]

set n5 [$ns node]


$n0 random-motion 0

$n1 random-motion 0

$n2 random-motion 0

$n3 random-motion 0

$n4 random-motion 0

$n5 random-motion 0


$ns initial_node_pos $n0 20

$ns initial_node_pos $n1 20

$ns initial_node_pos $n2 20

$ns initial_node_pos $n3 20

$ns initial_node_pos $n4 20

$ns initial_node_pos $n5 50


#initial coordinates of the nodes 

$n0 set X_ 10.0

$n0 set Y_ 20.0

$n0 set Z_ 0.0


$n1 set X_ 210.0

$n1 set Y_ 230.0

$n1 set Z_ 0.0


$n2 set X_ 100.0

$n2 set Y_ 200.0

$n2 set Z_ 0.0


$n3 set X_ 150.0

$n3 set Y_ 230.0

$n3 set Z_ 0.0


$n4 set X_ 430.0

$n4 set Y_ 320.0

$n4 set Z_ 0.0


$n5 set X_ 270.0

$n5 set Y_ 120.0

$n5 set Z_ 0.0

#Dont mention any values above than 500 because in this example, we use X and Y as 500,500


#mobility of the nodes

#At what Time? Which node? Where to? at What Speed?

$ns at 1.0 "$n1 setdest 490.0 340.0 25.0"

$ns at 1.0 "$n4 setdest 300.0 130.0 5.0"

$ns at 1.0 "$n5 setdest 190.0 440.0 15.0"

#the nodes can move any number of times at any location during the simulation (runtime)

$ns at 20.0 "$n5 setdest 100.0 200.0 30.0"


#creation of agents

set tcp [new Agent/TCP]

set sink [new Agent/TCPSink]

$ns attach-agent $n0 $tcp

$ns attach-agent $n5 $sink

$ns connect $tcp $sink

set ftp [new Application/FTP]

$ftp attach-agent $tcp

$ns at 1.0 "$ftp start"


set udp [new Agent/UDP]

set null [new Agent/Null]

$ns attach-agent $n2 $udp

$ns attach-agent $n3 $null

$ns connect $udp $null

set cbr [new Application/Traffic/CBR]

$cbr attach-agent $udp

$ns at 1.0 "$cbr start"


$ns at 30.0 "finish"


proc finish {} {

global ns tracefile namfile

$ns flush-trace

close $tracefile

close $namfile

exit 0

}


puts "Starting Simulation"

$ns run





T S Pradeep Kumar





28 July 2018

Wireless network Coding in ns2 - NS2 Tutorial # 5

This post shows you how to write TCL code for Wireless simulations in ns2. It also explains the various aspects of wireless network.

It is part of a lecture series in network simulator 2.

The following image is shown for explanation

Wireless Networks
Wireless Networks
Download the Source code for Wireless Networks

#Example of Wireless networks
#Step 1 initialize variables
#Step 2 - Create a Simulator object
#step 3 - Create Tracing and animation file
#step 4 - topography
#step 5 - GOD - General Operations Director
#step 6 - Create nodes
#Step 7 - Create Channel (Communication PATH)
#step 8 - Position of the nodes (Wireless nodes needs a location)
#step 9 - Any mobility codes (if the nodes are moving)
#step 10 - TCP, UDP Traffic
#run the simulation

#initialize the variables
set val(chan)           Channel/WirelessChannel    ;#Channel Type
set val(prop)           Propagation/TwoRayGround   ;# radio-propagation model
set val(netif)          Phy/WirelessPhy            ;# network interface type WAVELAN DSSS 2.4GHz
set val(mac)            Mac/802_11                 ;# MAC type
set val(ifq)            Queue/DropTail/PriQueue    ;# interface queue type
set val(ll)             LL                         ;# link layer type
set val(ant)            Antenna/OmniAntenna        ;# antenna model
set val(ifqlen)         50                         ;# max packet in ifq
set val(nn)             6                          ;# number of mobilenodes
set val(rp)             AODV                       ;# routing protocol
set val(x) 500 ;# in metres
set val(y) 500 ;# in metres
#Adhoc OnDemand Distance Vector

#creation of Simulator
set ns [new Simulator]

#creation of Trace and namfile 
set tracefile [open wireless.tr w]
$ns trace-all $tracefile

#Creation of Network Animation file
set namfile [open wireless.nam w]
$ns namtrace-all-wireless $namfile $val(x) $val(y)

#create topography
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)

#GOD Creation - General Operations Director
create-god $val(nn)

set channel1 [new $val(chan)]
set channel2 [new $val(chan)]
set channel3 [new $val(chan)]

#configure the node
$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) \
-topoInstance $topo \
-agentTrace ON \
-macTrace ON \
-routerTrace ON \
-movementTrace ON \
-channel $channel1 

set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]

$n0 random-motion 0
$n1 random-motion 0
$n2 random-motion 0
$n3 random-motion 0
$n4 random-motion 0
$n5 random-motion 0

$ns initial_node_pos $n0 20
$ns initial_node_pos $n1 20
$ns initial_node_pos $n2 20
$ns initial_node_pos $n3 20
$ns initial_node_pos $n4 20
$ns initial_node_pos $n5 50

#initial coordinates of the nodes 
$n0 set X_ 10.0
$n0 set Y_ 20.0
$n0 set Z_ 0.0

$n1 set X_ 210.0
$n1 set Y_ 230.0
$n1 set Z_ 0.0

$n2 set X_ 100.0
$n2 set Y_ 200.0
$n2 set Z_ 0.0

$n3 set X_ 150.0
$n3 set Y_ 230.0
$n3 set Z_ 0.0

$n4 set X_ 430.0
$n4 set Y_ 320.0
$n4 set Z_ 0.0

$n5 set X_ 270.0
$n5 set Y_ 120.0
$n5 set Z_ 0.0
#Dont mention any values above than 500 because in this example, we use X and Y as 500,500

#mobility of the nodes
#At what Time? Which node? Where to? at What Speed?
$ns at 1.0 "$n1 setdest 490.0 340.0 25.0"
$ns at 1.0 "$n4 setdest 300.0 130.0 5.0"
$ns at 1.0 "$n5 setdest 190.0 440.0 15.0"
#the nodes can move any number of times at any location during the simulation (runtime)
$ns at 20.0 "$n5 setdest 100.0 200.0 30.0"

#creation of agents
set tcp [new Agent/TCP]
set sink [new Agent/TCPSink]
$ns attach-agent $n0 $tcp
$ns attach-agent $n5 $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 1.0 "$ftp start"

set udp [new Agent/UDP]
set null [new Agent/Null]
$ns attach-agent $n2 $udp
$ns attach-agent $n3 $null
$ns connect $udp $null
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$ns at 1.0 "$cbr start"

$ns at 30.0 "finish"

proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exit 0
}

puts "Starting Simulation"
$ns run




T S Pradeep Kumar

26 July 2018

Wired Network Coding in ns2 - NS2 Tutorial # 4

This post shows the wired network coding in ns2. It uses 6 nodes ( 0 to 5) and exchange FTP/CBR packets between the nodes.
Please find the coding here. 


Wired Network
Wired Network
Wired Coding in ns2 (with comments and explanation, for detailed explanation see the video at the end)

#please subscribe
#www.youtube.com/tspradeepkumar
#Thank you

#create a simulator object 
set ns [new Simulator]

#create a trace file, this file is for logging purpose 
set tracefile [open wired.tr w]
$ns trace-all $tracefile

#create a animation infomration or NAM file creation
set namfile [open wired.nam w]
$ns namtrace-all $namfile

#create nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]

#creation of link between nodes with DropTail Queue
#Droptail means Dropping the tail.
$ns duplex-link $n0 $n1 5Mb 2ms DropTail
$ns duplex-link $n2 $n1 10Mb 5ms DropTail
$ns duplex-link $n1 $n4 3Mb 10ms DropTail
$ns duplex-link $n4 $n3 100Mb 2ms DropTail
$ns duplex-link $n4 $n5 4Mb 10ms DropTail

#creation of Agents
#node 0 to Node 3
set udp [new Agent/UDP]
set null [new Agent/Null]
$ns attach-agent $n0 $udp
$ns attach-agent $n3 $null
$ns connect $udp $null

#creation of TCP Agent
set tcp [new Agent/TCP]
set sink [new Agent/TCPSink]
$ns attach-agent $n2 $tcp
$ns attach-agent $n5 $sink
$ns connect $tcp $sink

#creation of Application CBR, FTP
#CBR - Constant Bit Rate (Example nmp3 files that have a CBR or 192kbps, 320kbps, etc.)
#FTP - File Transfer Protocol (Ex: To download a file from a network)
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp

set ftp [new Application/FTP]
$ftp attach-agent $tcp

#Start the traffic 
$ns at 1.0 "$cbr start"
$ns at 2.0 "$ftp start"

$ns at 10.0 "finish"

#the following procedure will be called at 10.0 seconds 
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exit 0
}

puts "Simulation is starting..."
$ns run







T S Pradeep Kumar


23 July 2018


04 July 2018

How to Mount NTFS and exFAT Partition in RHEL CentOS

Mounting NTFS

Mounting NTFS partition in CentOS/RHEL will need a simple trick. Here is the step.
$] sudo yum install epel-release

$] sudo yum install ntfs-3g

Suppose if the name of the device is /dev/sda3 and /dev/sda4, then here is the command to mount it from the terminal
$] sudo mkdir /mnt/WinE

$] sudo mkdir /mnt/WinD

$] sudo mount -t ntfs-3g /dev/sda3 /mnt/WinE  $] sudo mount -t ntfs-3g /dev/sda4 /mnt/WinD
If your windows OS is running with any updates or under hibernation, the above command will not work, Here is the solution for that. You can open the drives under read only mode.

if you get the error like shown above, here is the command 

$] sudo mount -t ntfs-3g /dev/sda3 /mnt/WinE -ro o

$] sudo mount -t ntfs-3g /dev/sda4 /mnt/WinD -ro o
NB: Sometimes you need not type "-t ntfs-3g", if the libraries are there, without this attribute also, the disk will be mounted.
Mounting in RHEL

Mounting exFAT file system

exFAT is another filesystem supported by the Unix families like (Mac OS). CentOS has a way to 
customise for mounting the exfat filesystem.

$] sudo yum install scons gcc fuse-devel rpmbuild
$] wget http://download1.rpmfusion.org/free/el/updates/6/SRPMS/exfat-utils-1.0.1-1.el6.src.rpm
$] wget http://download1.rpmfusion.org/free/el/updates/6/SRPMS/fuse-exfat-1.0.1-1.el6.src.rpm

$] rpm -ivh fuse-exfat-1.0.1-1.el6.src.rpm exfat-utils-1.0.1-1.el6.src.rpm

$] cd
./rpmbuild/SPECS
$] rpmbuild -ba fuse-exfat.spec
$] rpmbuild -ba exfat-utils.spec

$] cd
../RPMS/x86_64/
$] rpm -ivh fuse-exfat-1.0.1-1.el6.x86_64.rpm exfat-utils-1.0.1-1.el6.x86_64.rpm

The following is optional.
$] ln -s /usr/sbin/mount.exfat /sbin/mount.exfat

Again you can click the icon in the explorer to mount the exFAT partition, in the terminal

$] sudo mount -t exfat /dev/sdb2 /mnt/WinC

Powered by Blogger.

About Me

Featured Post

5G Network Simulation in NS3 using mmWave | NS3 Tutorial 2024

5G Network Simulation in NS3 Using mmWave This post shows the installation of ns3mmwave in Ubuntu 24.04 and simulates 5G networks in ns3. In...

Contact form

Name

Email *

Message *

Total Pageviews

Search This Blog

Pages

Pages

Pages - Menu

Most Popular

Popular Posts