tcp/ip network simulation

32
Sungkyunkwan University Sungkyunkwan University Copyright 2006 Convergence Laboratory TCP/IP Network TCP/IP Network Simulation Simulation Jahwan Koo Intelligent HCI Convergence Research Ce nter Sungkyunkwan University [email protected]

Upload: tiva

Post on 31-Jan-2016

108 views

Category:

Documents


0 download

DESCRIPTION

TCP/IP Network Simulation. Jahwan Koo Intelligent HCI Convergence Research Center Sungkyunkwan University [email protected]. Talk Objectives. Appreciate the role of simulation in performance evaluation Understand the steps of simulation methodology Classify various simulation tools - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: TCP/IP Network Simulation

Sungkyunkwan UniversitySungkyunkwan University

Copyright 2006 Convergence Laboratory

TCP/IP Network SimulationTCP/IP Network Simulation

Jahwan KooIntelligent HCI Convergence Research Center

Sungkyunkwan University

[email protected]

Page 2: TCP/IP Network Simulation

Convergence Laboratory 2/32TCP/IP Network Simulation

Talk ObjectivesTalk Objectives

Appreciate the role of simulation in performance evaluation

Understand the steps of simulation methodology

Classify various simulation tools

Become familiar with popular simulation tools

Page 3: TCP/IP Network Simulation

Convergence Laboratory 3/32TCP/IP Network Simulation

How are you doing research?How are you doing research?

Research

To study (something) thoroughly so as to present in a detailed, accurate mannerTo study (something) thoroughly so as to present in a detailed, accurate manner

MathematicalMathematical ExperimentalExperimental SimulationSimulation DevelopmentDevelopment

MethodologyMethodology

Basic ConceptsBasic Concepts

Case StudyCase Study

Page 4: TCP/IP Network Simulation

Convergence Laboratory 4/32TCP/IP Network Simulation

Simulation?Simulation?

Robert.E Shannon, “Introduction to the art and science of simulation”

the process of designing a model of a real system and conducting experimen

ts with this model for the purpose of understanding the behavior of the syste

m and /or evaluating various strategies for the operation of the system

Advantages

Describe the behavior of a system

Use the model to predict future behavior, i.e. the effects that will be produce

d by changes in the system or in its method of operation

Page 5: TCP/IP Network Simulation

Convergence Laboratory 5/32TCP/IP Network Simulation

Simulation MethodologySimulation Methodology

Page 6: TCP/IP Network Simulation

Convergence Laboratory 6/32TCP/IP Network Simulation

ClassificationClassification General-purpose programming languages (GPPL) “Plain” simulation languages (PSL) Simulation packages (SP)

Page 7: TCP/IP Network Simulation

Convergence Laboratory 7/32TCP/IP Network Simulation

Advantages & DisadvantagesAdvantages & Disadvantages GPPLs

Advantages Available in almost all computer systems & platforms Almost all researchers know at least one GPPL very well Provide total control over the software development process

Disadvantages Lack of support for a discrete-event simulation

• Spend considerable time and effort writing routines for event handling & random number generation

Model constructions take a very long time PSLs

Advantages Basic support for a discrete-event simulation

Disadvantages Not available in all computer systems & platforms The need of programming expertise in a new language Lack of built-in libraries for TCP/IP networks

SPs Advantages

Highest level of simulation tools Basic support for a discrete-event simulation Built-in libraries for TCP/IP networks

Page 8: TCP/IP Network Simulation

Convergence Laboratory 8/32TCP/IP Network Simulation

NS HistoryNS History 1989: REAL network simulator

1995: DARPA VINT project at LBL, Xerox PARC, UCB, and USC/ISI

Present: DARPA SAMAN project and NSF CONSER project Collaboration with other researchers including CIRI

Page 9: TCP/IP Network Simulation

Convergence Laboratory 9/32TCP/IP Network Simulation

NS StatusNS Status Periodical release (ns-2.1b9a, July 2002)

~200K LOC in C++ and Otcl,

~100 test suites and 100+ examples

371 pages of ns manual

Daily snapshot (with auto-validation)

Stability validation http://www.isi.edu/nsnam/ns/ns-tests.html

Platform support FreeBSD, Linux, Solaris, Windows and Mac

User base > 1k institutes (50 countries), >10k users

About 300 posts to [email protected] every month

Page 10: TCP/IP Network Simulation

Convergence Laboratory 10/32TCP/IP Network Simulation

NS FunctionalitiesNS Functionalities Wired world

Routing DV, LS, PIM-SM

Transportation: TCP and UDP

Traffic sources:web, ftp, telnet, cbr, stochastic

Queuing disciplines:drop-tail, RED, FQ, SFQ, DRR

QoS: IntServ and Diffserv

Emulation

Wireless

Ad hoc routing and mobile IP

Directed diffusion, sensor-MAC

Tracing, visualization, various utilities

Page 11: TCP/IP Network Simulation

Convergence Laboratory 11/32TCP/IP Network Simulation

NS ComponentsNS Components Ns, the simulator itself

Nam, the network animator

Visualize ns (or other) output

Nam editor: GUI interface to generate ns scripts

Pre-processing:

Traffic and topology generators

Post-processing:

Simple trace analysis, often in Awk, Perl, or Tcl

Page 12: TCP/IP Network Simulation

Convergence Laboratory 12/32TCP/IP Network Simulation

NS ModelsNS Models Traffic models and applications:

Web, FTP, telnet, constant-bit rate, real audio

Transport protocols:

unicast: TCP (Reno, Vegas, etc.), UDP

Multicast: SRM

Routing and queuing:

Wired routing, ad hoc rtg and directed diffusion

queuing protocols: RED, drop-tail, etc

Physical media:

Wired (point-to-point, LANs), wireless (multiple propagation models), satellite

Page 13: TCP/IP Network Simulation

Convergence Laboratory 13/32TCP/IP Network Simulation

NS ResourcesNS Resources Ns Homepage

http://www.isi.edu/nsnam/ns/

Ns and nam build questions

http://www.isi.edu/nsnam/ns/ns-build.html

Ns mailing list: [email protected]

Ns manual and tutorial (in distribution)

TCL: http://dev.scriptics.com/scripting

Otcl tutorial (in distribution): ftp://ftp.tns.lcs.mit.edu/pub/otcl/doc/tutorial.ht

ml

Page 14: TCP/IP Network Simulation

Convergence Laboratory 14/32TCP/IP Network Simulation

Study Guidelines-1Study Guidelines-1

Basic ConceptBasic Concept

CommandsCommands

ShellShell

InstallationInstallation

ManagementManagement

C Fundamental

C Fundamental

Unix System Programming

Unix System Programming C++

FundamentalC++

Fundamental

Unix Linux Windows

Guidelines & Activities

Main TopicsMain Topics

Network ConceptNetwork Concept

NS-2NS-2

* *

Technical PaperTechnical Paper PresentationPresentation

#1

#2

#3

#5

#4

#7 #8

#6

Page 15: TCP/IP Network Simulation

Convergence Laboratory 15/32TCP/IP Network Simulation

Study Guidelines-2Study Guidelines-2Step 1) Prepare a Linux Machine and Install Redhat Linux Operating System

http://www.redhat.com

Step 2) Download NS All-in-One version(2.29.tar.gz) and Install it on your machine http://www.isi.edu/nsnam/ns/ns-tests.html

Step 3) Practice step-by-step Examples http://perform.wpi.edu/NS/index.html

Step 4) Read numerous technical papers, understand network concepts, and select

main topics or problems Related papers using NS-2

Step 5) Execute modeling and simulation By Simulation Methodology

Use a simulation language like Otcl, C++

Use graph and chart drawing tools such as gnuplot, excel, MatLab

Page 16: TCP/IP Network Simulation

Convergence Laboratory 16/32TCP/IP Network Simulation

OverviewOverview

Developed by UCB/LBNL/VINT groups (http://www.isi.edu/nsnam/ns/)

Very popular software

Object-oriented simulator Represents Network components & network characteristics

by various classes

Written in C++ & object-oriented tcl (Otcl) scripts

Page 17: TCP/IP Network Simulation

Convergence Laboratory 17/32TCP/IP Network Simulation

Model Construction & Parameter SettingModel Construction & Parameter Setting A network model in ns is constructed by interconnecting

several components, called ns object. Built from a hierarchical C++ class structure http://www.isi.edu/nsnam/nsdoc-classes/index.html

Page 18: TCP/IP Network Simulation

Convergence Laboratory 18/32TCP/IP Network Simulation

NsObjectNsObject NsObject

Base class for all derived classes Methods

handle method to handle events recv method to process received packets

Connector Derive to links related objects (Queue, Delay) and nodes related

objects (Agents) Trace

Used to collect data about packets in the network during the simulation

Classifier Examines packets & forward them to the appropriate destination

By passing the packet object to the recv method of the object Unicast address classifier Multicast address classifier Replicator

Page 19: TCP/IP Network Simulation

Convergence Laboratory 19/32TCP/IP Network Simulation

Major Objects-1Major Objects-1 Nodes

Represent clients, hosts, routers, or switches A node s1 can be created as follows:

set s1 [$ns node] Classifiers

Determine the outgoing interface object Address Classifiers : support unicast packet forwarding Multicast Classifiers : classify packets based on both source and destination

group address Multipath Classifiers : support equal cost multipath forwarding Replicators : deliver copies of the same packet to multiple receivers

Links Used to connect nodes to form a network topology Support for a variety of links

$ns <link-type> <n1> <n2> <bandwidth> <delay> <queue-type> link-type : simplex-link, duplex-link, or duplex-intserv-link queue-type : DropTail, Fair Queueing (FQ), Stochastic Fair Queuing (SFQ), Deficit

Round Robin scheduling (DRR), Random Early Detection (RED), or Class Based Queuing (CBQ)

Example$ns duplex-link $s1 $r1 8Mb 5ms DropTail

Page 20: TCP/IP Network Simulation

Convergence Laboratory 20/32TCP/IP Network Simulation

Major Objects-2Major Objects-2 Agents

Have several fields to construct the appropriate packet Source address, destination address, packet size, IP flow identifier, IP priority,

flags, time to live Can be set using the set command

Attached to a node using the attach-agent command UDP agents

Commonly use when rate-based traffic generators (CBR or Pareto) are used at the application level.

set udp_agent [new Agent/UDP]$ns attach-agent <node> $udp_agent$udp_agent set <field> <field-value>

TCP agents Create

set tcp_agent [new Agent/<tcp-agent-type>] connect between two agents

$ns connect <source agent> <destination agent> Parameters

•Window settings (window_), ECN bit (ecn_), timer granularity (tcpTick_), congestion window, ssthresh setting.

$tcp_agent set window_ 15$tcp_agent set ecn_ 1

Page 21: TCP/IP Network Simulation

Convergence Laboratory 21/32TCP/IP Network Simulation

Major Objects-3Major Objects-3 Applications

Produce data on top of the transport layer (UDP or TCP)

Attached to the transport end points by the attach-agent command

Start (stop) sending data at specified times using the start (stop) command

Main application supported by ns FTP, Telnet, WWW, etc

Example) a TCP agent is used as the transport layer and an FTP application runs on top of it.

set tcp_agent [new Agent/TCP]

$ns attach-agent $source $tcp_agent

set ftp_app [new Application/FTP]

$ftp_app attach-agent $tcp_agent

$ns at 10.0 “$ftp_app start”

$ns at 20.0 “$ftp_app stop”

Page 22: TCP/IP Network Simulation

Convergence Laboratory 22/32TCP/IP Network Simulation

Major Objects-4Major Objects-4 Traffic Generators

Automate generation of traffic according to a desired pattern & load

Exponential ON-OFF Generate packets at a fixed rate during the ON periods, while no packets are sent

during the OFF periods.

Exponential distribution

Size of packets being generated, average ON time, average OFF time, and sending rate

set expapp [new Application/Traffic/Exponential]

$expapp set packetsize_ 1000

$expapp set rate_ 500k

$expapp set burst_time_ 100ms

$expapp set idle_time_ 30ms

Pareto ON-OFF Pareto distribution

Self-similar traffic can be generated by aggregating several Pareto ON-OFF sources

The shape of the pareto distribution can be set as follows:

set parapp [new Application/Traffic/Pareto]

$parapp set shape 1.0

Page 23: TCP/IP Network Simulation

Convergence Laboratory 23/32TCP/IP Network Simulation

Major Objects-5Major Objects-5 Traffic Generators

Constant Bit Rate (CBR)

Generates packets at a constant rate

Random noise can be introduced to vary the time between sending of packets

Constant packet sizes

Sending rate, interval between packets, size of packets, a flag to specify

introduction of random noise, maximum number of packets that can be sent

set cbrapp [new Application/Traffic/CBR]

$cbrapp set maxpkts_ 10000

$cbrapp set packetsize_ 5000

$cbrapp set rate_ 16kb

$cbrapp set interval_ 1ms

$cbrapp set random 1

Page 24: TCP/IP Network Simulation

Convergence Laboratory 24/32TCP/IP Network Simulation

Data Collection-1Data Collection-1 Tracing

Records each packets as it arrives at a node, departs a node, or is dropped at a link or queue.

Useful in debugging or verification of the simulation code To collect the trace record of every packet

$ns trace-all <tracefile> Structure of trace files

Example

Event Type : enqueue (+), dequeue (-), drop (d), receive (r) Src, Dst addr : “node.port”

Page 25: TCP/IP Network Simulation

Convergence Laboratory 25/32TCP/IP Network Simulation

Data Collection-2Data Collection-2 Monitoring

Monitor counts, such as number of packets dropped, for all traffic in the

network, for specific links, or for specific flows

Monitoring objects are inserted into the network topology at specific

places.

To create a trace object between a src and a dest node

$ns create-trace <type> <tracefile> <src> <dest>

type Enqueue, Deque, Drop, or Recv

To add a trace agent to trace the TCP congestion window variable

$ns add-agent-trace $tcp_agent tcp_agent

$ns monitor-agent-trace $tcp_agent

$tcp_agent tracevar cwnd_

Page 26: TCP/IP Network Simulation

Convergence Laboratory 26/32TCP/IP Network Simulation

Simulation ExecutionSimulation Execution

An object of class Simulator must be created as follow:

set ns [new Simulator]

To start an application at a specified time

$ns at <time> “<command>”

Example) An FTP source can be started at time 0.0

$ns at 0.0 “$ftp_app atart”

To terminate ns

by calling the finish procedure

$ns at 2.0 “finish”

To execute ns

$ns run

Page 27: TCP/IP Network Simulation

Convergence Laboratory 27/32TCP/IP Network Simulation

nsns Examples-1 Examples-1 A Simple Network Topology

Page 28: TCP/IP Network Simulation

Convergence Laboratory 28/32TCP/IP Network Simulation

nsns Examples-2 Examples-2 Evaluating TCP Performance

Step 1: Design Network Model

Step 2 : Select Performance Metrics Observe the throughput of the FTP connection

Monitor the rate of sequence number increase over time

Step 3 : Select Variables Buffer size at R1 to examine the effect of buffer size on the TCP throughput

Step 4 : Construct Model & Set Parameters Create the four nodes

Connect nodes with link

Create TCP source & sink agent

Connect source to sink

Attach FTP application to TCP transport protocol

Page 29: TCP/IP Network Simulation

Convergence Laboratory 29/32TCP/IP Network Simulation

nsns Examples-2 (Con’t) Examples-2 (Con’t) Step 4 : Construct Model & Set Parameters (Cont’)

Create the four nodesset n0 [$ns node]set R1 [$ns node]set R2 [$ns node]set n1 [$ns node]

Connect nodes with link$ns duplex-link $n0 $R1 10Mb 1ms DropTail$ns duplex-link $R1 $R2 1Mb 3ms DropTail$ns duplex-link $R2 $n1 10Mb 1ms DropTail

Create TCP source & sink agentset tcp0 [new Agent/TCP]$ns attach-agent $n0 $tcp0set tcpsink0 [new Agent/TCPSink]$ns attach-agent $n1 $tcpsink0

Connect source to sink$ns connect $tcp0 $tcpsink0

Attach FTP application to TCP transport protocolset ftp0 [new Application/FTP]$ftp0 attach-agent $tcp0

Page 30: TCP/IP Network Simulation

Convergence Laboratory 30/32TCP/IP Network Simulation

nsns Examples-2 (Con’t) Examples-2 (Con’t) Step 5 : Data Collection

Use tracing for collecting the sequence numbers

$ns trace-all [open out.tr w]

Use monitoring for collecting the throughput data

#Define “bytes_” in TCP sink agent (tcp-sink.cc) void TcpSink::recv(Packet* pkt, Handler*){... Some line beforebytes_ += hdr_cmn::access(pkt) -> size();Double now = Scheduler::instance().clock();... Some line after}

#Bind variables in agent’s constructorTcpAgent::TcpAgent() : Agent(PT_TCP), ...{... Some line beforebind(“seqno_”, &seqno_);... Some line after}

TcpSink::TcpSink(Acker* acker) : Agent(PT_ACK), acker_(acker), save_(NULL)

{... Some line beforebind(“bytes_”, &bytes_);... Some line after}

Page 31: TCP/IP Network Simulation

Convergence Laboratory 31/32TCP/IP Network Simulation

nsns Examples-2 (Con’t) Examples-2 (Con’t)#Initialize variables in ns-default.tcl to be linked to OTclAgent/TCP set seqno_ 0

Agent/TCPSink set bytes_ 0

#Open output file for writing dataset f1 [open seq.dat w]

set f2 [open thruput.dat w]

set f3 [open delay.dat w]

#Call output variable in Tcl and write data to output fileset seq [$tcp0 set seqno_]

set bw [$tcpsink0 set bytes_]

set delay [$tcpsink0 set e2e_delay_]

puts $f1 “$now $seq”

puts $f2 “$now [expr $bw/$time*8/1000]”

puts $f3 “$now [expr $delay*1000]”

#Recompile ns

Page 32: TCP/IP Network Simulation

Convergence Laboratory 32/32TCP/IP Network Simulation

nsns Examples-2 (Con’t) Examples-2 (Con’t) Step 6 : Simulation Execution

#Set simulation time, run FTP sources for 10 seconds

$ns at 0.0 “$ftp0 start”

$ns at 10.0 “$ftp0 stop”

$ns at 0.0 “record”

$ns at 10.0 “finish”

$ns run

Step 7 : Presentation & Analysis of Simulation Results

exec awk {

{

if (($1 == “r”) && ($4 == “0”) && ($5 == “ack”))

print $2, $11

}

} out.tr > datafile