Presentation is loading. Please wait.

Presentation is loading. Please wait.

NCTUNS 網路模擬器操作與 模擬程式開發 柯志亨 國立金門大學資訊工程學系 副教授

Similar presentations


Presentation on theme: "NCTUNS 網路模擬器操作與 模擬程式開發 柯志亨 國立金門大學資訊工程學系 副教授"— Presentation transcript:

1 NCTUNS 網路模擬器操作與 模擬程式開發 柯志亨 國立金門大學資訊工程學系 副教授

2 大綱 1. NCTUNS 簡介與 GUI 操作 2. LAN & WLAN 3. Emulation 4. How to insert a new module into NCTUNS? 5. How to Get/Set a variable at the run-time? 6. How to write a simple MAC for wireless network? 7. How to write a flooding module for wireless simulations?

3 1. NCTUNS 簡介與 GUI 操作 Simulates and emulates network protocols Open source Modified Linux kernel GUI and shell commands Client-server model to allow communication between simulation/emulation engine and interface Uses native Linux TCP/IP stack Interacts with real devices in virtual networks Allows experiments with real applications There is no need to change the real applications Allows remote simulations and concurrent simulations Easy to create simulation servers Can take advantage of multiple cores/processors

4 4 Features (1) ‏ Support to several protocols is already included : IEEE 802.3, IEEE , IEEE , Learning bridge protocol, Spanning tree protocol,... IP, Mobile IP, RIP, OSPF, OBS, GPRS,... TCP, UDP, SDP,... HTTP, FTP, telnet,... (+ any real application)‏ Some specific applications included: stcp/rtcp - Greedy TCP traffic ttcp - Greedy TCP/UDP trafic stg/rtg - Greedy TCP/UDP traffic, trace driven, self-similar traffic, on-off, constant-bit-rate, and various packet streams.

5 5 Features (2) ‏ Support to several links and devices is already included PPP link, ethernet link,... Host, hub, switch, router,... QoS Diffserv boundary/interior routers Optical burst/circuit switch External host, external router (emulation) ‏

6 6 Features (3) ‏ Creates virtual interfaces to simulate the devices of the scenario Inspiration from loopback interface Utilizes IP address During the simulation it is possible to “see” the interfaces with the commands /sbin/ifconfig or /sbin/route Interfaces named tun0, tun1, tun2,...

7 7 Features (4) ‏ Kernel re-entering methodology

8

9

10 10 Utilization (1) ‏ Basic components (binaries) ‏ nctunsclient – GUI interface between user and system nctuns – shell interface between user and system nctunsse – NCTUns core dispatcher – Manage the simulation requests. Can control multiple coordinators running in different machines coordinator – Receives the simulation from the dispatcher and forward it to the nctunsse

11 11 Utilization (2) ‏  Each simulation server = kernel modifications + nctunsse + protocol modules + coordinator

12

13 13 Utilization (3) ‏ Folders organization tools = executable programs of various applications and tools pre-installed (/usr/local/nctuns/tools) bin = executable programs of the GUI program, dispatcher, coordinator, and the simulation engine (/usr/local/nctuns/bin) etc = configuration files needed by the dispatcher and coordinator programs (/usr/local/nctuns/etc) BMP = icon bmp files uses by the GUI program (/usr/local/nctuns/BMP) lib = libraries used by the simulation engine

14 14 Utilization (4 )‏ Execution order dispatcher  Waits client connection via TCP port 9800  Waits coordinator connection via TCP port 9810 coordinator  Connects to dispatcher nctunsclient or nctuns  Connects to dispatcher to send the scenario and waits the end of the simulation. The nctunsse is started by the coordinator

15 15 Utilization (5) ‏ How to use the GUI?

16 NCTUns - Professor Nelson Fonseca16 Utilization (6 )‏ Draw topology

17 17 Utilization (7) ‏

18 18 Utilization (8 )‏ Edit property

19 19 Utilization (9) ‏

20 20 Utilization (10) ‏ Run simulation

21 21 Utilization (11) ‏

22 22 Utilization (12) ‏

23 23 Utilization (13) ‏ Playback

24 24 Utilization (14) ‏

25 25 Utilization (15) ‏

26 26 Utilization (16) ‏

27 NCTUns - Professor Nelson Fonseca27 Utilization (17) ‏ Main simulation files.emu: external routing table (needed to emulation) ‏.ndt: nodes identification.tfc: list of commands to be executed.srt-l: internal routing table (tun[0-9]* devices) ‏.tcl: scenario details One example of each file is available at See p54~p70 in DeveloperManual.pdf

28 28 Utilization (18) ‏ To run without the GUI Create the basic scenario from the GUI (It is easier) ‏ Make the necessary changes in the files Run nctuns  is generated by the GUI Wait for the results

29 29 Examples (1) ‏ Scenario 1 Network topology: 2 hosts connected by an ethernet link Protocols: TCP and UDP Applications: rtcp/stcp Devices:

30 30 Examples (2) ‏ Scenario 1 – Applications configuration To simulate data transfer between host 1 ( ) and hosts 2 ( ) via TCP using stcp and rtcp Host 1: stcp -p  Sending TCP segments to at port 8000 Host 2: rtcp -p 8000  Receiving TCP segments from port 8000

31 31 Examples (3) ‏

32 Scenario 2 To simulate data transfer between host 1 ( ) and host 2 ( ) via UDP using stg and rtg Host 1: stg -u m p  Sending UDP datagrams to at port Transmission rate limited to 50Mbps and packet size equal to 1000 bytes. Host 2: rtg -u -p 8000  Receiving UDP datagrams from port Examples (4) ‏

33 2. LAN & WLAN Basic performance evaluation Routing (Static routing vs. Dynamic routing) Performance Anomaly Problem Performance evaluation of ad hoc routing protocols Performance evaluation of IEEE b wireless networks

34 Basic performance evaluation Tools – Wireshark ( 封包觀測 ) yum install wireshark* – Gnuplot ( 繪圖 ) yum install gnuplot Throughput Measurement (Application and MAC Level)

35 tcpdump –i eth1 –U –w mylog wireshark mylog udp_sudp_c 封包觀測 hub Example: hub

36 client  server

37 server->client

38 3~30s: ttcp –t –s –p ~30s: ttcp –t –s –p ~30s: ttcp –r –s –p 4321 –w thr_n3n4 0~30s: ttcp –r –s – p 1234 –w thr_n2n5 switch Application level MAC level Example: switch

39 At Node 4 Throughput: Application level vs. MAC level

40

41 Dynamic routing vs. Static Routing Bandwidth=10Mbps Link down = 5 ~ 25 sec (from R3 to R4) Run time:1~100 seconds rtcp stcp Example: routing_wired

42

43

44 How to manually set the routing tables in wired simulation ? rtcp stcp Example: routing_wired_static

45 rtcp stcp *.srt-l

46

47 How to manually set the routes in the wireless simulations? $node_(NID) + entry-changing time + "set-next-hop" + SrcNode + DstNode + NextHop + "chan" + channel

48

49 在 IEEE 的標準裡 a/b/g 分別利用不同的編碼 方式可支援多種不同的傳輸速度, b 提供了 四種傳輸速度, (1M/2M/5.5M/11M) , a 則提 供多達八種傳輸速度。 較低的傳輸速度對於訊號的抗干擾性較強,反之較 高的傳輸速度則較弱。當訊號不良的時候選擇低速 的傳輸速度,當訊號收訊良好時則選擇高速的傳輸。 所以在一個無線區域網路中,可能同時存在具有不 同傳輸速率的行動節點,我們通常稱這樣這網路為 多速率網路環境 (multi-rate wireless network) 。 無線網路異常問題 (Performance Anomaly Problem) 1

50 假設所有無線網路所有傳輸的封包大小都是相同 的,在此假設下,當低速節點得到通道存取機會 時,需要較久的時間才能把封包傳送完畢;另外, 若是高速節點和低速節點發生傳輸碰撞,則高速 節點還是需要等待低速節點把整個封包傳送過程 完成後,才能重新競爭通到存取機會。以上兩個 情況是主要造成整個無線網路效能變差的原因。 無線網路異常問題 (Performance Anomaly Problem) 2

51 Performance Anomaly Problem 11M 在 group wireless nodes 時, 第一個一定要先選 AP stg -u ~30sec stg -u ~20sec Example: anomaly

52

53 11M 1M stg -u ~30sec stg -u ~20sec Change link bandwidth from 11 to 1

54

55

56 Increase the cwmin value of the 1Mbps node to lower the contending probability a.Press the R b.Edit the *.tcl file to increase the cwmin value c.Run

57 Limit the packet length of the 1Mpbs node

58 Performance evaluation of ad hoc routing protocols Compare DSDV, AODV, DSR routing protocols under static or dynamic situations The nodes are all fixed. Example : wrouting

59

60

61 比較 DSDV, AODV, DSR Random Number 要設定相同的數值, 但不能為 0

62

63

64

65 The nodes are randomly moving. Example : wrouting2

66

67 Performance evaluation of IEEE b wireless networks packet size vs. throughput – with/without wireless transmission error Example: wperformance

68 without wireless transmission error

69 Kbytes/sec Application data:500 bytes

70 Application data:1000 bytes Kbytes/sec

71 Application data:2000 bytes Kbytes/sec ??? Why ???

72 Packets are fragmented into small packets and need to contend more times for transmission.

73 Application data:2000 bytes Kbytes/sec Packet size Overhead Throughput

74 With transmission error Set the bit error rate to Kbytes/sec Application data:500 bytes

75 Application data:1000 bytes Kbytes/sec With transmission error, Packet size throughput How to design a mechanism that can adjust the packet size under different wireless transmission error rates is important !!!

76 4. Emulation Example: emu

77

78

79 Simulated Host External Host

80

81 How to insert a new module into NCTUNS? [Background] 1. This is a simplified version of First In First Out (Drop Tail) Queue. The codes were mainly re-written from original FIFO.cc/FIFO.h. 2. Please refer to DeveloperManual.pdf which is under /root/ NCTUns- 6.0/doc/Developer.Manual folder. Take a closer look at the chapter 2 and chapter 5. [Preparation] 1. Change the path to /root/NCTUns-6.0/src/nctuns/module/ps 2. Create a new folder named sFIFO. 3. Prepare 3 files under sFIFO.

82

83

84

85 PACKET RECEPTION PACKET TRANSMISSION

86 THE RELATIONSHIP BETWEEN PUT(), GET() AND SEND().

87 THE RELATIONSHIP BETWEEN PUT(), GET() AND RECV().

88 #ifndef __NCTUNS_sfifo_h__ #define __NCTUNS_sfifo_h__ #include /* Define Interface Queue for every Interface */ struct ifqueue { ePacket_ *ifq_head; /* head of ifq */ ePacket_ *ifq_tail; /* tail of ifq */ int ifq_len; /* current queue length */ int ifq_maxlen;/* max queue length */ int ifq_drops; /* drops count */ }; /* Define Macros for IFq */ #define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen) #define IF_DROP(ifq) ((ifq)->ifq_drops++) #define IF_ENQUEUE(ifq, m) { \ if ((ifq)->ifq_tail == 0) \ (ifq)->ifq_head = m; \ else \ (ifq)->ifq_tail->next_ep = m; \ (ifq)->ifq_tail = m; \ (ifq)->ifq_len++; \ } sfifo.h #define IF_PREPEND(ifq, m) { \ (m)->next_ep = (ifq)->ifq_head; \ if ((ifq)->ifq_tail == 0) \ (ifq)->ifq_tail = (m); \ (ifq)->ifq_head = (m); \ (ifq)->ifq_len++; \ } #define IF_DEQUEUE(ifq, m) { \ (m) = (ifq)->ifq_head; \ if (m) { \ if (((ifq)->ifq_head = (m)->next_ep) == 0) \ (ifq)->ifq_tail = 0; \ (m)->next_ep = 0; \ (ifq)->ifq_len--; \ } \ }

89 class sfifo : public NslObject { private: struct ifqueue if_snd; /* output interface queue */ protected: int intrq(MBinder *); public: sfifo(u_int32_t type, u_int32_t id, struct plist* pl, const char *name); ~sfifo(); int init(); int recv(ePacket_ *); int send(ePacket_ *); }; #endif /* __NCTUNS_sfifo_h__ */

90 #include MODULE_GENERATOR(sfifo); sfifo::sfifo(u_int32_t type, u_int32_t id, struct plist* pl, const char *name) : NslObject(type, id, pl, name) { /* disable flow control */ s_flowctl = DISABLED; r_flowctl = DISABLED; /* initialize interface queue */ if_snd.ifq_head = if_snd.ifq_tail = 0; if_snd.ifq_len = 0; if_snd.ifq_drops = 0; /* bind variable */ vBind("max_qlen", &if_snd.ifq_maxlen); if_snd.ifq_maxlen = 50; /* by default */ } sfifo.cc sfifo::~sfifo() { } int sfifo::init() { int (NslObject::*upcall)(MBinder *); /* set upcall */ upcall = (int (NslObject::*)(MBinder *))&sfifo::intrq; sendtarget_->set_upcall(this, upcall); return(1); }

91 int sfifo::send(ePacket_ *pkt) { assert(pkt&&pkt->DataInfo_); /* * If Module-Binder Queue(MBQ) is full, we should * insert the outgoing packet into the interface * queue. If MBQ is not full, we can call the * put() or NslObject::send() method to pass the * outgoing packet to next module. */ if( sendtarget_->qfull() ) { /* MBQ is full, insert to ifq */ if (IF_QFULL(&if_snd)) { /* ifq full, drop it! */ IF_DROP(&if_snd); freePacket(pkt); return(1); } /* otherwise, ifq not full, insert it */ IF_ENQUEUE(&if_snd, pkt); return(1); } else { /* * MBQ is not full, pass outgoing packet * to next module. */ return(NslObject::send(pkt)); }

92 int sfifo::recv(ePacket_ *pkt) { /* Just by pass incoming packet */ assert(pkt&&pkt->DataInfo_); return(NslObject::recv(pkt)); } int sfifo::intrq(MBinder *port) { ePacket_ *pkt; /* * Push the packet in the interface queue * to the MBQ. Whenever the pakcet in the * MBQ is sent, the scheduler will call this * member function to give sfifo module a * chance to send the next packet in the * interface queue. */ IF_DEQUEUE(&if_snd, pkt); if (pkt != NULL) { /* * If still exist packet in the interface * queue, we try to push it to the MBQ, */ assert(sendtarget_->enqueue(pkt) == 0); } return(1); } # # Makefile for the NCTUns engine module # obj-y = sfifo.o Makefile

93

94 Change path to /root/NCTUns-6.0/src/nctuns and edit the nctuns.cc Recompile the nctuns

95 方法一

96 (change FIFO to sFIFO and remove some redundant functions)

97

98 方法二

99 記得要關閉 nctunsclient, 再重新開啟才會生效

100

101 How to Get/Set a variable at the run- time? [Background] Refer to the section in the DeveloperManual.pdf for advanced information. But in that document, it teaches you to use “EXPORT” function to register the variables that you are interested in. And then modify the module description file in order to get/set a variable at the run-time. Take the following scenario as an example. Node 2 is using stg program to send packets to Node 3. If we are interested in the current queue length in the Node 2, we have to do the following procedures: “Simulation/Run”->Node 2-> Node editor->FIFO->GET (Current Queue Length) in the Run Time Query group. It takes time and many procedures to achieve what we want. Therefore, I will introduce another method. With this method, you can get/set the information at the time exactly at any time you want during simulation.

102

103

104

105

106

107

108

109

110

111

112 How to write a flooding module for wireless simulations?

113

114

115

116

117

118 How to write a simple MAC for wireless network? MYMAC_SIMPLE

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135


Download ppt "NCTUNS 網路模擬器操作與 模擬程式開發 柯志亨 國立金門大學資訊工程學系 副教授"

Similar presentations


Ads by Google