File: ns-diffusion.tcl

package info (click to toggle)
ns2 2.35%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 78,864 kB
  • sloc: cpp: 172,923; tcl: 107,130; perl: 6,391; sh: 6,143; ansic: 5,846; makefile: 818; awk: 525; csh: 355
file content (65 lines) | stat: -rw-r--r-- 1,672 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
# All diffusion related procedures go here

Simulator instproc attach-diffapp { node diffapp } {
    $diffapp dr [$node get-dr]
}

Node instproc get-dr {} {
    $self instvar diffAppAgent_
    if [info exists diffAppAgent_] {
	return $diffAppAgent_
    } else {
	puts "Error: No DiffusionApp agent created for this node!\n" 
	exit 1
    }
}


Node instproc create-diffusionApp-agent { diffFilters } {
    $self instvar gradient_ diffAppAgent_
    
    # first we create diffusion agent
    # if it doesnot exist already
    # do we really need this check, I mean for a given node
    # is create-diffusionApp-agent{} called more than once??
    
    if [info exists diffAppAgent_] {
	puts "diffAppAgent_ exists: $diffAppAgent_"
	return $diffAppAgent_
    }

    # create diffApp agent for this node
    $self set diffAppAgent_ [new Agent/DiffusionApp]
    set da $diffAppAgent_
    set port [get-da-port $da $self]
    $da agent-id $port
    $da node $self
    
    # now setup filters for this node
    if {$diffFilters == ""} {
	puts "Error: No filter defined for diffusion!\n"
	exit 1
    }
    #XXXX FOR NOW
    set n 0
    foreach filtertype [split $diffFilters "/"] {
	if {$filtertype == "GeoRoutingFilter" } continue
	set filter($n) [new Application/DiffApp/$filtertype $da]
	#$self set filtertype_($n) $filter($n)
	$filter($n) start         ;# starts filter
	incr n
    }
    
    #return $da
}


proc get-da-port {da node} {

    # diffusion assumes diffusion-application agent
    # to be attached to non-zero port numbers
    # thus for assigning port 254 to diffAppAgent
    set port [Node set DIFFUSION_APP_PORT]
    $node attach $da $port
    return $port
}