LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Closed Thread
  Search this Thread
Old 04-30-2015, 03:23 AM   #1
Md Zishan Khan
LQ Newbie
 
Registered: Oct 2014
Location: West Bengal, INDIA
Posts: 16

Rep: Reputation: Disabled
Doppler Effect using aodv - where to code in c++


#my code is
# Our aim is to make a real time application
# Define options
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-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 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) 4 ;# number of mobilenodes
set val(rp) DSDV ;# routing protocol
set val(x) 300 ;# X dimension of topography
set val(y) 200 ;# Y dimension of topography
set val(stop) 10 ;# time of simulation end

set ns [new Simulator]
set tracefd [open simple-dsdv.tr w]
#set windowVsTime2 [open win.tr w]
set namtrace [open simwrls.nam w]

$ns trace-all $tracefd
$ns use-newtrace
$ns namtrace-all-wireless $namtrace $val(x) $val(y)

# set up topography object
set topo [new Topography]

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

create-god $val(nn)

#
# Create nn mobilenodes [$val(nn)] and attach them to the channel.
#

# configure the nodes
$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 OFF \
-movementTrace ON

# for source node

set node_(0) [$ns node]

$node_(0) set X_ 100.0
$node_(0) set Y_ 100.0
$node_(0) set Z_ 0.0
# for new nodes
for {set i 1} {$i < $val(nn) } { incr i } {
set node_($i) [$ns node]
}
# for random placement
for {set i 1} {$i < $val(nn)} {incr i} {

set xi($i) [expr rand()*$val(x)]
set yi($i) [expr rand()*$val(y)]

$node_($i) set X_ $xi($i)
$node_($i) set Y_ $yi($i)
$node_($i) set Z_ 0
#puts "Initial Position = $xi($i)"
}
# for random movement
for {set i 1} {$i < $val(nn)} {incr i} {

set xf($i) [expr rand()*$val(x)]
set yf($i) [expr rand()*$val(y)]
set t($i) [expr rand()*($val(stop)-1)]

$ns at $t($i) "$node_($i) setdest $xf($i) $yf($i) 5.0"
#puts "final position = $xf($i)"
puts "time = $t($i)"
}

for {set i 0} {$i < $val(stop)} {incr i} { # for time from 0

for {set j 1} {$j < $val(nn)} {incr j} { # for every node/time

#puts "xi($j)= $xi($j)"
#puts "xf($j)= $xf($j)"
#puts "t($j)= $t($j)"

if { $i <= $t($j) && ($i+1) > $t($j) } {
puts "for loop no : $i"
puts "OK $j $xi($j) $xf($j) $yi($j) $yf($j) $t($j)"


#calculating angle of each node
set sl1 [expr {$xf($j)-$xi($j)}]
set sl2 [expr {$yf($j)-$yi($j)}]
set sf [expr {$sl2/$sl1} ]
set sloper($j) [expr {atan($sf)}]
set sloped($j) [expr {$sloper($j)*57.324}]

puts "the angle of direction node $j is : $sloped($j)"

#comparing the movement of node with the source node

# Distance between 2 nodes in initial
set dxi [expr 100.0 - $xi($j)]
set dyi [expr 100.0 - $yi($j)]
set dxi2 [expr $dxi * $dxi]
set dyi2 [expr $dyi * $dyi]
set hi2 [expr $dxi2 + $dyi2]
set hi(0-1) [expr pow($hi2, 0.5)]

puts "$hi(0-1)"

# Distance between 2 nodes in final
set dxf [expr 100.0 - $xf($j)]
set dyf [expr 100.0 - $yf($j)]
set dxf2 [expr $dxf * $dxf]
set dyf2 [expr $dyf * $dyf]
set hf2 [expr $dxf2 + $dyf2]
set hf(0-1) [expr pow($hf2, 0.5)]

puts "$hf(0-1)"



}





}





}







# Set a TCP connection between node_(0) and node_(3)
set tcp [new Agent/TCP/Newreno]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $node_(0) $tcp
$ns attach-agent $node_(3) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 1 "$ftp start"



# Define node initial position in nam
for {set i 0} {$i < $val(nn)} { incr i } {
# 30 defines the node size for nam
$ns initial_node_pos $node_($i) 30
}

# Telling nodes when the simulation ends
for {set i 0} {$i < $val(nn) } { incr i } {
$ns at $val(stop) "$node_($i) reset";
}

# ending nam and the simulation
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "stop"
$ns at 150.01 "puts "end simulation" ; $ns halt"
proc stop {} {
global ns tracefd namtrace
$ns flush-trace
close $tracefd
close $namtrace
exec nam simwrls.nam &
}

$ns run


result is :---
i am getting different angle for different node and i am able to know which node is going far and which will come near in future but the problem is that how to calculate and remove the far going nodes from the path in aodv
 
Old 04-30-2015, 09:32 AM   #2
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,602

Rep: Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.
 
  


Closed Thread

Tags
ns



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error while running modified AODV code shyjuu Linux - Wireless Networking 20 04-04-2015 12:09 PM
I modified the AODV code part of NS2.31 for selecting a node which have minumamenergy lakshmanarao.k Programming 1 03-11-2015 04:51 PM
implementation code for AODV using C++ salma sindagiri Programming 1 11-21-2014 01:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 04:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration