LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-06-2014, 10:21 AM   #1
Eyesfil
LQ Newbie
 
Registered: Jul 2014
Posts: 1

Rep: Reputation: Disabled
NS-2 cbrgen and gnuplot problem


Hi guys i need your helps i must make one topology of network [802.11 with 2.4 frequency] with variable number of nodes [100 or 200] in an Area of 250x250 mt second Random Waypoint with fix velocity of 1m/s and pause time of 10 sec. With renge of communication radio about 100 m. with Mac rate 24mbs and basic rate 6 mbs. With propagation model TwoRayGround. The number of fluxs Cbr over UDP are 5 10 15 20 25 activated between source and destination in random way. Rate of CBR in the application level must be 64 kbs and 512 kbs. DImension of packet CBR is 1000 byte.

I have do in this way : i have used tool setdest and threshold and cbrgen i have make mobilita_source.tcl that is my tcl and inside is so :


# ======================================================================
# Define ions
# ======================================================================

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
Mac/802_11 set RTSThreshold_ 500 ;
Mac/802_11 set dataRate_ 24Mb ;
Mac/802_11 set basicRate_ 6Mb ;
Mac/802_11 set CWMin_ 31 ;
Mac/802_11 set CWMAX_ 1023 ;
Mac/802_11 set SlotTime_ 0.000009 ;
Mac/802_11 set SIFS_ 0.000016 ;
Mac/802_11 set ShortRetryLImit_ 7 ;
Mac/802_11 set LOngRetryLimit_ 7 ;


set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
set val(ifqlen) 50 ;# max packet in ifq
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(adhocRouting) AODV ;# routing protocol

###########################################
set val(x) 250 ;# X dimension of the topography
set val(y) 250 ;# Y dimension of the topography

set val(tr) esercizio1.tr ;# trace file
set val(nn) 100 ;# how many nodes are simulated
set val(stop) 100.0 ;# simulation time
set val(seed) 0.0



# ======================================================================
# Main Program
# ======================================================================


#
# Initialize Global Variables
#

# create simulator instance

set ns_ [new Simulator]

# define topology
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)

# create trace object for ns and nam

set tracefd [open $val(tr) w]

$ns_ trace-all $tracefd

# use new trace file format
#$ns use-newtrace


#
# Create God
#
set god_ [create-god $val(nn)]
#
# define how node should be created
#
#global node setting

$ns_ node-config -adhocRouting $val(adhocRouting) \
-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

#
# Create the specified number of nodes [$val(nn)] and "attach" them
# to the channel.

for {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns_ node]
}


#
# Define node positions

source "mobilita_100.tcl"



# Define traffic flows

source "traffic"






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

$ns_ at $val(stop).000000001 "puts \"NS EXITING...\" ; $ns_ halt"


puts "Starting Simulation..."
$ns_ run



then i have modded also Cbrgen puts inside random flux betwen 0 and 10 second... and must finish in 100.
:


#
# Copyright (c) 1999 by the University of Southern California
# All rights reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License,
# version 2, as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# The copyright of this module includes the following
# linking-with-specific-other-licenses addition:
#
# In addition, as a special exception, the copyright holders of
# this module give you permission to combine (via static or
# dynamic linking) this module with free software programs or
# libraries that are released under the GNU LGPL and with code
# included in the standard release of ns-2 under the Apache 2.0
# license or under otherwise-compatible licenses with advertising
# requirements (or modified versions of such code, with unchanged
# license). You may copy and distribute such a system following the
# terms of the GNU GPL for this module and the licenses of the
# other code concerned, provided that you include the source code of
# that other code when and as the GNU GPL requires distribution of
# source code.
#
# Note that people who make modified versions of this module
# are not obligated to grant this special exception for their
# modified versions; it is their choice whether to do so. The GNU
# General Public License gives permission to release a modified
# version without this exception; this exception also makes it
# possible to release a modified version which carries forward this
# exception.

# Traffic source generator from CMU's mobile code.
#
# $Header: /cvsroot/nsnam/ns-2/indep-utils/cmu-scen-gen/cbrgen.tcl,v 1.4 2005/09/16 03:05:39 tomh Exp $

# ======================================================================
# Default Script Options
# ======================================================================
set opt(nn) 0 ;# Number of Nodes
set opt(seed) 0.0
set opt(mc) 0
set opt(pktsize) 1000

set opt(rate) 0
set opt(interval) 0.0 ;# inverse of rate
set opt(type) ""

# ======================================================================

proc usage {} {
global argv0

puts "\nusage: $argv0 \[-type cbr|tcp\] \[-nn nodes\] \[-seed seed\] \[-mc connections\] \[-rate rate\]\n"
}

proc getopt {argc argv} {
global opt
lappend optlist nn seed mc rate type

for {set i 0} {$i < $argc} {incr i} {
set arg [lindex $argv $i]
if {[string range $arg 0 0] != "-"} continue

set name [string range $arg 1 end]
set opt($name) [lindex $argv [expr $i+1]]
}
}

proc create-cbr-connection { src dst } {
global rng cbr_cnt opt

set stime [$rng uniform 0.0 180.0]

puts "#\n# $src connecting to $dst at time $stime\n#"

##puts "set cbr_($cbr_cnt) \[\$ns_ create-connection \
##CBR \$node_($src) CBR \$node_($dst) 0\]";

puts "set udp_($cbr_cnt) \[new Agent/UDP\]"
puts "\$ns_ attach-agent \$node_($src) \$udp_($cbr_cnt)"
puts "set null_($cbr_cnt) \[new Agent/Null\]"
puts "\$ns_ attach-agent \$node_($dst) \$null_($cbr_cnt)"
puts "set cbr_($cbr_cnt) \[new Application/Traffic/CBR\]"
puts "\$cbr_($cbr_cnt) set packetSize_ $opt(pktsize)"
puts "\$cbr_($cbr_cnt) set interval_ $opt(interval)"
puts "\$cbr_($cbr_cnt) set random_ 1"
puts "\$cbr_($cbr_cnt) set maxpkts_ 10000"
puts "\$cbr_($cbr_cnt) attach-agent \$udp_($cbr_cnt)"
puts "\$ns_ connect \$udp_($cbr_cnt) \$null_($cbr_cnt)"

puts "\$ns_ at $0 \"\$cbr_($cbr_cnt) start\""
puts "\$ns_ at $10 \"\$cbr_($cbr_cnt) stop\""

incr cbr_cnt
}

proc create-tcp-connection { src dst } {
global rng cbr_cnt opt

set stime [$rng uniform 0.0 180.0]

puts "#\n# $src connecting to $dst at time $stime\n#"

puts "set tcp_($cbr_cnt) \[\$ns_ create-connection \
TCP \$node_($src) TCPSink \$node_($dst) 0\]";
puts "\$tcp_($cbr_cnt) set window_ 32"
puts "\$tcp_($cbr_cnt) set packetSize_ $opt(pktsize)"

puts "set ftp_($cbr_cnt) \[\$tcp_($cbr_cnt) attach-source FTP\]"


puts "\$ns_ at $stime \"\$ftp_($cbr_cnt) start\""

incr cbr_cnt
}

# ======================================================================

getopt $argc $argv

if { $opt(type) == "" } {
usage
exit
} elseif { $opt(type) == "cbr" } {
if { $opt(nn) == 0 || $opt(seed) == 0.0 || $opt(mc) == 0 || $opt(rate) == 0 } {
usage
exit
}

set opt(interval) [expr 1 / $opt(rate)]
if { $opt(interval) <= 0.0 } {
puts "\ninvalid sending rate $opt(rate)\n"
exit
}
}

puts "#\n# nodes: $opt(nn), max conn: $opt(mc), send rate: $opt(interval), seed: $opt(seed)\n#"

set rng [new RNG]
$rng seed $opt(seed)

set u [new RandomVariable/Uniform]
$u set min_ 0
$u set max_ 100
$u use-rng $rng

set cbr_cnt 0
set src_cnt 0






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

set x [$u value]

if {$x < 50} {continue;}

incr src_cnt

set dst [expr ($i+1) % [expr $opt(nn) + 1] ]
#if { $dst == 0 } {
#set dst [expr $dst + 1]
#}

if { $opt(type) == "cbr" } {
create-cbr-connection $i $dst
} else {
create-tcp-connection $i $dst
}

if { $cbr_cnt == $opt(mc) } {
break
}

if {$x < 75} {continue;}

set dst [expr ($i+2) % [expr $opt(nn) + 1] ]
#if { $dst == 0 } {
#set dst [expr $dst + 1]
#}

if { $opt(type) == "cbr" } {
create-cbr-connection $i $dst
} else {
create-tcp-connection $i $dst
}

if { $cbr_cnt == $opt(mc) } {
break
}
}

puts "#\n#Total sources/connections: $src_cnt/$cbr_cnt\n#"


but i am not sure about random fluxs start number i used this inside cbr
puts "\$ns_ at $0 \"\$cbr_($cbr_cnt) start\""
puts "\$ns_ at $10 \"\$cbr_($cbr_cnt) stop\""

Last edited by Eyesfil; 07-06-2014 at 10:32 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
imbedded gnuplot script problem sbgirl54 Linux - Software 4 08-20-2012 10:18 AM
gnuplot svg terminal problem sreejithpk Linux - Software 6 03-18-2009 11:24 AM
Gnuplot allycavs Linux - Software 5 02-04-2005 07:31 AM
need help for gnuplot eph Linux - Newbie 1 08-23-2004 08:41 AM
about gnuplot Rex_chaos Linux - Software 0 09-25-2003 08:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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