LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-06-2019, 11:57 PM   #1
hajivali
LQ Newbie
 
Registered: Feb 2019
Posts: 9

Rep: Reputation: Disabled
Angry in ns2, wired cum wireless program have some problem ...


### This simulation is an example of combination of wired and wireless
### topologies.


global opt
set opt(chan) Channel/WirelessChannel
set opt(prop) Propagation/TwoRayGround
set opt(netif) Phy/WirelessPhy
set opt(mac) Mac/802_11
set opt(ifq) Queue/DropTail/PriQueue
set opt(ll) LL
set opt(ant) Antenna/OmniAntenna
set opt(x) 670
set opt(y) 670
set opt(ifqlen) 50
set opt(tr) wired-and-wireless.tr
set opt(namtr) wired-and-wireless.nam
set opt(nn) 3
set opt(adhocRouting) DSDV
set opt(cp) ""
set opt(sc) "../mobility/scene/scen-3-test"
set opt(stop) 250
set num_wired_nodes 2
set num_bs_nodes 2


set ns_ [new Simulator]
# set up for hierarchical routing
$ns_ node-config -addressType hierarchical
AddrParams set domain_num_ 3
lappend cluster_num 2 1 1
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel 1 1 4 1
AddrParams set nodes_num_ $eilastlevel

set tracefd [open $opt(tr) w]
$ns_ trace-all $tracefd
$ns
set namtracefd [open $opt(namtr) w]
$ns_ namtrace-all $namtracefd


set topo [new Topography]
$topo load_flatgrid $opt(x) $opt(y)
# god needs to know the number of all wireless interfaces
create-god [expr $opt(nn) + $num_bs_nodes]

#create wired nodes
set temp {0.0.0 0.1.0}
for {set i 0} {$i < $num_wired_nodes} {incr i} {
set W($i) [$ns_ node [lindex $temp $i]]
}
$ns_ node-config -adhocRouting $opt(adhocRouting) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propInstance [new $opt(prop)] \
-phyType $opt(netif) \
-channel [new $opt(chan)] \
-topoInstance $topo \
-wiredRouting ON \
-agentTrace ON \
-routerTrace OFF \
-macTrace OFF

set temp {1.0.0 1.0.1 1.0.2 1.0.3}
set BS(0) [$ns_ node [lindex $temp 0]]
set BS(1) [$ns_ node 2.0.0]
$BS(0) random-motion 0
$BS(1) random-motion 0

$BS(0) set X_ 1.0
$BS(0) set Y_ 2.0
$BS(0) set Z_ 0.0

$BS(1) set X_ 650.0
$BS(1) set Y_ 600.0
$BS(1) set Z_ 0.0

#configure for mobilenodes
$ns_ node-config -wiredRouting OFF

for {set j 0} {$j < $opt(nn)} {incr j} {
set node_($j) [ $ns_ node [lindex $temp \
[expr $j+1]] ]
$node_($j) base-station [AddrParams addr2id [$BS(0) node-addr]]
}
#create links between wired and BS nodes
$ns_ duplex-link $W(0) $W(1) 5Mb 2ms DropTail
$ns_ duplex-link $W(1) $BS(0) 5Mb 2ms DropTail
$ns_ duplex-link $W(1) $BS(1) 5Mb 2ms DropTail
$ns_ duplex-link-op $W(0) $W(1) orient down
$ns_ duplex-link-op $W(1) $BS(0) orient left-down
$ns_ duplex-link-op $W(1) $BS(1) orient right-down

# setup TCP connections
set tcp1 [new Agent/TCP]
$tcp1 set class_ 2
set sink1 [new Agent/TCPSink]
$ns_ attach-agent $node_(0) $tcp1
$ns_ attach-agent $W(0) $sink1
$ns_ connect $tcp1 $sink1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
$ns_ at 160 "$ftp1 start"

set tcp2 [new Agent/TCP]
$tcp2 set class_ 2
set sink2 [new Agent/TCPSink]
$ns_ attach-agent $W(1) $tcp2
$ns_ attach-agent $node_(1) $sink2
$ns_ connect $tcp2 $sink2
set ftp2 [new Application/FTP]
$ftp2 attach-agent $tcp2
$ns_ at 180 "$ftp2 start"

for {set i 0} {$i < $opt(nn)} {incr i} {
$ns_ initial_node_pos $node_($i) 20
}

for {set i } {$i < $opt(nn) } {incr i} {
$ns_ at $opt(stop).0000010 "$node_($i) reset";
}
$ns_ at $opt(stop).0000010 "$BS(0) reset";

$ns_ at $opt(stop).1 "puts "NS EXITING..." ; $ns_ halt"

puts "Starting Simulation..."
$ns_ run
 
Old 02-07-2019, 01:08 AM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196
You have not asked a question. Simply pasting code and saying it has a problem is not going to get many useful responses.

If your code is not working, try to post simplest example which demonstrates the problem along with an explanation of how you would expect it to work and what you have done to try to resolve it.

Please review the Site FAQ for guidance in posting your questions and general forum usage. Especially, read the link in that page, How To Ask Questions The Smart Way. The more effort you put into understanding your problem and framing your questions, the better others can help!

Also, please place your code snippets inside [CODE]...[/CODE] tags for better readability. You may type those yourself or click the "#" button in the edit controls.
 
2 members found this post helpful.
Old 02-07-2019, 06:10 AM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,513

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
@hajivali : Welcome to LQ.

The text you show is a faulty copy of ns-2.35/tcl/ex/wired-cum-wireless-sim.tcl
( Note : Please use CODE TAGS for code → I.e. write [code]code text[/code]
http://www.linuxquestions.org/questi....php?do=bbcode )

Solution: You can unpack ns-allinone-2.35_gcc5.tar.gz (The 2014 .. 2017 update)
https://drive.google.com/file/d/0B7S...ew?usp=sharing
... into a new random location, and run a valid ns-2.35/tcl/ex/wired-cum-wireless-sim.tcl :
Code:
cd ns-2.35/tcl/ex/
ns wired-cum-wireless-sim.tcl
 
1 members found this post helpful.
  


Reply

Tags
ns2



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
Implementing multiple Channels in wired cum wireless scenario sandy123 Linux - Networking 4 04-25-2014 04:53 AM
i am trying to run wireless2.tcl script used for wired cum wireless network pooja lohia Linux - Wireless Networking 0 06-15-2012 03:36 AM
error 'variable can't be read' in nS2 wired cum wireles simulation susanthomas Linux - Wireless Networking 1 06-07-2012 07:22 AM
ns2-how to use Diffserv in wireless-cum-wired networks robina Linux - Networking 0 03-03-2012 11:44 PM
Wireless Laptop to Wired ethernet via Linux PC (wired/wireless) sambartle Linux - Wireless Networking 0 01-30-2005 04:37 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:37 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