# Create a new simulation object
set ns [new Simulator]
# Enable trace file generation
set tracefile [open
hybrid_aodv_olsr.tr w]
$ns trace-all $tracefile
# Create nodes
set node0 [$ns node]
set node1 [$ns node]
set node2 [$ns node]
# Create links between nodes
$ns duplex-link $node0 $node1 10Mb 5ms DropTail
$ns duplex-link $node1 $node2 10Mb 5ms DropTail
# Create AODV agent at node0
set aodv [new Agent/AODV]
$ns attach-agent $node0 $aodv
$ns at 0.0 "$aodv start"
# Create OLSR agent at node1
set olsr [new Agent/OLSR]
$ns attach-agent $node1 $olsr
$ns at 0.0 "$olsr start"
# Define a routing protocol for each link
$ns rtproto DV $node0 $aodv
$ns rtproto OLSR $node1 $olsr
$ns rtmodel-at $node2 $ns
# Create CBR traffic source
set udp_cbr [new Agent/UDP]
$ns attach-agent $node0 $udp_cbr
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp_cbr
$cbr set rate_ 1Mbps
$cbr set random_ false
$cbr set packetSize_ 1000
$ns connect $udp_cbr $node2
$ns at 1.0 "$cbr start"
$ns at 10.0 "$cbr stop"
# Run the simulation
$ns run
# Close the trace file
$ns flush-trace
close $tracefile
# Exit the simulation
exit 0
18 Eylül 2023 Pazartesi tarihinde saat 15:39:32 UTC+3 itibarıyla knudfl şunları yazdı: