1、网络仿真与NS仿真器,王文鼐 email: Addr:科研楼1613 Tel:83492617,讲课内容,参考资料 Chap0. 概论,参考资料,www.wintersim.org www.isi.edu/nsnam/ns 以读源码为主,课程内容,第一章 离散事件仿真 第二章 网络模型与仿真模型 第三章 NS2初步 第四章 TCP仿真及NS2对象结构 第五章 以太网仿真及基本扩展方法 第六章 网络拓扑和业务源模型 第七章 路由仿真及组播和MPLS模块 第八章 应用层协议及NS2扩展 第九章 无线网络与移动IP 第十章 QoS仿真和实时性仿真,第0章 概论,基本术语、过程和原理 仿真方法
2、网络仿真工具 有效性验证 基本步骤和方法,simulation,仿真是指按事物的规律进行仿制或假造。 仿真计算,就是先对目标系统建立近似性的数学表示,再通过物理的模型系统或者专用的或者通用的计算程序,重现目标系统的行为。 “Network simulation” 985,000 条Web URL (谷歌, 2002.2.9) 39,200,200 (2006.9.22) 589,000(2007.9.27), 266,000(2008.10.10) ns2.1b5a发展到ns2.33 ns3正在计划中,0.1 术语 http:/D 仿真时间:目标域中事件发生的时间 仿真钟:记录仿真时间的实体(
3、变量) 因果关系:仿真事件的先后次序,表示时间的单向性,Simulation/Virtual Clock,Real/Wall Clock,典型应用,目标系统通常包含不能或不易直接观察的对象和部件 核反应及其控制 天气及气候预测 通信系统 通信网系统:端到端通信连接及其控制过程 目标系统可以非常直观地得到呈现、重现,而其实验成本相比几乎可以忽略,0.1 术语 典型应用,近代仿真技术起源,MIT的Jay Forrester受ENIAC的启发,研制出性能更高、实用性更强的名为whirlwind的电子计算机,用于雷达目标识别训练和飞行器模拟。 军事训练和环境一直是仿真计算最重要、最前沿的领域。,0.1
4、 术语 简要历程,仿真飞行器,典型处理过程,由大气环境、飞行状态和飞行员操作所构成的动态系统,在一定近似条件下,可用多组动力学方程来描述。将飞行器仿真归结为动力学方程的求解,这个过程就是仿真建模。 采用计算机来执行仿真计算,就是设计并编写仿真计算程序。 将仿真计算结果与实际系统进行对照,以观察仿真的逼真度,是判断整套仿真系统可用性的必须步骤。,过程框图,建模、程序开发、验证,现实系统,数学模型,仿真程序,数学建模,仿真编程,计算模型,数据建模,结果验证与应用,路由器及其功能,协议功能 分组存储转发 网络接口协议,0.1 术语 路由器仿真示例,网络接口,网络层,运输层,应用层,网络接口,网络层,
5、网络接口,网络层,网络接口,网络层,运输层,应用层,路由器,0.1 术语 路由器仿真示例,影响分组转发性能的因素,路由表查找时间(通常忽略!) 端口发送时间 排队等待时间 排队缓冲区的大小 缓冲区的调度,影响业务性能的因素,网络拓扑及组织体制 业务控制与业务流控制 业务发展的中长期不平衡 非典型性因素,Queuing Theory,图形表示 顾客到达和离去 缓冲区 服务员,0.1 术语 排队机模型,顾客到达,顾客离去,N,Kendall notation,形式化表示 A/B/C/D/E/F A/S/s/c/p/D,A:顾客到达(Arrival)的时间间隔分布, B:服务(Service)时长的
6、分布, C:服务员(server)的数目, D:排队机的容量(capacity), E:顾客总数(population), F:队列调度规则(Discipline)。,排队机计算模型,Ai, 顾客达到时间 Di, 被丢弃的时间 Wi, 开始等待时间 Si, 开始接受服务的时间 Fi, 服务结束的时间 Li, 顾客离开的时间,ST,仿真计算步骤,仿真钟 因果关系,NS2的仿真模型,采用面向对象的编程方法 提供Tcl/Tk命令行、脚本接口,Node,结点类,负责为到达分组选择出端口或链路; Link,链路类,主要包含排队队列Queue、链路延时Delay; Agent,代理类,负责构造新分组或接收
7、并终结分组; Application,应用类,模拟特定应用触发分组的生成; Simulator,仿真器类,是所有其它计算对象的容器。,D/D/1仿真程序,set ns new Simulatorset n1 $ns nodeset n2 $ns node$ns duplex-link $n1 $n2 1Mb 1ms DropTailset udp new Agent/UDP$ns attach-agent $n1 $udpset cbr new Application/Traffic/CBR$cbr attach-agent $udpset nul new Agent/Null $ns att
8、ach-agent $n2 $nul $ns connect $udp $nul $ns at 0.0 “$cbr start“ $ns at 2.0 “exit 0“ $ns run,典型模块(对象/元件/组件),M/D/1? M/M/1?,Application,Agent,Node,Node,TTLChecker,Queue,Delay,Agent,Link,0.2 仿真方法,系统状态取值 确定的(deterministic) 随机的(stochastic) 系统状态的时变特性 连续时间(continuous time) 离散时间(discrete time) 离散事件(discrete
9、 event) NS2为随机的DES仿真器,与OSI-RM的对应,基于物理波形的仿真 分组级仿真 网络流仿真 网络应用仿真 排队机仿真,network,TCP runs at the “edge”,Fluid Flow for TCP Flows,TCP Congestion Control: window algorithm,Window: can send W packets increase window by one per RTT if no loss decrease window by half on detection of loss,sender,receiver,TCP C
10、ongestion Control: window algorithm,Window: can send W packets increase window by one per RTT if no loss decrease window by half on detection of loss,Active Queue Management:RED,RED: Random Early Detect proposed in 1993 Proactively mark/drop packets in a router queue probabilistically to Prevent ons
11、et of congestion by reacting early Remove synchronization between flows,The RED Mechanism,RED: Marking/dropping based on average queue length x (t),tmin,tmax,pmax,1,2tmax,Marking probability p,Average queue length x,x (t): smoothed, time averaged q (t),Modeling RED: A Single Congested Router,TCP flo
12、w i, prop. delay Ai,AQM router C, p,One bottlenecked AQM router service capacity C (packets/sec) queue length q(t)drop prob. p(t) N TCP flows window sizes Wi (t) round trip timeRi (t) = Ai+q (t)/C throughputs Bi (t) = Wi (t)/Ri (t),System of Differential Equations,Window Size:,Loss arrival rate,Syst
13、em of Differential Equations (cont.),Average queue length:,Where a = averaging parameter of RED(wq)d = sampling interval 1/C,Loss probability:,Where is obtained from the marking profile,Fluid Flow Model for a Network with Multiple Bottle-necks,Scalable with link bandwidth and flow population within
14、each class,Network of M RED queues, K TCP classes, flows in class k,Fixed Stepsize Runge-Kutta Method,0.3 仿真工具,GPSS (General Purpose System Simulator, G. Gordon, IBM,1961) NEST(NEtwork Simulation Testbed, Columbia, 1988) REAL(REalistic And Large, Cornell & UC, 1993) NS1 NS2 OpNet, etc.,I. Stahl. GPSS-40 years of development. Proc.WinterSim2001, May 2001: 577-585,0.4 有效性验证,B.Lee, etal. Advances in Network Simulation. Computer, May 2000: 59-67,802.11 3的节点隐藏效应,R Bagrodia, M Takai. ftp:/pcl.cs.ucla.edu/pub/papers/nist99.pdf,0.5 基本步骤和方法,理解目标系统 制定仿真需求 分解计算功能 制定验证途径 编程并实施 结果统计和总结 报告或发表,