File: agent-gen-script.tcl

package info (click to toggle)
ns2 2.35%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 78,796 kB
  • sloc: cpp: 172,923; tcl: 107,130; perl: 6,391; sh: 6,143; ansic: 5,846; makefile: 816; awk: 525; csh: 355
file content (112 lines) | stat: -rw-r--r-- 3,425 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# This file is an example script for using the topology generator,
# the routing generator and the agents generator together as part
# of the scenario generator
# Created by Ahmed Helmy, June 98.

# source the generators code (this is not part of the release yet)
source topo-gen.tcl
source agent-gen.tcl
source route-gen.tcl

# setup the files that will contain the scripts generated
set topofile topo1.tcl
set agentfile agent1.tcl
set routefile route1.tcl

set hier_flag 1

# we remove the agentfile, to start afresh... the agentfile is
# opened in append mode and previous runs may cause problems
if { [file exists $agentfile] } {
	catch { [exec rm $agentfile] }
}

# generate the topology creation script
#puts {topology -outfile $topofile -num 50 -connection_prob 0.1}
#topology -outfile $topofile -nodes 15 -connection_prob 0.1

puts {topology -outfile $topofile -type transit_stub -nodes 50 -connection_prob 0.1}
topology -outfile $topofile -type transit_stub -nodes 50 -connection_prob 0.1

# set the route settings for unicast/mcast
puts {routing -outfile $routefile -unicast Session -multicast CtrMcast}
routing -outfile $routefile -unicast Session -multicast CtrMcast

# generate the agent creation script
# note that src and dest stub location info (for distribution of src and dest nodes)
# should be given only when topology generated is of type transit-stub

puts {agents -outfile $agentfile -transport TCP/Reno -src FTP \
	-sink TCPSink/DelAck -num 60% -srcstub 1-4,8,10 -deststub 5-7,9,11,12 -start 1-3 -stop 9-11}
agents -outfile $agentfile -transport TCP/Reno -src FTP \
    -sink TCPSink/DelAck -num 60% -srcstub 1-4,8,10 -deststub 5-7,9,11,12 -start 1-3 -stop 9-11

#puts {agents -outfile $agentfile -transport TCP -sink TCPSink -num 8}
#agents -outfile $agentfile -transport TCP -sink TCPSink -num 8

#puts {agents -outfile $agentfile -transport SRM/Deterministic -num 75% \
	-join 0-2 -src CBR/UDP -traffic Pareto -srcnum 20% \
	-start 3-10}
#agents -outfile $agentfile -transport SRM/Deterministic -num 75% \
	-join 0-2 -src CBR/UDP -traffic Pareto -srcnum 20% \
	-start 3-10 

#puts {agents -outfile $agentfile -transport SRM -src CBR/UDP \
	-traffic Expoo }
#agents -outfile $agentfile -transport SRM -src CBR/UDP \
	-traffic Expoo

mark-end $agentfile
# the marker merely serves as debugging aid to make sure that
# all the code was written to file, and was not disrupted due
# to failure or disk full... etc, it also contains all the 
# the command lines used to generate the code.

# now that we've generated the tcl scripts, source them and call
# the procs to start the simulations.
source $routefile
source $topofile
source $agentfile

set ns [new Simulator]

# set up hierarchical routing (if needed) or any other address format
#$ns set-address-format hierarchical

# comment out the ns trace for now... it consumes a lot of mem
# set f [open out.tr w]
# $ns trace-all $f
set nf [open out.nam w]
$ns namtrace-all $nf

# have to call these before the topology is generated, as
# artifact of current ns !!!
setup-mcastNaddr ns

# call the topology script
if {$hier_flag} {
	create-hier-topology ns node 1.5Mb
} else {
	create-topology ns node 1.5Mb
}

# set routing
create-routing ns

# call the agent script
generate-agents ns node

$ns at 3.0 "finish"

proc finish {} {
	global ns nf; #f
	$ns flush-trace
	# close $f
	close $nf

	puts "running nam..."
	exec nam out.nam &
	exit 0
}

$ns run