Hi, all!!I don't understand it..
#Open the output files
set f0 [open out0.tr w]
set f1 [open out1.tr w]
set f2 [open out2.tr w]
#Create lan env
set opt(tr) out
set opt(namtr) "mylan2.nam"
set opt(seed) 0
set opt(stop) 20
set opt(node) 8
set opt(qsize) 100
set opt(bw) 10Mb
set opt(delay) 1ms
set opt(ll) LL
set opt(ifq) Queue/DropTail
set opt(mac) Mac/802_3
set opt(chan) Channel
#Define a 'finish' procedure
proc finish {} {
global env nshome pwd
global f0 f1 f2 ns opt trfd
#Close the output files
close $f0
close $f1
close $f2
close $trfd
#Call xgraph to display the results
exec nam mylan2.nam
# exec xgraph out0.tr out1.tr out2.tr -geometry 800x400 &
exit 0
}proc attach-expoo-traffic { node sink size burst idle rate } {
#Get an instance of the simulator
set ns [Simulator instance]
#Create a UDP agent and attach it to the node
set source [new Agent/CBR/UDP]
$ns attach-agent $node $source
#Create an Expoo traffic agent and set its configuration parameters
set traffic [new Traffic/Expoo]
$traffic set packet-size $size
$traffic set burst-time $burst
$traffic set idle-time $idle
$traffic set rate $rate
#Attach the traffic agent to the traffic source
$source attach-traffic $traffic
#Connect the source and the sink
$ns connect $source $sink
return $source
}proc record {} {
global sink0 sink1 sink2 f0 f1 f2 opt
#Get an instance of the simulator
set ns [Simulator instance]
#Set the time after which the procedure should be called again
set time 0.5
#How many bytes have been received by the traffic sinks?
set bw0 [$sink0 set bytes_]
set bw1 [$sink1 set bytes_]
set bw2 [$sink2 set bytes_]
#Get the current time
set now [$ns now]
#Calculate the bandwidth (in MBit/s) and write it to the files
puts $f0 "$now [expr $bw0/$time*8/1000000]"
puts $f1 "$now [expr $bw1/$time*8/1000000]"
puts $f2 "$now [expr $bw2/$time*8/1000000]"
#Reset the bytes_ values on the traffic sinks
$sink0 set bytes_ 0
$sink1 set bytes_ 0
$sink2 set bytes_ 0
#Re-schedule the procedure
$ns at [expr $now+$time] "record"
}proc create-trace {} {
global ns opt
if [file exists $opt(tr)] {
catch "exec rm -f $opt(tr) $opt(tr)-bw [glob $opt(tr).*]"
}
set trfd [open $opt(tr) w]
$ns trace-all $trfd
if {$opt(namtr) != ""} {
$ns namtrace-all [open $opt(namtr) w]
}
return $trfd
}
#Configure lan
proc create-topology {} {
global ns opt
global lan node source node(0) node(1) node(2)
set num $opt(node)
for {set i 0} {$i < $num} {incr i} {
set node($i) [$ns node]
lappend nodelist $node($i)
}
set lan [$ns newLan $nodelist $opt(bw) $opt(delay) \
-llType $opt(ll) -ifqType $opt(ifq) \
-macType $opt(mac) -chanType $opt(chan)]
}
##MAIN##
set ns [new Simulator]
set trfd [create-trace]
create-topology
#Create three traffic sinks and attach them to the node n4
set sink0 [new Agent/LossMonitor]
set sink1 [new Agent/LossMonitor]
set sink2 [new Agent/LossMonitor]
$ns attach-agent $node(7) $sink0
$ns attach-agent $node(7) $sink1
$ns attach-agent $node(7) $sink2
#Create three traffic sources
set source0 [attach-expoo-traffic $node(0) $sink0 200 2s 1s 100k]
set source1 [attach-expoo-traffic $node(1) $sink1 200 2s 1s 200k]
set source2 [attach-expoo-traffic $node(2) $sink2 200 2s 1s 300k]
#Start logging the received bandwidth
$ns at 0.0 "record"
#Start the traffic sources
$ns at 10.0 "$source0 start"
$ns at 10.0 "$source1 start"
$ns at 10.0 "$source2 start"
#Stop the traffic sources
$ns at 50.0 "$source0 stop"
$ns at 50.0 "$source1 stop"
$ns at 50.0 "$source2 stop"
#Call the finish procedure after 60 seconds simulation time
$ns at 60.0 "finish"
#Run the simulation
$ns run
I simulated this source...
This source's base topology is LAN and it's mac is 802_3.
But packet transmitted at same time and not occured collision..
I know 803_3 is csma/cd protocol... isn't is?Please help me!!
--
****************************
Chungnam national University
Computer Communications Lab.
Kisoon Sung
[email protected]
+82-42-821-7792
****************************