LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-21-2011, 11:21 PM   #1
Basavaraj Malapur
LQ Newbie
 
Registered: Feb 2011
Posts: 1

Rep: Reputation: 0
coding for ns2


Hi, Friends, I am doing M.Tech project on ROUTE OPTIMIZATION using GENETIC ALGORITHM. I am newer to ns2 and genetic algorithm, plz help me how to carry out.
 
Old 02-21-2011, 11:50 PM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
Hello and welcome to LQ. Please be more descriptive when asking a question, and please follow the guide on how to ask a question.... http://www.linuxquestions.org/linux/...Ask_a_Question

As far as your question, what exactly do you need help with? I do not understand your question at all...
 
Old 08-09-2011, 10:17 PM   #3
shanky
Member
 
Registered: Aug 2011
Posts: 155

Rep: Reputation: Disabled
hiiii..i am trying to write a code in ns2 where 2 nodes act as access point and a station and exchange of frames take place between them one after the other.Frames like probe req response authentication and association.But for the code i have written the exchange is takin place simultaneously.Below is my code.Can u plz help me out such that frames are transferred one after the other.
Thanks in advance.

#Creating a new Simulator object
set ns [new Simulator]

#Opening file to be used as nam trace file
set nf [open shot.nam w]
$ns namtrace-all $nf

#Finish procedure
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec nam shot.nam &
exit 0
}

#Defining two nodes
set n0 [$ns node]
set n1 [$ns node]

#Connecting two nodes
$ns duplex-link $n0 $n1 1Mb 10ms DropTail

#CreateUDP agent and connect to node0
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0

#Create CBR traffic source and attach to UDP agent
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 1
$cbr0 attach-agent $udp0

set null0 [new Agent/Null]
$ns attach-agent $n1 $null0

$ns connect $udp0 $null0

#CreateUDP agent and connect to node1
set udp1 [new Agent/UDP]
$ns attach-agent $n1 $udp1

#Create CBR traffic source and attach to UDP agent
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 1
$cbr1 attach-agent $udp1

set null1 [new Agent/Null]
$ns attach-agent $n0 $null1

$ns connect $udp1 $null1

for {set i 0} {$i < 10} {incr i} {

set q [expr $i%2]
if {$q==0} {
set a i
set b [expr $i+1]
$ns at a "$cbr0 start"
$ns at b "$cbr0 stop"
}
if {$q!=0} {
set a i
set b [expr $i+1]
$ns at a "$cbr1 start"
$ns at b "$cbr1 stop"
}
}

#Stop after 10 seconds
$ns at 10.0 "finish"

#Running simulation
$ns run
 
  


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
coding needed lano Linux - Newbie 6 11-30-2010 04:23 PM
i am using ubuntu as os. for NS2 to implement a routing protocol in ns2. sujovasu Programming 1 07-27-2010 01:44 AM
weight throwing protocol using ns2 code,diffusion based protocol using ns2 code rajrupa Linux - Networking 1 05-27-2010 03:39 AM
HTML-coding oh2fpg General 4 02-18-2010 01:56 AM
Coding a WM? SocialEngineer Programming 1 05-20-2005 08:32 AM


All times are GMT -5. The time now is 07:42 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration