help with network animator code

This is a discussion on help with network animator code within the C Programming forums, part of the General Programming Boards category; Hi im new to C, I was wondering what alterations I would need to the code to specify the upper ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    3

    help with network animator code

    Hi im new to C, I was wondering what alterations I would need to the code to specify the upper limits of my for loops with a variable e.g instead of
    {$i < 8}....something like {$i < flowno}.

    Also for the for loop that specifies 4 as its upper limit, instead could I simply write flowno/2, as this loop will always be half the size of the first loop.

    Code:
    #Create a simulator object
    set ns [new Simulator]
    
    $ns rtproto DV
    Node set multiPath_ 1
    
    
    #Open the nam trace file
    set nf [open out.nam w]
    $ns namtrace-all $nf
    
    #Define a 'finish' procedure
    proc finish {} {
            global ns nf
            $ns flush-trace
        #Close the trace file
            close $nf
        #Execute nam on the trace file
            exec nam out.nam &
            exit 0
    }
    
    
    
    #Create the required number of nodes nodes
    for {set i 0} {$i < 8} {incr i} {
      set n($i) [$ns node]
    }
    
    #set up a link between then
    for {set i 0} {$i < 8} {incr i} {
      $ns duplex-link $n($i) $n([expr ($i+1)%8]) 1Mb 10ms DropTail
    }
    
    #Setting up a flow needs these four steps ---------------
    #1. Create a UDP agent and attach it to node n0
    for {set i 0} {$i < 4} {incr i} {
      set udp($i) [new Agent/UDP]
      $ns attach-agent $n($i) $udp($i)
    
    #2. Create a CBR traffic source and attach it to udp0
      set cbr($i) [new Application/Traffic/CBR]
      $cbr($i) set packetSize_ 1000
      $cbr($i) set interval_ 0.05
      $cbr($i) attach-agent $udp($i)
    
    #3. Create a Null agent (a traffic sink) and attach it to node n1
      set x [expr ($i+4)]
      set null($i) [new Agent/Null]
      $ns attach-agent $n($x) $null($i)
    
    #4. Connect the traffic source with the traffic sink
      $ns connect $udp($i) $null($i)
    
    #Schedule events for the CBR agent
      $ns at 0.5  "$cbr($i) start"
      $ns at 5.0 "$cbr($i) stop"
    
    }  
    #-----------------------------------------------------------
    
    #Call the finish procedure after 1 second of simulation time
      $ns at 1.0 "finish"
    
    #Run the simulation
      $ns run
    any help is greatly appreciated!!!!!

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,533
    Yes, you posted this before
    C help for network animator

    No, it isn't C.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 3D Network Analysis Tool
    By durban in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 11-08-2005, 05:33 PM
  2. Need help with easy Network setup
    By the dead tree in forum Tech Board
    Replies: 9
    Last Post: 04-08-2005, 07:44 PM
  3. Network Phantom !!
    By GSLR in forum Networking/Device Communication
    Replies: 2
    Last Post: 08-14-2003, 11:41 PM
  4. network problems
    By lucy in forum Tech Board
    Replies: 6
    Last Post: 01-01-2003, 02:33 PM
  5. WinXP Network Connections pop-up
    By DavidP in forum Tech Board
    Replies: 1
    Last Post: 10-02-2002, 05:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21