A Sample TCL - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

A Sample TCL

Description:

A Sample TCL – PowerPoint PPT presentation

Number of Views:413
Avg rating:3.0/5.0
Slides: 19
Provided by: ming3
Category:
Tags: tcl | cw | sample

less

Transcript and Presenter's Notes

Title: A Sample TCL


1
A Sample TCL
  • July 20, 2005

2
  • Create a simulator object
  • set ns new Simulator
  • ns use-newtrace
  • Open the ns trace file
  • set nf open out.ns w
  • ns trace-all nf
  • set thru(0) open thru0.tr w
  • set thru(1) open thru1.tr w
  • set cw open cw.tr w
  • set val(stop) 200 time of simulation end
  • set val(nn) 8 number of nodes
  • proc stop
  • global ns nf thru cw
  • ns flush-trace
  • close nf
  • close thru(0)

3
  • Create 8 nodes
  • for set i 0 i lt val(nn) incr i
  • set n(i) ns node
  • Create a duplex link between the nodes
  • ns duplex-link n(0) n(2) 100Mb 10ms DropTail
  • ns duplex-link n(2) n(4) 100Mb 10ms DropTail
  • ns duplex-link n(1) n(3) 100Mb 10ms DropTail
  • ns duplex-link n(3) n(4) 100Mb 10ms DropTail
  • ns duplex-link n(4) n(5) 1Mb 10ms DropTail
  • ns duplex-link n(5) n(6) 100Mb 10ms DropTail
  • ns duplex-link n(5) n(7) 100Mb 10ms DropTail

4
  • Create a TCP agent and attach it to node n0
  • set src_tcp new Agent/TCP/Newreno
  • ns attach-agent n(0) src_tcp
  • set dst_tcp new Agent/TCPSink/DelAck
  • ns attach-agent n(6) dst_tcp
  • ns connect src_tcp dst_tcp
  • src_tcp set maxcwnd_ 32
  • Tahoe new Agent/TCP
  • Reno new Agent/TCP/Reno
  • New reno new Agent/TCP/Newreno
  • Vegas new Agent/TCP/Vegas

5
  • Setup a FTP over TCP connection
  • set ftp new Application/FTP
  • ftp attach-agent src_tcp
  • ftp set packetSize_ 512

6
  • UDP flow between n1 and n7
  • set src_udp new Agent/UDP
  • ns attach-agent n(1) src_udp
  • set dst_udp new Agent/LossMonitor
  • ns attach-agent n(7) dst_udp
  • ns connect src_udp dst_udp

7
  • Setup a CBR over UDP connection
  • set cbr new Application/Traffic/CBR
  • cbr attach-agent src_udp
  • cbr set type_ CBR
  • cbr set packetSize_ 512
  • cbr set rate_ 4Mb
  • 200kbps cbr set rate_ 0.2Mb
  • 400kbps cbr set rate_ 0.4Mb
  • 4Mbps

8
  • printing throughput of each client and channel
    utilization
  • set last_udp 0.0
  • set last_tcp 0.0
  • proc plotThru
  • global ns thru last_udp last_tcp dst_udp
    dst_tcp val
  • set time 1
  • set now ns now
  • set total 0.0
  • set cur_tcp dst_tcp set bytes_
  • set bytesthru expr cur_tcp-last_tcp
  • set bitsthru expr bytesthru8.0/1000000.0/
    time
  • puts thru(0) "format .2f now format
    .2f bitsthru"
  • set total expr totaltemp
  • set cur_udp dst_udp set bytes_
  • set bytesthru expr cur_udp-last_udp

9
  • proc plotCW
  • global ns cw src_tcp val
  • set time 1
  • set now ns now
  • set cwnd src_tcp set cwnd_
  • puts cw "now cwnd"
  • Your work here
  • ns at 0.1 "plotCW"

10
  • proc summary
  • global ns val dst_udp dst_tcp
  • set tcpbytes dct_tcp set bytes_
  • .. (get bytes for udp
  • .. Get ratio between TCP and UDP. (converges
    the nominator to float number by 1.0)
  • average bandwidth for TCP (make sure
    converges it to bits)
  • puts

11
  • ns at 0.0 "ftp start"
  • ns at 0.0 "cbr start"
  • ns at val(stop) "ftp stop"
  • ns at val(stop) "cbr stop"
  • ns at val(stop) "stop"
  • ns at expr val(stop) - 0.01 summary"
  • Run the simulation
  • ns run

12
How to plot the results
  • Trace format
  • Time thru
  • 0.10 0.06
  • 1.10 0.98

13
Gnuplot
  • set ylabel Throughput (Mbps)
  • set xlabel Time
  • set term postscript color
  • Set output thru.eps
  • plot ./thru0.tr using 12 title TCP with
    linespoints 1, ./thru1.tr using 12 title UDP
    with linespoints 2
  • Save it to xxx.plt
  • Excute it using gnuplot xxx.plt

14
(No Transcript)
15
  • set ylabel Congestion Window
  • set xlabel Time
  • set term postscript color
  • set output cw.eps
  • plot ./cw.tr using 12 title Congestion
    Window Size with linespoints 1
  • Save it to xxx.plt
  • Excute it using gnuplot xxx.plt

16
(No Transcript)
17
How to include pics into one page
  • Using Latex
  • \documentclassarticle\usepackagegraphics
    \begindocument\beginfigure \begincenter
    \begintabularcc \resizebox60mm!\
    includegraphicscw.eps
    \resizebox60mm!\includegraphicsthru.eps
    \\ \resizebox60mm!\includegraphicscw.e
    ps \resizebox60mm!\includegraphics
    thru.eps \\ \endtabular \captionThis
    is sample figures. \labeltest4
    \endcenter\endfigure\enddocument
  • Save it to xxx.tex
  • Complie it using latex xxx.tex
  • dvips o xxx.ps
    xxx.dvi

18
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com