ns-2 網路模擬 rung-shiang cheng ( 程榮祥 ) department of computer and communication, kun shan...

58
NS-2 網網網網 Rung-Shiang Cheng ( 程程程 ) Department of Computer and Communication, Kun Shan University [email protected] http://teachers.ksu.edu.tw/rscheng/

Upload: arleen-weaver

Post on 30-Dec-2015

231 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

NS-2網路模擬

Rung-Shiang Cheng (程榮祥 )Department of Computer and Communication, Kun Shan University

[email protected]://teachers.ksu.edu.tw/rscheng/

Page 2: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

Outline

NS-2基本操作– NS-2安裝與設定 (for Linux)

– 個別套件的安裝範例介紹

– Improving TCP Performance with Bandwidth Estimation and Selective Negative ACK Wireless Networks

Page 3: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

3

NS-2 安裝與設定 (for Linux)

Page 4: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

4

NS-2 是什麼 ?

Network Simulator, version 2– 物件導向網路模擬器– C++, OTCL– Router, Link, End point, TCP/IP protocols– Ethernet, WiFi, Sensor Networks

Page 5: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

5

NS-2 的下載與安裝下載 NS-2

– NS-2 網址 http://www.isi.edu/nsnam/ns/– Download and Build ns

• Getting everything at once • Ns-allinone 套件

選擇 current release 2.XX

Page 6: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

NS-2 的下載與安裝

安裝 NS-2– 解壓縮

– 安裝

– 開始進行安裝… .

Page 7: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

NS-2 的下載與安裝

各別套件的安裝位置

7

Page 8: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

8

NS-2 的下載與安裝

安裝完成訊息

Page 9: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

9

NS-2 的下載與安裝

修改使用者環境設定

將 NS-2要求設定的路徑,加入 PATH 參數中

Page 10: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

.bashrc 範例

10

Page 11: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

測試可否使用 Network Animator

請在命令列 (Command Line)輸入 nam指令

若可以看到下列視窗表示 nam 安裝成功 (若否 ,則進行個別套件安裝 )

目前使用的是 1.13 版

Page 12: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

12

個別套件的安裝 – 以 NAM 為例

Download and Build ns

– Getting the Pieces

最新版本的nam

Page 13: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

下載新版的 nam

將下載的檔案移至 NS-allinone 的目錄下

原先的版本是 nam-1.13,新的版本是 nam-1.14

Page 14: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

個別套件的安裝 – 以 NAM 為例

使用 tar指令將下載的檔案解壓縮

開始進行安裝

14

…..( 省略 )……

Page 15: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

個別套件的安裝 – 以 NAM 為例

檢查是否產生 nam執行檔

指定使用新的 NAM版本來取代舊的 NAM版本

15

Page 16: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

測試可否使用新安裝好的 Network Animator

請在命令列 (Command Line)輸入 nam指令

若可以看到下列視窗表示 nam安裝成功

目前使用的版本已經更新為 1.14版

Page 17: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

17

Getting Older Versions of Ns

Page 18: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

開始使用 NS-2

Hello World程式

Page 19: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

19

如何使用 NS-2 進行網路模擬

NS-2的執行流程

Page 20: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

如何使用 NS-2 進行網路模擬

設計模擬劇本產生網路拓撲產生網路流量利用 NAM觀察模擬過程

Page 21: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

The first TCL script (1/3)

程式碼來源 ⇒ http://www.isi.edu/nsnam/ns/tutorial/index.html

使用文字編輯器輸入下列 TCL 程式碼 ( 檔名為 template.tcl)

Page 22: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

The first TCL script (1/3)

在命令列輸入 ns template.tcl

Page 23: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

The first TCL script (1/3)

執行結果

沒有任何東西… .( 因為尚未產生網路拓撲 )

Page 24: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

產生網路拓撲 (2/3)

加入這段程式碼:

產生 2 個 node並建立 duplex-link

程式碼來源 ⇒ http://www.isi.edu/nsnam/ns/tutorial/index.html

Page 25: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

The first TCL script (2/3)

重新執行程式

已經產生網路拓樸 , 但沒有資料在傳送… .

Page 26: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

The first TCL script (3/3)

再接下去加入這段程式碼:

產生 CBR 流量並設定傳資料的起始和結束時間

Page 27: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

The first TCL script (3/3)

修改後 , 重新執行程式

經過 0.5 秒後開始傳送資料

按下 play…

Page 28: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

Improving TCP Performance with Bandwidth Estimation and Selective

Negative ACK Wireless Networks

Rung-Shiang ChengAssistant ProfessorDepartment of Computer and Communication, Kun Shan UniversityEmail: [email protected]

1. Rung-Shiang Cheng, Hui-Tang Lin, Improving TCP Performance with Bandwidth Estimation and Selective Negative Acknowledgment in Wireless Networks, Journal of Communications and Networks, vol. 9, no. 3, pp. 236-246, Sep. 2007. (SCI)

Page 29: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

Outline

Introduction TCP Congestion Control TCP Enhancement

– Bandwidth Estimation Schemes for TCP over High-Speed Networks

– SNACK-based Error Recovery Scheme Conclusion

Page 30: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

30

TCP Overview

TCP is the most widely used Internet protocol– Web, FTP, Telnet, E-mail, Peer-to-peer etc.

A two way, reliable, connection-oriented protocol– Reliable data transfer

• Byte-stream– App writes bytes, TCP sends segments

– Flow control: keep sender from overrunning receiver– Congestion control: keep sender from overrunning

network

Page 31: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

31

Reliability in TCP

Checksum used to detect bit level errors Sequence numbers used to detect sequencing errors

– Duplicates are ignored– Reordered packets are reordered (or dropped)– Lost packets are retransmitted

Timeouts used to detect lost packets– Requires RTO calculation– Requires sender to maintain data until it is ACKed

Page 32: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

32

Motivation

Why Study TCP Performance– Dependence on TCP/IP networks

• More people rely on TCP/IP networks than ever before

– Emergence of New Networking Technologies• TCP algorithms suitable for one environment, do not always work best in

another, e.g., Wireless (WiFi, WiMax), satellite, High-speed networks etc.

• Need for research into new algorithms

Critical Role of TCP– Many believe that network performance can be boosted by simply

upgrading hardware– TCP has total control of how application data should be released to the

network– Unless TCP is optimized, hardware alone cannot boost network

performance

Page 33: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

33

Congestion Control

Approach: increase transmission rate (congestion window size), probing for usable bandwidth, until loss occurs– additive increase: increase cwnd by 1 MSS every RTT

until loss detected– multiplicative decrease: cut cwnd in half after loss

expiry timer upon 1,

ACK) duplicate- triple(receive congestion if ,2/

if , ,/1

if , ,1

W

WWWW

WWW

W t

t

avoidance Congestion

phase start-Slow

W: congestion windowWt: slow-start threshold

Page 34: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

34

Poor Link Unitization at High Bandwidth-Delay Product (BDP)

Networks

Internet’s subsequent growth and worldwide expansion has meant faster links and increased diversity in network access technologies

TCP congestion control performs poorly as bandwidth or delay increases– TCP increases by 1 Packet/RTT even if spare bandwidth is

huge– A single TCP flow can saturate a 10Gbps link where there

is unrealistically low packet loss Because TCP lacks fast response

Page 35: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

35

Enhanced Startup Procedure

Two changes in the modified start-up procedure

– An appropriate initial threshold

– Smooth the transition from the slow-start phase to the congestion-avoidance phase

Goal

– Fast response to currently available bandwidth

– Friendly to TCP flows that potentially share bandwidth

– Scalable (no per-flow state)

Page 36: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

36

Enhanced Startup Procedure

t

W (1)

(2) qbtW

(3)

11

1

tqb

t

qbt

qbW 1)(

(4)

tWt (5)

Based on Eq. (4), Wt is computed every round-trip

Page 37: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

37

Enhanced Startup Procedure

The source updates its window size for each ACK received, as follows:

When a triple-duplicate ACK is received:

t

tt

WWWW

WWW

WW

W

if ,,/1

if ,,1

avoidance Congestion

start Slow(6)

longtm /ˆ

}ˆ ,{ max2/

tWWWW

t

t

(7)

(8)

Page 38: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

加入自行修改的 TCP 模組

切換目徑至 tcp 目錄下 :

新增自行修改的 TCP模組接著到 ns目錄下編輯Mackfile

將新增的模組名稱加入Makefile中

最後重新編譯Makefile即可

Page 39: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

39

Simulation Model

Default value– Bottleneck: 155 Mbps– RTT: 20 ms– Packet size 512 Bytes

Simplified TCP network model

Page 40: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

40

(a). Congestion window dynamic

Numerical Results

Reno: 63.44% Vegas: 63.53%Modified TCP 95.14%, in the first 20 seconds

Page 41: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

計算 Queue length

(c.) Modified startup procedure(b). Reno startup procedure

Page 42: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

42

Numerical Results

Goodput achieved with different bottleneck link capacities (RTT = 20 ms)

Page 43: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

43

Numerical Results

Effect of different round-trip time (bottleneck bandwidth = 155 Mbps)

Page 44: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

44

Numerical ResultsTCP goodput and the corresponding packet drop rate (RTT = 20 ms)

Queue length at bottleneck:

Buffer size = 19

Reno TCP Modified TCP

Page 45: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

45

Fair share: 15.50 MbpsModified TCP : 15.53 Mbps Reno: 11.83 MbpsFairness index: 0.982

Numerical Results

Variations of congestion window size (bottleneck =155 Mbps)

Page 46: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

Numerical Results

TCP goodput and fairness index

ni i

ni i

nxn

xxxxxf

12

2

1321 ),,(

Jain’s Fairness Index:

Page 47: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

47

TCP Performance Issues in Wireless Environments

Limited by– Erratic bit-error– Varying latency– Shared spectrum

• pose formidable challenges when attempting to provide reliable, end-to-end data transmission for transport protocols such as TCP

Inappropriate reduction of congestion window– Wireless transmission errors not related to

network congestion– TCP backs off upon detection of packet loss– Severe degradation in TCP throughput

Page 48: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

48

TCP Enhancement Schemes

Splitting TCP Connections– Indirect-TCP (I-TCP), Snoop Agent

Link-Layer schemes– Explicit Loss Notification (ELN)

End-to-end schemes– SACK: adding Selective ACK to TCP– Combat multiple losses problem– Cannot provide the status of the receiver buffer completely

if the number of blocks is greater than three

Page 49: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

49

Selective Negative Acknowledgement

Goal– Enhance the TCP performance, leaving the functionality of the

MAC protocol unchanged

Integrates the respective capabilities of SACK and negative acknowledgement (NAK)

Capable of specifying a large number of holes in a bit-efficient manner

hole 1 offset: specifies the starting location of the first hole

hole 1 length: the size of the first hole bit-vector: missing data in the

corresponding MSS-sized block of the receiver buffer

Structure of SACK and SNACK options

Page 50: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

50

SNACK Bit-vector Example

Receiver side buffer

SNACK example

Retransmitted segment 6 received but segment 1 not received

Retransmitted segment 1 received but segment 6 not received

Page 51: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

51

Proposed Error Recovery Procedure

Page 52: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

52

Performace Evaluation

Simulation topology

Gilbert-Elliot error model

– Good state, G: losses occur with a low probability PG

– Bad state, B: the channel operates in a fading condition and the loss probability , PB, is higher

PG= 0.001, PB = 0.005, PGG =0.96, PBB = 0.94

Gilbert-Elliott model

Page 53: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

53

Analytical Model

DATA2DATA1ACK

ACKDATA2ACKDATA1CTSnoRTS

TTTSIFSDIFS

m

TSIFSTDIFSTSIFSTDIFS

mTh

SLOT /2)(CW2

SLOT /2)(CWSLOT /2)(CW

min

minmin/

DATA2DATA1ACKCTSRTSCTSRTS TTTTTSIFSDIFS

mTh

SLOT /2)(CW32 min/

TDATA1: the time required to transmit a MAC frame including the TCP data packet TDATA2: the time required to transmit a MAC frame including the TCP layer ACK TACK: the time required to transmit a MAC layer ACK frame including a physical layer header (CWmin /2) . SLOT: the assumed average backoff time

TDATA / (DIFS + TDATA + SIFS + TACK) TDATA / (DIFS + TRTS + TCTS + TDATA +

(3 . SIFS) + TACK)

Basic access mechanism Virtual carrier sensing mechanism

Page 54: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

54

Effect of Channel Collisions and Physical Errors

TCP throughput over 802.11 WLAN (packet size = 1400 bytes)

the high-speed link is more seriously affected by losses

The analytical upper bound of TCP throughput over 802.11 networks

Page 55: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

Figure 1. TCP goodput with different RTT

Figure 2. TCP goodput with different FER

Comparison between SNACK and SNACK-S

Page 56: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

Figure 1 的 Unix Shell Script

Page 57: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

Figure 2 的 Unix Shell Script

Page 58: NS-2 網路模擬 Rung-Shiang Cheng ( 程榮祥 ) Department of Computer and Communication, Kun Shan University rscheng@mail.ksu.edu.tw

58

Conclusion

Large delay-bandwidth networks– Resolve lack-fast-response problem in TCP– Improve throughput while remain fair to other active TCP

implementation Wired/wireless Networks

– Applies SNACK-based error recovery scheme to improve the performance of TCP over wireless channels.

– SNACK scheme recovers from packet loss events in an effective manner

Simulation results show that the proposed scheme greatly improves the TCP goodput in heterogeneous wired/wireless networks