# Create event scheduler set ns [new Simulator] # Turn on tracing set nam_file lab-ex.nam set nf [open $nam_file w] $ns namtrace-all $nf # Create the topology # Frist, the nodes ...... # Then, the links ...... # Set the routing protocol ...... # Now create agents and attach them to the appropriate nodes ...... # start transmitting packets from 0 to 2 ...... # Bring down the link between 1 and 2 using this command $ns rtmodel-at 0.25 down $n(0) $n(1) proc finish {} { global ns nf nam_file $ns flush-trace close $nf exec nam $nam_file & exit 0 } $ns at 1.0 "finish" $ns run
4 | | 0-------------1----------2---------5 | | 3Choose Dense Mode as the multicast routing protocol for the experiment. Node 0 is a UDP source for this group. The source will start transmission at time 0.05. Nodes 3 and 4 will join the multicast group at times 0.10 and 0.12, respectively. Node 3 will leave the multicast group at 0.5, and the execution will terminate at 0.6
# Create event scheduler set ns [new Simulator] # Turn on tracing ...... # [Define nam colors?] ...... # Create topology # First the nodes ...... # Then the links ...... # [Define topology layout in nam?] ...... # Choose the routing protocol ...... # Create multicast group ...... # Create the UDP agent and tie it to the multicast group ...... # Set group membership ...... # Final wrapup ...... # Run the script. $ns run
References: