File: ns-emulate.tcl

package info (click to toggle)
ns2 2.35%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 78,120 kB
  • sloc: cpp: 172,923; tcl: 107,127; perl: 6,391; sh: 6,143; ansic: 5,846; makefile: 812; awk: 525; csh: 355
file content (52 lines) | stat: -rw-r--r-- 1,239 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
#
# ns-emulate.tcl
#	defaults for nse [ns with emulation support]
#
if [TclObject is-class Network/Pcap/Live] {
	Network/Pcap/Live set snaplen_ 4096;# bpf snap len
	Network/Pcap/Live set promisc_ false;
	Network/Pcap/Live set timeout_ 0
	Network/Pcap/Live set optimize_ true;# bpf code optimizer
	Network/Pcap/Live set offset_ 0.0; # 

	Network/Pcap/File set offset_ 0.0; # ts for 1st pkt in trace file
}

if [TclObject is-class Agent/Tap] {
    Agent/Tap set maxpkt_ 1600
}

if [TclObject is-class Agent/TCPTap] {
    Agent/TCPTap set maxpkt_ 1600
}

if [TclObject is-class Agent/IcmpAgent] {
    Agent/IcmpAgent set ttl_ 254
}

if [TclObject is-class Agent/IPTap] {
    Agent/IPTap set maxpkt_ 1600
}

if [TclObject is-class ArpAgent] {

	ArpAgent set cachesize_ 10; # entries in arp cache
	ArpAgent instproc init {} {
		$self next
	}

	ArpAgent instproc config ifname {
		$self instvar net_ myether_ myip_
		set net_ [new Network/Pcap/Live]
		$net_ open readwrite $ifname
		set myether_ [$net_ linkaddr]
		set myip_ [$net_ netaddr]
		$net_ filter "arp and (not ether src $myether_) and \
			(ether dst $myether_ \
			or ether dst ff:ff:ff:ff:ff:ff)"
		$self cmd network $net_
		$self cmd myether $myether_
		$self cmd myip $myip_
	}
}