example.ns 898 Bytes
Newer Older
1
2
3
# This NS file shows how to use loops to set a topology.  This topology is a 
# degree 3/depth 3 tree.

Christopher Alfeld's avatar
Christopher Alfeld committed
4
source tb_compat.tcl
5
6
7
8
9
10
11
12

set ns [new Simulator]

set center_node [$ns node]

for {set group 0} {$group < 3} {incr group} {
    set nodes(node-$group) [$ns node]
    $ns duplex-link $nodes(node-$group) $center_node 100Mb 1ms DropTail
Christopher Alfeld's avatar
Christopher Alfeld committed
13
14
    tb-set-ip-interface $center_node $nodes(node-$group) 192.0.$group.1
    tb-set-ip-interface $nodes(node-$group) $center_node 192.0.$group.2
15
16
17
    for {set member 0} {$member < 3} {incr member} {
	set nodes(node-$group-$member) [$ns node]
	$ns duplex-link $nodes(node-$group-$member) $nodes(node-$group) \
Christopher Alfeld's avatar
Christopher Alfeld committed
18
19
20
21
22
		100Mb 1ms DropTail
	tb-set-ip-interface $nodes(node-$group) $nodes(node-$group-$member) \
		192.0.[expr 10*($group+1)+$member].1
	tb-set-ip-interface $nodes(node-$group-$member) $nodes(node-$group) \
		192.0.[expr 10*($group+1)+$member].2
23
24
25
26
    }
}

$ns run