File: simple.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 (83 lines) | stat: -rw-r--r-- 2,105 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
#
# Example code for running a congestion control module with TCP-Linux
#
# TCP-Linux module for NS2 
#
# Nov 2007
#
# Author: Xiaoliang (David) Wei  (DavidWei@acm.org)
#
# NetLab, the California Institute of Technology 
# http://netlab.caltech.edu
#
# See a mini-tutorial about TCP-Linux at: http://netlab.caltech.edu/projects/ns2tcplinux/
#
#
# Module: tcl/ex/tcp-linux/simple.tcl
#    This is an example on how to run a congestion control algorithm with TCP-Linux. 
# This code uses Highspeed TCP as an example and demonstrates a minimum setup for running TCP-Linux.
#
# The code simulates the scenario in which a single Highspeed TCP flow running through a bottleneck.

#    The code outputs:
# queue_simple.trace: the queue length over time in the format of <time> <queue len>
# p_simple: the connection variables over time in format specified in sampling.tcl
#
#
# After the simulation, run
#    gnuplot gnuplot_simple.script 
# to generate figures on cwnd trajectory and queue trajectory.
#

#Create a simulator object
set ns [new Simulator]

#Create two nodes and a link
set bs [$ns node]
set br [$ns node]
$ns duplex-link $bs $br 100Mb 10ms DropTail

#setup sender side	
set tcp [new Agent/TCP/Linux]
$tcp set timestamps_ true
$tcp set window_ 100000
#$tcp set windowOption_ 8
$ns attach-agent $bs $tcp

#set up receiver side
set sink [new Agent/TCPSink/Sack1]
$sink set ts_echo_rfc1323_ true
$ns attach-agent $br $sink

#logical connection
$ns connect $tcp $sink

#Setup a FTP over TCP connection
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP

$ns at 0 "$tcp select_ca highspeed"

#Start FTP 
$ns at 0 "$ftp start"
$ns at 10 "$ftp stop"
$ns at 11 "exit 0"

set MonitorInterval 0.1
set qmonfile [open "queue.trace" "w"]
close $qmonfile
set qmon [$ns monitor-queue $bs $br "" $MonitorInterval]
source "sampling.tcl"
proc monitor {interval} {
    global ns tcp qmon
    set nowtime [$ns now]
    monitor_tcp $ns $tcp p_simple.trace
    monitor_queue $ns $qmon queue_simple.trace
    $ns after $interval "monitor $interval"
}
$ns at 0 "monitor $MonitorInterval"


$ns run