-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.tcl
More file actions
executable file
·93 lines (78 loc) · 3.08 KB
/
utils.tcl
File metadata and controls
executable file
·93 lines (78 loc) · 3.08 KB
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
# Copyright (C) 2001-2006 Sergio Andreozzi
#
# This file is part of DiffServ4NS, a set of improvements to
# the Network Simulator 2 for DiffServ simulations.
#
# Project page: http://diffserv4ns.sourceforge.net/
#
# DiffServ4NS is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# DiffServ4NS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with DiffServ4NS; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# GNU License: http://www.gnu.org/licenses/gpl.txt
# SourceId : source agent index
# SinkId : sink agent index
# src : source node
# dst : destination node
# flowId : flow Id used by LossMonitor to compute parameters as OWD and IPDV
# PacketSize : UDP packet size (in bytes)
# Rate :
# Start :
# Stop :
proc cbr_connection {SourceId SinkId src dst flowId PacketSize Rate start stop} {
global ns Sink_
set udp_($SourceId) [new Agent/UDP]
$udp_($SourceId) set class_ $flowId
$ns attach-agent $src $udp_($SourceId)
set cbr_($SourceId) [new Application/Traffic/CBR]
$cbr_($SourceId) attach-agent $udp_($SourceId)
$cbr_($SourceId) set packet_size_ $PacketSize
$udp_($SourceId) set packetSize_ $PacketSize
$cbr_($SourceId) set rate_ $Rate
if {($flowId == 1)} {
set Sink_($SinkId) [new Agent/LossMonitor]
$Sink_($SinkId) set flowid_ $flowId
} else {
set Sink_($SinkId) [new Agent/Null]
}
$ns attach-agent $dst $Sink_($SinkId)
$ns connect $udp_($SourceId) $Sink_($SinkId)
$ns at $start "$cbr_($SourceId) start"
$ns at $stop "$cbr_($SourceId) stop"
}
proc telnet_connection {id src dst inter start} {
global ns
set tcp_($id) [new Agent/TCP]
$tcp_($id) set class_ 2
# $tcp_($id) set packetSize_ 1500
set sink_($id) [new Agent/TCPSink]
$ns attach-agent $src $tcp_($id)
$ns attach-agent $dst $sink_($id)
set telnet_($id) [new Application/Telnet]
$telnet_($id) attach-agent $tcp_($id)
$telnet_($id) set interval $inter
$ns connect $tcp_($id) $sink_($id)
$ns at $start "$telnet_($id) start"
}
proc ftp_connection {id src dst start} {
global ns
set tcp_($id) [new Agent/TCP]
$tcp_($id) set class_ 2
# $tcp_($id) set packetSize_ 1500
$ns attach-agent $src $tcp_($id)
set ftp_($id) [new Application/FTP]
$ftp_($id) attach-agent $tcp_($id)
set sink_($id) [new Agent/TCPSink]
$ns attach-agent $dst $sink_($id)
$ns connect $tcp_($id) $sink_($id)
$ns at $start "$ftp_($id) start"
}