1. Trang chủ
  2. » Giáo án - Bài giảng

THIẾT KẾ VÀ MÔ PHÓNG MẠNG VOWLAN (VOICE OVER WIRELESS-LAN) TRƯỜNG ĐẠI HỌC TÔN ĐỨC THẮNG

93 3 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

TỔNG LIÊN ĐOÀN LAO ĐỘNG VIỆT NAM TRƯỜNG ĐẠI HỌC TÔN ĐỨC THẮNG KHOA ĐIỆN-ĐIỆN TỬ LUẬN VĂN TỐT NGHIỆP ĐỀ TÀI: THIẾT KẾ VÀ MÔ PHỎNG MẠNG VOWLAN (VOICE OVER WIRELESS-LAN) GVHD: Th.S ĐỖ ĐÌNH THUẤN SVTH: NGUYỄN TRƯỜNG GIANG MSSV: 060562D LỚP: 06DD2D KHĨA: 10 Tp Hồ Chí Minh, tháng 12 năm 2010 LỜI CẢM ƠN  Trong thời gian học tập rèn luyện trường Đại học Tôn Đức Thắng, đặc biệt thời gian làm luận văn tốt nghiệp, em chân thành cảm ơn quý thầy cô khoa Điện - Điện Tử đặc biệt thầy cô môn Điện Tử Viễn Thơng nhiệt tình truyền đạt kinh nghiệm, kiến thức chuyên môn nhiều kỹ quý bảo cho em Đặc biệt em chân thành cảm ơn thầy Đỗ Đình Thuấn - giảng viên môn Điện Tử Viễn Thông - nhiệt tình giúp đỡ, hướng dẫn truyền đạt kinh nghiệm giúp em hoàn thành luận văn tốt nghiệp! Một lần em xinh chân thành cảm ơn thầy cô! NHẬN XÉT CỦA GIẢNG VIÊN HƯỚNG DẪN  NHẬN XÉT CỦA GIẢNG VIÊN PHẢN BIỆN  NỘI DUNG  DANH MỤC CÁC TỪ VIẾT TẮT DANH MỤC CÁC HÌNH VẼ LỜI MỞ ĐẦU MẠNG CỤC BỘ KHÔNG DÂY WIRELESS LAN 1.1 Tổng quan mạng cục không dây WLAN 1.1.1 Giới thiệu 1.1.2 Quá trình phát triển 1.1.3 Ưu điểm nhược điểm 1.1.4 Các chuẩn mạng 1.1.5 Các mô hình mạng 11 1.1.5.1 Ad-hoc Mode 12 1.1.5.2 Infrastructure Mode 13 1.2 Giới thiệu thiết bị mạng không dây 14 1.2.1 Wireless LAN card 14 1.2.2 Bridge-Hub-Switch 15 1.2.3 Access point 18 1.2.4 Antena 18 VOICE OVER INTERNET PROTOCOL (VoIP) .21 2.1 VoIP ( Voice over internet protocol) 21 2.1.1 Các thành phần mạng IP 22 2.1.2 Phương thức hoạt động 22 2.2 Các giao thức báo hiệu gọi 22 2.2.1 H.323 .23 2.2.2 SIP 24 2.2.3 MGCP MEGACO/H 248 26 2.2.4 RTP 26 2.2.5 RTCP .27 2.2.6 IMCP .28 THIẾT KẾ VÀ BẢO MẬT MẠNG VoWLAN .29 3.1 Tổng quan hệ thống VoWLAN 29 3.2 Thiết kế hệ thống VoWLAN 30 3.2.1 Dung lượng hệ thống System Capacity: 30 3.2.1.1 Packet Sizes 30 3.2.1.2 Màu đầu gói tin 32 3.2.1.3 Màu đầu DCF .33 3.2.1.4 PCF .34 3.2.1.5 Tốc độ truyền dẫn 36 3.2.2 QoS hệ thống VoWLAN 39 3.2.2.1 Khả sẵn sang 39 3.2.2.2 Thông lượng 39 3.2.2.3 Delay 39 3.2.2.4 Trễ thay đổi 40 3.2.2.5 Mất gói 40 3.3 Bảo mật VoWLAN 41 3.3.1 Tổng quan WLAN sercurity 41 3.3.1.1 Xác thực 41 3.3.1.2 Mã hóa 46 3.3.2 Các nguy biện pháp bảo đảm thông tin VoWLAN 50 3.3.2.1 Tấn công bị động 50 3.3.2.2 Truy cập trái phép 53 3.3.2.3 Man in the Middle 54 3.3.2.4 Tấn công từ chối dịch vụ 55 MÔ PHỎNG VoIP TRÊN WLAN 58 4.1 Giới thiệu phần mềm mô NS2 ( Network Simulator) .58 4.2 Mô hình mơ cấu hình thành phần mạng .63 4.3 Kết mô 66 KẾT LUẬN VÀ HƯỚNG PHÁT TRIỂN ĐỀ TÀI 75 5.1 Kết luận 75 5.2 Hướng phát triển đề tài 75 TÀI LIỆU THAM KHẢO 76 PHỤC LỤC 77 Voice Over Wireless LAN DANH MỤC CÁC TỪ VIẾT TẮT  ACK Acknow Ledgement Ghi nhận CBR Constant Bit Rate Tốc độ bit cố định CBQ Class Based Queueing Hàng đợi dựa lớp FTP File Transfer Protocol Giao thức truyền tập tin GSM Global System for Mobile Hệ thống di động toàn cầu HBT High priority Best effort Traffic Lưu lượng nỗ lực tối đa có độ ưu tiên cao HTTP Hypertext Transfer Protocol Giao thức truyền tải siêu văn ID Identifier Mã nhận dạng IEEE Institute of Electrical and Viện kỹ thuật điện điện tử Electronic Engineers IP Internet Protocol Giao thức internet LAN Local Area Network Mạng cục MAC Media Access Control Điều khiển truy cập đường truyền MMS MPLS Network Simulation Mô mạng MPLS MPLS Multicast-Protocol Label Switching Chuyển mạch nhãn đa giao thức NAM Network Animator Minh họa mạng NFS Network FileSystems Các tập tin hệ thống mạng NS Network Simulator Mô mạng OSPF Open Shortest Path First Đường dẫn ngắn mở PBX Private Branche Xchange Tổng đài chi nhánh riêng Nguyễn Trường Giang 060562D Page Voice Over Wireless LAN RED Random Early Detection Hàng đợi Dò sớm ngẫu nhiên RT Realtime Traffic Lưu lượng thời gian thực RTP Real Time Transport Protocol Giao thức truyền thời gian thực RTCP Real Time Transport control Điều khiển truyền thời gian thực Protocol SBT Simple Best Effort Traffic Lưu lượng nỗ lực tối đa đơn giản SGW Singnaling Gateway Cổng kết nối SIP Session Initiation Protocol Giao thức khỡi tạo phiên SPF Shortest Path First Đường dẫn ngắn ST Signaling Traffic Lưu lượng tín hiệu TCP Transmission Control Protocol Giao thức điều khiển truyền tải TTL Time-To-Live Thời gian tồn UDP User Datagram Protocol Giao thức gói người dùng VOIP Voice Over Internet Protocol Giao thưc thoại qua Internet WAN Wide Area Network Mạng diện rộng WLAN Wireless Local Area Network Mạng cục không dây WWW World Wide Web Nguyễn Trường Giang 060562D Page Voice Over Wireless LAN DANH MỤC CÁC HÌNH VẼ  Hình 1.1: Các chuẩn mạng Wi-fi Hình 1.2: Ad-hoc Mode Hình 1.3: Infrastructure Mode Hình 1.4: PC card Hình 1.5: Adaptor card Hình 1.6: USB card Hình 1.7: Cấu tạo nguyên tắc hoạt động Hub Hình 1.8: Cấu tạo nguyên tắc hoạt động switch Hình 1.9: : Bridge Hình 1.10: Access Point Hình 1.11: Antena đa hướng Omni Hình 1.12: Antena Parabol Hình 1.13: Antena Yagi Hình 2.1: VoIP connection Hình 2.2: Các thành phần giao thức H.323 Hình 2.3: Các thành phần SIP network Hình 3.1: Hệ thống VoWLAN Hình 3.2: Thơng lượng Package Size Hình 3.3: Tiêu đề PHY cho 802.11b Hình 3.4: DCF Time Hình 3.5: PCF Time Hình 3.6: Tốc độ phạm vi truyền data Hình 3.7: Nguy bị cơng từ bên ngồi Hình 3.8: Các bước xác thực OSA Hình 3.9: Xác thực khóa chia sẻ SKA Hình 3.10: Xác thực IEEE 802.1X/EAP Hình 3.11: Mã hóa giải mã WEP Hình 3.12: Các bước bẻ khóa WEP Hình 3.13: Tấn cơng Mand-in-the -midle Hình 3.14: Tấn cơng DoS vật lý Hình 3.15:Tấn cơng DoS lớp Liên kết liệu Hình 4.1:Kiến trúc NS-2 Hình 4.2:Giao diện người dùng NAM-Network Animator Hình 4.3: Giao diện đồ họa người dùng Xgraph Nguyễn Trường Giang 060562D Page Voice Over Wireless LAN Hình 4.4: Mơ hình mơ qua phần mềm NAM-Network Animator Hình 4.5: Mơ truyền gói tin Voice Hình 4.6: Trễ gói – Trường hợp: truyền gói tin Voice Hình 4.7: Băng thơng chiếm dụng lưu lượng Voice Hình 4.8: Số lượng Package gữi đến đích Hình 4.9: Trễ gói – Trường hợp: Tăng kích thước gói tin Voice Hình 4.10: Băng thông chiếm dụng lưu lượng Voice tăng kích thước gói tin Voice Hình 4.11: Mơ truyền gói tin Voice Data Hình 4.12: Trễ gói – trường hợp mạng có luồng Voice Data Hình 4.13: Băng thơng truyền Voice Data Nguyễn Trường Giang 060562D Page Voice Over Wireless LAN ◦ Độ trễ Package: Hình 4.12: Trễ gói – trường hợp mạng có luồng Voice Data => Trường hợp mạng tăng thêm hai kênh truyền liệu truy cập vào mạng wireless Ta thấy số lượng gói tin trễ tăng cao so với trường hợp có kênh voice truyền Điều cho thấy, mạng số lượng kênh truyền data tăng lên nhiều tương đương với tãi mạng tăng ảnh hưởng nhiều đến gọi Vì vậy, việc đảm bảo băng thơng mạng đủ rộng cho ứng dụng Voice, data quan trọng Nguyễn Trường Giang 060562D Page 73 Voice Over Wireless LAN ◦ Băng thông chiếm dụng: Hình 4.13: Băng thơng truyền Voice Data => Đảm bảo băng thơng cho tồn hệ thống mạng yếu tố quan trọng, băng thông đáp ứng mạng nhỏ lưu lượng liệu mạng sảy trường hợp gói, trễ gói lớn ảnh hưởng đến chất lượng thoại Với lại, băng thông khơng đáp ứng u cầu đệm xảy tình trạng tràn đệm làm gói Với dịch dụ VoIP nết tỉ lệ gói tin thoại lên 3% khơng thể chấp nhận Nguyễn Trường Giang 060562D Page 74 Voice Over Wireless LAN CHƯƠNG KẾT LUẬN VÀ HƯỚNG PHÁT TRIỂN ĐỀ TÀI   5.1 KẾT LUẬN: Qua trình mơ độ trễ gói tin Voice hệ thống Wireless LAN, ta kiểm tra yếu tố ảnh hưởng đến độ trễ như: kích thước gói tin, lưu lượng truy cập mạng, băng thơng, cấu hình hành đợi, … Để cãi thiện yếu tố gây ảnh hưởng đến độ trễ, ta điều chỉnh vài thông số giới hạn cho phép Một số thơng số điều chỉnh: ▪ Thay đổi cấu hình Antena ▪ Các kỹ thuật định tuyến ▪ Xử lý hàng đợi ▪ Các kỹ thuật bảo mật ▪ Băng thông mạng LAN ▪ … Qua mơ phỏng, ta có thơng tin phục vụ cho việc thiết kế triển khai ứng dụng Voice mơi trường WirelessLAN nói riêng mơi trường vơ tuyến nói chung Hạn chế mơ chưa thống kê % gói tin Voice bị % gói tin trễ giới hạn cho phép dịch vụ Voice IP 5.2 HƯỚNG PHÁT TRIỂN ĐỀ TÀI: • Kỹ thuật chuyển giao mạng WLAN mạng GSM/3G • Kỹ thuật bảo mật cho hệ thống VoWLAN • Kỹ thuật QoS Nguyễn Trường Giang 060562D Page 75 Voice Over Wireless LAN DANH MỤC TÀI LIỆU THAM KHẢO  [1] Tống Văn On, Mạng Máy Tính (Tập 1), NXB Lao Động-Xã Hội [2] Trần Văn Thành & Nguyễn Thành Trung, Mạng Máy Tính, NXB ĐH Quốc gia TpHCM [3] http://www.vnpro.org/blog/ [4] http://www.3cx.vn/voip [5] http://www.quantrimang.com [6] Bùi Xuân Hạnh, Nghiên cứu công nghệ truyền thoại qua internet sử dụng giao thức TCP/IP (VoIP), Đại học Quốc gia Hà Nội [7] Alcatel white paper, April 2003, IP telephone Design Guide [8] Phùng Văn Vận, Điện thoại IP, NXB Bưu điện tháng 10/2002 [9] Joseph Choi, Design a successful VoWLAN system, Texas Instruments Inc [10] Lin Cai, Yang Xiao, Xuemin (Sherman) Shen and Jon W.Mark, VoIP over WLAN: Voice capacity, admission control, QoS, and MAC; Wiley InterScience (www.interscience.wiley.com) Nguyễn Trường Giang 060562D Page 76 Voice Over Wireless LAN PHỤC LỤC   Cài đặt NS-2 hệ điều hành UBUNTU 10.04: Hệ điều hành ubuntu 10.04 sau cài đặt song, đăng nhập vào tài khoản người dùng - user mơ phỏng: longriver • Download NS-2: http://sourceforge.net/projects/nsnam/files/allinone/ download phiên ns-allinone-2.34.tar lưu vào /home/longriver/ Sử dung Teminal: • Giải nén gói phần mềm tãi về: • ◦ $ cd /home/simulator ◦ $ tar -xvf ns-allinone-2.34.tar • Download & install some packages from repository ◦ $ sudo apt-get install build-essential autoconf automake libxmu-dev • Install the ns2 ◦ $ cd ns-allinone-2.34 ◦ $ /install • You might face problem with the installation of otcl-1.13, the problem can be due to the gcc-4.4.1 / g++-4.4.1 compilers But please try this : sudo apt-get install g++-4.3 CC=gcc-4.3 CXX=g++-4.3 /install try to edit the Makefile.in too From : CC= @CC@ to : CC= gcc-4.3 • Edit some paths ==a $ gedit ~/.bashrc Nguyễn Trường Giang 060562D Page 77 Voice Over Wireless LAN • Put these lines on that file Off course, you might change /home/simulator for it depends on where you extract ns-allinone-2.34.tar # LD_LIBRARY_PATH OTCL_LIB=/home/simulator/ns-allinone-2.34/otcl-1.13 NS2_LIB=/home/simulator/ns-allinone-2.34/lib X11_LIB=/usr/X11R6/lib USR_LOCAL_LIB=/usr/local/lib export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB: $NS2_LIB:$X11_LIB:$USR_LOCAL_LIB # TCL_LIBRARY TCL_LIB=/home/simulator/ns-allinone-2.34/tcl8.4.18/library USR_LIB=/usr/lib export TCL_LIBRARY=$TCL_LIB:$USR_LIB # PATH XGRAPH=/home/simulator/ns-allinone-2.34/bin:/home/simulator/nsallinone-2.34/tcl8.4.18/unix:/home/simulator/ns-allinone-2.34/tk8.4.18/unix NS=/home/simulator/ns-allinone-2.34/ns-2.34/ NAM=/home/simulator/ns-allinone-2.34/nam-1.13/ export PATH=$PATH:$XGRAPH:$NS:$NAM • Validate it $ cd ns-2.34 $ /validate • (Optionally) You can create a symlink, so that ns can be called from everywhere $ sudo ln -s /home/simulator/ns-allinone-2.34/ns-2.34/ns /usr/bin/ns • Try to run it $ ns => Sau cài đặt thành công xuất ký hiệu: % Cài đặt phần mềm hỗ trợ XGRAPH: Download packet: • xgraph-12.1.tar Địa download http://www.isi.edu/nsnam/xgraph/index.html Nguyễn Trường Giang 060562D Page 78 Voice Over Wireless LAN Chạy XGRAPH Chạy XGRAPH Command Line: $xgraph out.tr –geometry 800x400 Chạy XGRAPH kịch ns-2: Proc finish{} { …… exec xgraph out.tr –geometry 800x400 & exit } CODE MÔ PHỎNG VoWLAN: # global setting global opt set opt(chan) Channel/WirelessChannel ;# channel type set opt(prop) Propagation/TwoRayGround ;# radio-propagation model set opt(netif) Phy/WirelessPhy ;# network interface type set opt(mac) Mac/802_11 ;# MAC type set opt(ifq) Queue/DropTail/PriQueue ;# interface queue set opt(ll) LL ;# link layer set opt(ant) Antenna/OmniAntenna ;# antenna model set opt(x) 500 ;# X dimension of the topography set opt(y) 500 ;# X dimension of the topography set opt(ifqlen) 50 ;# max packet in ifq set opt(tr) vowlan.tr ;# trace file set opt(namtr) vowlan.nam ;# nam trace file set opt(nn) 10 ;# numnode set opt(adhocRouting) DSDV ;# routing protocol script (DSR or TORA) set opt(cp) "" ;# no use set opt(sc) "/home/longriver/ns-allinone2.34/ns-.34/tcl/mobility/scene/scen-10-test" ;# node movement file set opt(stop) 10.0 ;# simulation time set num_wired_nodes Nguyễn Trường Giang 060562D Page 79 Voice Over Wireless LAN set num_bs_nodes # Create file trace set f0 [open PkDl.tr w] set f1 [open Bw.tr w] set f2 [open Npkg.tr w] proc init {} { global f0 f1 f2 set f0 [open PkDl.tr w] set f1 [open Bw.tr w] set f2 [open Npkg.tr w] } # Other default settings LL set mindelay_ 50us LL set delay_ 25us LL set bandwidth_ ;# not used Queue/DropTail/PriQueue set Prefer_Routing_Protocols # unity gain, omni-directional antennas #set up the antennas to be centered in the node and 1.5 meters above it Antenna/OmniAntenna set X_ Antenna/OmniAntenna set Y_ Antenna/OmniAntenna set Z_ 1.5 Antenna/OmniAntenna set Gt_ 1.0 ;#transmit-antenna-gain Antenna/OmniAntenna set Gr_ 1.0 ;#receive-antenna-gain # Initialize the SharedMedia interface with parameters to make #WirelessPhy it work like the 2.4GHz Lucent WaveLAN DSSS radio interface Phy/WirelessPhy set CPThresh_ 10.0 ;#threshold physical, Phy/WirelessPhy set CSThresh_ 1.559e-11 ;#connection pattern Phy/WirelessPhy set RXThresh_ 3.652e-10 Phy/WirelessPhy set Rb_ 2*1e6 Phy/WirelessPhy set Pt_ 0.2818 ;#transmit-power Phy/WirelessPhy set freq_ 2.4e+9 ;#freq being used Phy/WirelessPhy set L_ 1.0 ;#system-loss #=========================================================== # Main Program #=========================================================== # -create simulator instance Nguyễn Trường Giang 060562D Page 80 Voice Over Wireless LAN set ns_ [new Simulator] $ns_ node-config -addressType hierarchical $ns_ color Blue $ns_ color green $ns_ color Red # Set up for hierarchical routing AddrParams set domain_num_ ;# number of domains lappend cluster_num ;# number of clusters in each domain AddrParams set cluster_num_ $cluster_num lappend eilastlevel 114 ;# number of nodes in each cluster AddrParams set nodes_num_ $eilastlevel ;# of each domain set tracefd [open $opt(tr) w] $ns_ trace-all $tracefd set nf [open $opt(namtr) w] $ns_ namtrace-all-wireless $nf $opt(x) $opt(y) # Create Topography Network set topo [new Topography] $topo load_flatgrid $opt(x) $opt(y) # Create wired nodes -set temp {0.0.0 0.1.0} ;# hierarchical addresses for wired domain for {set q 0} {$q < $num_wired_nodes} {incr q} { set W($q) [$ns_ node [lindex $temp $q]] $W($q) color "#ffff0000ffff" } $W(0) set X_ 00.0 $W(0) set Y_ 100.0 # Create God set god_ [create-god [expr $opt(nn) +$num_bs_nodes + $num_wired_nodes ]] # global node setting $ns_ node-config -adhocRouting $opt(adhocRouting) \ -llType $opt(ll) \ -macType $opt(mac) \ -ifqType $opt(ifq) \ -ifqLen $opt(ifqlen) \ -antType $opt(ant) \ -propInstance [new $opt(prop)] \ Nguyễn Trường Giang 060562D Page 81 Voice Over Wireless LAN -phyType $opt(netif) \ -channel [new $opt(chan)] \ -topoInstance $topo \ -wiredRouting ON \ -agentTrace ON \ -routerTrace ON \ -macTrace ON # mobilenode start set temp {1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 } # Create base-station node set BS(0) [$ns_ node [lindex $temp 0]] $BS(0) random-motion $BS(0) color "#ffff00000000" $ns_ at 0.08 "$BS(0) label Base-Station" $ns_ at 0.02 "$W(0) label Receiver" $ns_ at 0.05 "$W(1) label Swich-Hub" # -configure for mobilenodes -$ns_ node-config -wiredRouting OFF\-wirelessRouting ON for {set h 0} {$h < $opt(nn)} {incr h} { set node_($h) [ $ns_ node [lindex $temp \ [expr $h+1]] ] $node_($h) base-station [AddrParams addr2id \ [$BS(0) node-addr]] $node_($h) random-motion } # -create links between wired and BS nodes -$ns_ duplex-link $W(1) $BS(0) 11Mb 5ms DropTail $ns_ duplex-link $W(0) $W(1) 11Mb 10ms DropTail # orther -$ns_ queue-limit $BS(0) $W(1) $ns_ duplex-link-op $W(1) $W(0) queuePos 0.5 $ns_ duplex-link-op $BS(0) $W(1) queuePos 0.5 # create the performance for node $ns_ duplex-link-op $W(0) $W(1) orient down $ns_ duplex-link-op $W(1) $BS(0) orient left-down Nguyễn Trường Giang 060562D Page 82 Voice Over Wireless LAN # Create Mobile node -for {set q 0} {$q < $opt(nn)} {incr q} { $ns_ initial_node_pos $node_($q) 10;#try to positor $node_($q) color "#00009999ffff" $ns_ at 0.0 " $node_($q) color #00009999ffff " $ns_ at 0.1 " $node_($q) label Client_($q) " } # -Define a 'finish' procedure -proc finish {} { global f0 f1 f2 namtracefd $namtracefd flush-trace #Close the output files close $f0 close $f1 close $f2 close $namtracefd #Call xgraph to display the results exec xgraph PkDl.tr Bw.tr Npkg.tr -geometry 800x400 #Execute NAM on the trace file puts "running nam " exec nam $opt(namtr) & exit } # -Define Source proc attach-expoo-traffic { node sink size burst idle rate } { #Get an instance of the simulator set ns_ [Simulator instance] #Create a UDP agent and attach it to the node set source [new Agent/UDP] ;#using udp protocol $ns_ attach-agent $node $source #Create an Expoo traffic agent and set its configuration parameters set traffic [new Application/Traffic/Exponential] $traffic set packetSize_ $size ;#the constant size of the packets generated $traffic set burst_time_ $burst ;#the average “on” time for the generator $traffic set idle_time_ $idle ;#the average“off”time for the generator $traffic set rate_ $rate Nguyễn Trường Giang 060562D Page 83 Voice Over Wireless LAN #Attach traffic source to the traffic generator $traffic attach-agent $source #Connect the source and the sink $ns_ connect $source $sink return $traffic } # setup TCP0 connections set tcp [new Agent/TCP] $tcp set class_ set sink0 [new Agent/TCPSink] $ns_ attach-agent $node_(6) $tcp $ns_ attach-agent $W(0) $sink0 $ns_ connect $tcp $sink0 set ftp [new Application/FTP] $ftp set packetSize_ 1024 $ftp set interval_ 0.005 $ftp attach-agent $tcp $ns_ at 0.0 "$ftp start" # set numnode 10 set start_rate 0.0 set time_sim 10.0 set load 0.0 set num_chan set delay 0.0 for {set i 0} {$i < $numnode} {incr i} { set sink($i) [new Agent/LossMonitor] $ns_ attach-agent $W(0) $sink($i) } # Create Bw0 and Bw1 -proc delaycheck { i timedelay LM startsim endsim} { global M1 f0 f1 f2 maxdelay mindelay sink5 sink0 sink1 sink2 t pktsdelay1 #Get an instance of the simulator set ns_ [Simulator instance] #Set the time after which the procedure should be called again set time 0.05 Nguyễn Trường Giang 060562D Page 84 Voice Over Wireless LAN set bw0 [$LM set lastPktTime_ ] set bw1 [$LM set bytes_] set bw2 [$LM set npkts_] #Get the current time set now [$ns_ now] #Calculate the bandwidth (in MBit/s) and write it to the files if {$bw0 > 0} { puts $f0 "$now [expr $now - $bw0]" } puts $f2 "$now [expr $bw2]" puts $f1 "$now [expr $bw1/$time*8/1000000]" puts "$now $bw0 [expr [expr $now - $bw0]*1000 ]" if { ($now = $timedelay) & ($bw0 > $startsim )} { incr t incr pktsdelay($i) set intervaldelay [expr $now - $bw0] } #Reset the bytes_ values on the traffic sinks $LM set lastPktTime_ $LM set bytes_ $LM set npkts_ #Re-schedule the procedure if { ($now 0.0 } { incr qe($so) } puts "num of channel delay $so = , $qe($so) " } } set sim_interval set start set T_sim 20.0 set end $T_sim set rate 64000.0 set size 256 set ontime set idle set t set delaychan for {set l 0} {$l < $sim_interval } { incr l} { set qe($l) $ns_ at $start "reset" segment-sim $start $end $size $ontime $idle $rate for {set i } {$i < $numnode } {incr i } { set pktsdelay($i) #if {[delaycheck $i 0.05 $sink($i) $start $end]== } { incr numchan}; delaycheck $i 0.05 $sink($i) $start $end } set sumband($l) [expr $rate*2/3*$i] set loadper($l) [expr $sumband($l)/11000000*100] $ns_ at $end " ndelaychan $numnode $l "; set start [expr $start + $T_sim + 5.0] set end [expr $start + $T_sim] set rate [expr $rate + 64000 ] } # Start logging the received bandwidth Nguyễn Trường Giang 060562D Page 86 Voice Over Wireless LAN $ns_ at [expr $end + 1.0] "finish" $ns_ at 0.0 "init" proc reset {} { global numnode pktsdelay for {set i } {$i < $numnode } {incr i } { set pktsdelay($i) } } # -Define node movement model puts "Loading scenario file " source $opt(sc) # -Tell all nodes when the simulation ends -for {set p 0} {$p < $opt(nn) } {incr p} { $ns_ at $opt(stop).0010 "$node_($p) reset"; } $ns_ at $opt(stop).0010 "$BS(0) reset"; $ns_ at $opt(stop).1 "puts \"NS EXITING \" ; $ns_ halt" puts "Starting Simulation " $ns_ run Nguyễn Trường Giang 060562D Page 87

Ngày đăng: 30/10/2022, 18:02

w