File: em.tcl

package info (click to toggle)
ns2 2.35%2Bdfsg-2.1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 78,780 kB
  • ctags: 27,490
  • sloc: cpp: 172,923; tcl: 107,130; perl: 6,391; sh: 6,143; ansic: 5,846; makefile: 816; awk: 525; csh: 355
file content (63 lines) | stat: -rw-r--r-- 1,485 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# tem.tcl - test emulation
# be careful here, as the tap agents will
# send out whatever they are given
#
set dotrace 1
set stoptime 20.0

set me [exec hostname]
set ns [new Simulator]

if { $dotrace } {
	set allchan [open em-all.tr w]
	$ns trace-all $allchan
	set namchan [open em.nam w]
	$ns namtrace-all $namchan
}

$ns use-scheduler RealTime

set livenet1 [new Network/Pcap/Live]
$livenet1 set promisc_ true

set livenet2 [new Network/Pcap/Live]
$livenet2 set promisc_ true

set nd1 [$livenet1 open] ;# open some appropriate device (devname is optional)
set nd2 [$livenet2 open] ;# open some appropriate device (devname is optional)
puts "ok, got network devices $nd1 and $nd2"

set f1len [$livenet1 filter "icmp and src $me"]
set f2len [$livenet2 filter "icmp and dst $me"]

puts "filter 1 len: $f1len, filter 2 len: $f2len"
puts "link1 address: [$livenet1 linkaddr]"
puts "link2 address: [$livenet2 linkaddr]"

set a1 [new Agent/Tap]
set a2 [new Agent/Tap]
puts "install nets into taps..."
$a1 network $livenet1
#############$a2 network $livenet2

set node0 [$ns node]
set node1 [$ns node]

$ns duplex-link $node0 $node1 8Mb 5ms DropTail
#
# attach-agent sets "target" of the agents to the node entrypoint
$ns attach-agent $node0 $a1
$ns attach-agent $node1 $a2

# let's detach the things
set null [$ns set nullAgent_]
###$a1 target $null
###$a2 target $null

$ns connect $a1 $a2

puts "scheduling termination at t=$stoptime"
$ns at $stoptime "exit 0"

puts "let's rock"
$ns run