Kỹ thuật lưu lượng trong chuyển mạch nhãn đa giao thức (mpls te)

109 10 0
Kỹ thuật lưu lượng trong chuyển mạch nhãn đa giao thức (mpls   te)

Đ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

Tr-ờng đại học vinh khoa điện tử viễn thông === === đồ án tốt nghiệp đại học Đề tài: Kỹ THUậT LƯU LƯợNG TRONG CHUYểN MạCH NHÃN ĐA GIAO THøC (MPLS - TE) Ng-êi h-íng dÉn Sinh viªn thùc hiƯn Líp M· sè sinh viªn : : : : KS lê văn ch-ơng võ trung hiếu 48K - ĐTVT 0751083498 NghÖ an - 01/2012 BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC VINH CỘNG HỊA XÃ HƠI CHỦ NGHĨA VIỆT NAM Độc lập - Tự - Hạnh phúc NHIỆM VỤ ĐỒ ÁN TỐT NGHIỆP Họ tên sinh viên: Võ Trung Hiếu Mã sinh viên: 0751083498 Khoá học: 48 Khoa: Điện tử Viễn thông Ngành: Điện tử Viễn thông Đầu đề đồ án: Các số liệu liệu ban đầu: Nội dung phần thuyết minh tính toán: Các vẽ, đồ thị ( ghi rõ loại kích thước vẽ ): Họ tên giảng viên hướng dẫn: KS Lê Văn Chương Ngày giao nhiệm vụ đồ án: / /20 Ngày hoàn thành đồ án: / /20 Ngày tháng năm 2012 TRƯỞNG BỘ MÔN NGƯỜI HƯỚNG DẪN Sinh viên hoàn thành nộp đồ án tốt nghiệp ngày tháng năm 2012 CÁN BỘ PHẢN BIỆN BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC VINH - BẢN NHẬN XÉT ĐỒ ÁN TỐT NGHIỆP Họ tên sinh viên: Số hiệu sinh viên: Ngành: Khoá: Giảng viên hướng dẫn: Cán phản biện: Nội dung thiết kế tốt nghiệp: Nhận xét cán phản biện: Ngày tháng năm Cán phản biện (Ký, ghi rõ họ tên) MỤC LỤC Trang LỜI NÓI ĐẦU DANH MỤC HÌNH VẼ, BẢNG BIỂU CÁC THUẬT NGỮ VIẾT TẮT Chương TỔNG QUAN VỀ CÁC CÔNG NGHỆ CHUYỂN MẠCH 1.1 Giới thiệu chung 1.1.1 Khái quát công nghệ chuyển mạch 1.1.2 Động lực đời công nghệ MPLS 10 1.2 Giới thiệu công nghệ MPLS 11 1.2.1 Lịch sử phát triển công nghệ MPLS 11 1.2.2 Khái niệm MPLS 12 1.2.3 Các ưu điểm ứng dụng MPLS 13 Chương CÔNG NGHỆ CHUYỂN MẠCH MPLS 15 2.1 Các khái niệm mạng sử dụng công nghệ MPLS 15 2.1.1 Nhãn ( Lable) 15 2.1.2 LSR LER 20 2.1.3 Lớp chuyển tiếp tương đương ( FEC ) 21 2.1.4 Mặt phẳng điều hành mặt phẳng liệu 21 2.2 Các thành phần mạng sử dụng công nghệ MPLS 23 2.3 Các giao thức MPLS 24 2.3.1 Các giao thức phân bố nhãn LPD 25 2.3.2 Giao thức CR-LPD 32 2.3.3 Giao thức MPLS – BGP 34 2.4 Hoạt động mạng sử dụng công nghệ MPLS 34 2.4.1 Chế độ hoạt động khung 36 2.4.2 Chế độ hoạt động tế bào 38 Chương KỸ THUẬT LƯU LƯỢNG TRONG MPLS 42 3.1 Kỹ thuật lưu lượng ( Traffic Engineering ) 42 3.1.2 Các lớp dịch vụ dựa nhu cầu QoS lớp lưu lượng 43 3.1.3 Hàng đợi lưu lượng 43 3.1.4 Giải thuật thùng rò thùng token 45 3.1.5 Giải pháp mơ hình chồng phủ ( Overlay Model ) 47 3.2 MPLS kỹ thuật lưu lượng 48 3.2.1 Khái niệm trung kế lưu lượng ( Traffic truck ) 48 3.2.2 Đồ hình nghiệm suy 49 3.2.3 Bài toán sở kỹ thuật lưu lượng 49 3.3 Trung kế lưu lượng thuộc tính 50 3.3.1 Các hoạt động trung kế lưu lượng 50 3.3.2 Thuộc tính tham số lưu lượng ( Traffic Parameter ) 50 3.3.3 Thuộc tính lựa chọn quản lý đường(chính sách chọn đường) 51 3.3.4 Thuộc tính ưu tiên / lấn chiếm ( Priority/Preemption ) 52 3.3.5 Thuộc tính đàn hồi ( Resilience ) 52 3.3.6 Thuộc tính khống chế ( Policing ) 53 3.4 Các thuộc tính tài nguyên 53 3.4.1 Bộ nhân cấp phát cực đại ( Maximum allocation multiplier ) 53 3.4.2 Lớp tài nguyên ( Resource – Class ) 53 3.4.3 TE Metric 54 3.5 Tính tốn đường ràng buộc 54 3.5.1 Quảng bá thuộc tính link 54 3.5.2 Tính toán LSP ràng buộc ( CR-LSP ) 55 3.5.3 Giải thuật chọn đường 56 3.5.4 Ví dụ chọn đường cho trung kế lưu lượng 56 3.5.5 Tái tối ưu hóa ( Re – optimization ) 58 3.6 Bảo vệ khôi phục đường 59 3.6.1 Phân loại chế bảo vệ khôi phục 59 3.6.2 Mơ hình Makam 60 3.6.3 Mơ hình Haskin ( Reverse Backup ) 61 3.6.4 Mơ hình Hundessa 62 3.6.5 Mơ hình Shortest – Dynamic 62 3.6.6 Mơ hình Simple – Dynamic 63 3.6.7 Mơ hình Simple – Static 63 Chương MÔ PHỎNG HỆ THỐNG MPLS – TE VÀ ĐÁNH GIÁ 64 4.1 Phương pháp công cụ mô 64 4.1.1 Phương pháp phân tích 64 4.1.2 Chuẩn bị công cụ mô 65 4.2 Nội dung kết mô 65 4.2.1 Mô mạng IP không hỗ trợ MPLS : 66 4.2.2 Mô định tuyến ràng buộc mạng MPLS 67 4.2.3 Mô hoạt động lấn chiếm ( Preemption ) với độ ưu tiên 69 4.2.4 Mô khôi phục đường theo chế Makam 71 4.2.5 Mô khôi phục đường theo chế Haskin ( Reverse Backup ) 74 4.2.6 Mô khôi phục đường theo chế Shortest – Dynamic 75 4.2.7 Mô khôi phục đường theo chế Simple – Dynamic 77 KẾT LUẬN 79 TÀI LIỆU THAM KHẢO 80 PHỤ LỤC 81 LỜI NÓI ĐẦU Sự phát triển nhanh chóng dịch vụ IP bùng nổ Internet dẫn đến loạt thay đổi nhận thức kinh doanh nhà khai thác Lưu lượng lớn mạng đường trục lưu lượng IP Giao thức IP thống trị toàn giao thức lớp mạng, hệ tất xu hướng phát triển công nghệ lớp hỗ trợ cho IP Nhu cầu thị trường cấp bách cho mạng tốc độ cao với chi phí thấp sở cho loạt cơng nghệ đời, có MPLS Trong năm gần khoảng thời gian mà cơng nghệ MPLS chứng minh tính ứng dụng thực tiễn tính vượt trội so với công nghệ chuyển mạch truyền thống khác ATM Tập đoàn BCVT Việt Nam lựa chọn IP/MPLS làm công nghệ cho lớp chuyển tải mạng NGN triển khai phạm vi toàn quốc Một ưu điểm lớn MPLS khả thực kỹ thuật lưu lượng Đây đối tượng nghiên cứu sinh viên đề tài Đề tài tổ chức thành chương với nội dung sau : Chương – Tổng quan công nghệ chuyển mạch Chương – Công nghệ chuyển mạch MPLS Chương – Kỹ thuật lưu lượng MPLS Chương – Mô hệ thống MPLS – TE đánh giá Sinh viên mong nhận ý kiến đóng góp q thầy cơ, bạn để hồn thiện thêm kiến thức lĩnh vực Qua đây, sinh viên bày tỏ tri ân sâu sắc đến KS Lê Văn Chương, giáo viên hướng dẫn giúp đỡ suốt trình thực đề tài SINH VIÊN THỰC HIỆN Võ Trung Hiếu DANH SÁCH HÌNH VẼ Hình 1.1: Các công nghệ chuyển mạch Hình 1.2: Hình 1.3: Mơ hình chuyển mạch kênh Mơ hình chuyển mạch gói Hình 2.1: Hình 2.2: Hình 2.3: Định dạng chung nhãn MPLS 16 Đặc điểm chung chồng nhãn 17 Đường chuyển mạch nhãn LSP 18 Hình 2.4: Hình 2.5: Upstream Downstream 19 Cơ cấu báo hiệu 20 Hình 2.6: Hình 2.7: Hình 2.8: Vị trí LSR LER mạng MPLS 20 Mặt phẳng điều khiển mặt phẳng liệu 21 Thành phần mặt phẳng điều khiển mặt phẳng liệu 22 Hình 2.9: Mơ hình mạng MPLS 23 Hình 2.10: Thủ tục phát LSR lân cận 26 Hình 2.11: Tiêu đề LDP 27 Hình 2.12: Hình 2.13: Hình 2.14: Hình 2.15: Mã hoá TLV 27 Khuôn dạng tin LDP 28 Chế độ phân phối nhãn tự nguyện theo yêu cầu 31 Tạo LSP chuyển tiếp gói tin thơng qua miền MPLS 36 Hình 2.16: Hình 2.17: Hình 3.1: Hình 3.2: Mạng MPLS hoạt động chế độ khung 36 Phân bổ nhãn mạng ATM-MPLS 40 Nhiều luồng cho lớp lưu lượng 44 Hàng đợi CQ 45 Hình 3.3: Hình 3.4: Hình 3.5: Hình 3.6: Hình 3.7: Hình 3.8: Hình 3.9: Hình 3.10: Hàng đợi PQ 45 Giải thuật thung rò 46 Giải thuật thùng token 46 Mơ hình chồng phủ ( Overlay mode ) 47 Các trung kế lưu lượng 48 Một ví dụ băng thơng dự trữ cho mức ưu tiên 53 Minh họa cho cách dùng bit Affinity Resource-Class 54 Băng thông khả dụng ứng với mức ưu tiên 55 Hình 3.11: Hình 3.12: Hình 3.13: Hình 3.14: Xem xét buộc khống chế 57 Xem xét tài nguyên khả dụng 57 Chọn đường tốt 58 Mơ hình Makam 61 Hình 3.15: Mơ hình Haskin 62 Hình 3.16: Mơ hình Shortest – Dynamic 62 Hình 3.17: Mơ hình Simple – Dynamic 63 Hình 4.1: Dữ liệu đầu vào kết xuất NS 64 Hình 4.2: Topology vật lý mạng thực mô 65 Hình 4.3: Hình 4.4: Hình 4.5: Kết băng thông nhận 66 Mô trực quan cửa sổ NAM 67 Kết băng thông nhận 68 Hình 4.6: Hình 4.7: Mô trực quan cửa sổ NAM 69 Xuất nội dung bảng LIB LSR hình console 69 Hình 4.8: Hình 4.9: Kết băng thơng nhận 70 Mô trực quan cửa sổ NAM 71 Hình 4.10: Hình 4.11: Hình 4.12: Hình 4.13: Kết băng thông nhận 72 Đường lưu lượng trước thời điểm cố 73 Đường lưu lượng sau thời điểm cố (Makam) 73 Kết băng thông nhận 74 Hình 4.14: Đường lưu lượng sau thời điểm cố ( Haskin) 75 Hình 4.15: Hình 4.16: Hình 4.17: Hình 4.18: Kết băng thông nhận 76 Đường lưu lượng sau thời điểm cố ( Shortest – Dynamic) 76 Kết băng thông nhận từ 77 Đường lưu lượng sau thời điểm cố ( Simple – Dynamic) 78 CÁC THUẬT NGỮ VIẾT TẮT Từ viết tắt AAL ACL AS ASBR ATM BGP CE CEM CEP CoS DLCI EGP FEC FR GRE HDLC HEC ID IGP IP IPLS IP-Sec ISP L2F L2TP LAC LAN LDP LER LNS LSP LSR M2M MD MPLS MPLS-TE MT MTI Từ đầy đủ ATM Adapter Layer Access Control List Autonomous System Autonomous System Border Router Asynchronous Transfer Mode Border Gateway Protocol Customer Edge Circuit Emulation Service over MPLS Circuit Emulation over Packet Class of Service Data Link Connection Identifier External Gateway Protocol Forwarding Equivalence Class Frame Relay Generic RoutingEncapsulation High-level Data Link Control Header Error Controller Identifier Interior Gateway Protocol Internet Protocol IP-Only Private LAN Service Internet Protocol Security Internet Service Provider Layer Forwarding Layer Tunneling Protocol L2TP Access Concentrator Local Area Network Label Distribution Protocol Label Edge Router L2TP Network Server Label Switching Path Label Switching Router Multipoint-to-Multipoint Multicast Domain MultiProtocol Label Switching MPLS-Traffice Engineering Multicast Tunnel Multicast Tunnel Interface Chú giải tiếng Việt Lớp tương thích ATM Danh sách điều khiển truy cập Hệ thống tự trị Bộ định tuyến biên hệ thống tự trị Cơ chế truyền tải không đồng Giao thức định tuyến cổng miền Thiết bị biên mạng người dùng Dịch vụ mô kênh MPLS Mô kênh gói Lớp dịch vụ Nhận dạng kết nối lớp kênh liệu Giao thức định tuyến liên miền Lớp chuyển tiếp tương đương Chuyển mạch khung Giao thức đóng gói định tuyến chung Điều khiển liên kết liệu mức cao Điều khiển lỗi tiêu đề Nhận dạng Giao thức định tuyến miền Giao thức Internet Dịch vụ LAN thuê riêng IP Giao thức an ninh Internet Nhà cung cấp dịch vụ Internet Giao thức chuyển tiếp lớp Giao thức đường hầm lớp Bộ tập trung truy cập L2TP Mạng cục Giao thức phân bổ nhãn Bộ định tuyến chuyển mạch nhãn biên Máy chủ mạng L2TP Đường chuyển mạch nhãn Bộ định tuyến chuyển mạch nhãn Đa điểm tới đa điểm Miền đa điểm Chuyển mạch nhãn đa giao thức Kỹ thuật lưu lượng Đường hầm đa điểm Giao diện đường hầm đa điểm NAS NGN OSPF Network Access Server Next Generation Network Open Shortest Path First PAC PE PNS POP PPP PVC PW QoS RD RSVP RT SDH SDU SONET SP TCP TDP UDP VC VCI VLLS VP VPDN VPI VPLS VPN VPWS VR VRF PPTP Access Concentrator Provider Edge PPTP Network Server Point of Presence Point to Point Tunneling Protocol Permanent Virtual Circuit Pseudowire Quality of Service Route Distinguisher Resource Reservation Protocol Route Target Synchronous Digital Hierachy Service Data Unit Synchronous Optical Network Service Provider Transmission Control Protocol Tag Distribution Protocol User Datagram Protocol Virtual Circuit Virtual Circuit Identifier Virtual Leased Line Service Virtual Path Virtual Private Dial Network Virtual Path Identifier Virtual Private LAN Service Virtual Private Network Virtual Private Wire Service Virtual Router VPN Routing and Forwarding Máy chủ truy cập mạng Mạng hệ Giao thức đường ngắn Bộ tập trung truy cập PPTP Thiết bị biên mạng nhà cung cấp Máy chủ mạng PPTP Điểm truy cập truyền thống Giao thức đường hầm điểm tới điểm Kênh ảo cố định Dây giả Chất lượng dịch vụ Thuộc tính phân biệt tuyến Giao thức dành trước tài nguyên Thuộc tính tuyến đích Phân cấp số đồng Đơn vị liệu dịch vụ Mạng quang đồng Nhà cung cấp dịch vụ Giao thức điều khiển truyền dẫn Giao thức phân phối thẻ Giao thức lược đồ liệu Kênh ảo Nhận dạng kênh ảo Dịchvụ đường dây thuê riêng ảo Đường ảo Mạng quay số riêng ảo Nhận dạng đường ảo Dịch vụ LAN riêng ảo Mạng riêng ảo Dịch vụ đường dây riêng ảo Bộ định tuyến ảo Bảng định tuyến chuyển tiếp VPN set m LSR$i eval $$m color blue } set R10 [$ns node] # Khai bao link: odes bw delay queue $ns duplex-link $R0 $LSR1 3Mb 10ms DropTail $ns duplex-link $LSR1 $LSR3 2Mb 30ms DropTail $ns duplex-link $LSR3 $LSR5 1Mb 30ms DropTail $ns duplex-link $LSR5 $LSR7 2Mb 30ms DropTail $ns duplex-link $LSR7 $LSR9 1Mb 30ms DropTail $ns duplex-link $LSR9 $R10 3Mb 10ms DropTail $ns duplex-link $LSR1 $LSR2 1Mb 30ms DropTail $ns duplex-link $LSR2 $LSR4 1Mb 30ms DropTail $ns duplex-link $LSR4 $LSR6 2Mb 30ms DropTail $ns duplex-link $LSR6 $LSR8 1Mb 30ms DropTail $ns duplex-link $LSR8 $LSR9 2Mb 30ms DropTail $ns duplex-link $LSR3 $LSR4 1Mb 30ms DropTail $ns duplex-link $LSR5 $LSR6 1Mb 30ms DropTail $ns duplex-link $LSR7 $LSR8 1Mb 30ms DropTail # Ve dang so mang $ns duplex-link-op $R0 $LSR1 orient right $ns duplex-link-op $LSR1 $LSR3 orient right $ns duplex-link-op $LSR3 $LSR5 orient right $ns duplex-link-op $LSR5 $LSR7 orient right $ns duplex-link-op $LSR7 $LSR9 orient right $ns duplex-link-op $LSR9 $R10 orient right $ns duplex-link-op $LSR1 $LSR2 orient 0.333 $ns duplex-link-op $LSR2 $LSR4 orient right $ns duplex-link-op $LSR4 $LSR6 orient right $ns duplex-link-op $LSR6 $LSR8 orient right $ns duplex-link-op $LSR8 $LSR9 orient 1.667 $ns duplex-link-op $LSR3 $LSR4 orient 0.333 $ns duplex-link-op $LSR5 $LSR6 orient 0.333 $ns duplex-link-op $LSR7 $LSR8 orient 0.333 # Ghi chu $ns duplex-link-op $LSR1 $LSR3 label " 2M " $ns duplex-link-op $LSR3 $LSR5 label " 1M " $ns duplex-link-op $LSR5 $LSR7 label " 2M " $ns duplex-link-op $LSR7 $LSR9 label " 1M " $ns duplex-link-op $LSR1 $LSR2 label " 1M " $ns duplex-link-op $LSR2 $LSR4 label " 1M " $ns duplex-link-op $LSR4 $LSR6 label " 2M " $ns duplex-link-op $LSR6 $LSR8 label " 1M " $ns duplex-link-op $LSR8 $LSR9 label " 2M" $ns duplex-link-op $LSR3 $LSR4 label " 1M " $ns duplex-link-op $LSR5 $LSR6 label " 1M " $ns duplex-link-op $LSR7 $LSR8 label " 1M " $R0 label "Nguon" $R10 label "Dich" $LSR1 label "Ingress " $LSR9 label " Egress" # Cau hinh LDP agent tren tat ca cac nut MPLS $ns configure-ldp-on-all-mpls-nodes # Dat color cho cac ban tin LDP $ns ldp-request-color blue $ns ldp-mapping-color red $ns ldp-withdraw-color magenta $ns ldp-release-color orange $ns ldp-notification-color green # -# Dinh nghia cac ham su dung chuong trinh chinh # -# Tao mot procedure ghi nhan bang thong theo mot chu ki $time proc record {} { global sink1 f1 set ns [Simulator instance] # Dinh chu ki ghi nhan bang thong 92 set time 0.1 # Lay so luong packet nhan duoc chu ky o moi sink set bw1 [$sink1 set bytes_] set now [$ns now] puts $f1 "$now [expr $bw1/$time*8/1000000]" # Reset gia tri bytes_ cua sink $sink1 set bytes_ #Dinh thoi goi lai ham record sau chu ky $time $ns at [expr $now+$time] "record" } # -set prvseqnb -1 set seqerrnb # Thu tuc ghi lai so packet nhan duoc dung thu tu proc seq-record {size rate ftime} { global prvseqnb seqerrnb sink1 f2 set ns [Simulator instance] # Dat chu ky thoi gian chay lai thu tuc set tsize [parse-bw $size] set trate [parse-bw $rate] set time [expr double($tsize)/double($trate)/8.0] set now [$ns now] # Tim so thu tu cua packet set revseqnb [$sink1 set expected_] if {$prvseqnb > $revseqnb} { incr seqerrnb } # Ghi so thu tu cua packet vao file if {$prvseqnb != $revseqnb} { puts $f2 "$now [$sink1 set expected_]" set prvseqnb $revseqnb } # Dinh thoi goi lai ham seq-record if { [expr $now+$time] < $ftime } { $ns at [expr $now+$time] "seq-record $size $rate $ftime" } } # -# Ham tao mot nguon luu luong gan vao node voi sink, size goi, # burst, idle time, rate va colour cua luu luong proc attach-expoo-traffic { node sink size burst idle rate } { set ns [Simulator instance] set source [new Agent/CBR/UDP] $ns attach-agent $node $source set traffic [new Traffic/Expoo] $traffic set packet-size $size $traffic set burst-time $burst $traffic set idle-time $idle $traffic set rate $rate $source attach-traffic $traffic $ns connect $source $sink return $source } # -# Thu tuc sau thong bao ER/CR-LSP da thiet lap de thuc hien tac vu khac proc notify-erlsp-setup {node lspid} { global src1 src2 set ns [Simulator instance] set msg " [string range [$ns now] 3]s: Tunnel LSP_$lspid (Ingress=LSR[$node id]) da duoc thiet lap xong !" puts $msg $ns trace-annotate $msg set module [$node get-module "MPLS"] switch $lspid { 1100 { 93 $module bind-flow-erlsp 10 100 $lspid } 1200 { $module reroute-lsp-binding } default { puts " Error!" exit } 1100 $lspid } } proc notify-erlsp-fail {node status lspid tr} { set ns [Simulator instance] set module [$node get-module "MPLS"] if { [$node id] == && $status=="BSNodeError" } { $module set-lib-error-for-lspid $lspid set msg " [string range [$ns now] 3]s: Phat hien loi tren duong lam viec LSP_$lspid Chuyen sang duong bao ve LSP_1200 !" } if { [$node id] == && $status=="NodeRepair" } { $module set-lib-error-for-lspid $lspid -1 set msg " [string range [$ns now] 3]s: Loi da duoc khoi phuc Chuyen luu luong tro lai duong lam viec LSP_$lspid !" } puts $msg $ns trace-annotate $msg } # -# Thu tuc xuat tong so packet nhan duoc o cac sink proc recv-pkts {} { global sink1 seqerrnb set ns [Simulator instance] set msg " Luong da truyen [$sink1 set expected_] goi, mat [$sink1 set nlost_] goi, ti le mat goi la [string range [expr [$sink1 set nlost_]*100.0/[$sink1 set expected_]] 3] */*" puts $msg $ns trace-annotate $msg set msg " Tong so packet bi sai thu tu : $seqerrnb goi" puts $msg $ns trace-annotate $msg } # -# Thu tuc dong file va the hien ket qua ket thuc mo phong proc finish {} { global ns nf f1 f2 $ns flush-trace close $nf close $f1 close $f2 exec xgraph luong_1.tr -M -nb -bg white -fg black -zg black \ -geometry 500x250 -y "BW (Mbps)" -x "Time (sec)" \ -t "Bai 4: Khoi phuc duong theo co che Makam" -tf "helvetica-12" & exec xgraph luong_seq.tr -p -nl -nb -bg white -fg black -zg black \ -geometry 500x250 -y "Packet No." -x "Time (sec)" \ -t "Bai 4: Bieu so thu tu packet theo thoi gian" -tf "helvetica12" & exec nam -r 2ms bai4.nam & exit } # -# Tao sink1 gan voi nut R10 (day la noi thu nhan traffic) set sink1 [new Agent/LossMonitor] $ns attach-agent $R10 $sink1 # Tao nguon luu luong src1 gan voi nut R0 bang cach 94 # goi ham attach-expoo-traffic Luong co packet_size=600, rate=0.8Mbps set src1 [attach-expoo-traffic $R0 $sink1 600B 0 0.8M ] $src1 set fid_ 100 $ns color 100 red # Cai dat co che khoi phuc: MAKAM $ns enable-reroute notify-prenegotiated [$LSR3 get-module "MPLS"] set-protection-lsp 0.7 0.01 1100 [$LSR5 get-module "MPLS"] set-protection-lsp 0.7 0.01 1100 [$LSR7 get-module "MPLS"] set-protection-lsp 0.7 0.01 1100 # Bat dau mo phong exec clear >@ stdout puts "\n BAI 4: KHOI PHUC DUONG BANG TAI DINH TUYEN TOAN CUC (MAKAM)\n" $ns at 0.00 "record" $ns at 0.00 "seq-record 600 800k 5.5" # Thiet lap LSP lam viec $ns at 0.15 "$ns trace-annotate {Bao hieu thiet lap duong lam viec: LSP_1100, ER=1_3_5_7_9 }" $ns at 0.15 "[$LSR1 get-module "MPLS"] setup-erlsp 1_3_5_7_9 1100" # Thiet lap LSP bao ve $ns at 0.15 "$ns trace-annotate {Bao hieu thiet lap duong bao ve: LSP_1200, ER=1_2_4_6_8_9 }" $ns at 0.15 "[$LSR1 get-module "MPLS"] setup-erlsp 1_2_4_6_8_9 1200" $ns at 0.50 "$ns trace-annotate {Luong 1: BW=0.8M (start=0.5 stop=5.0) su dung LSP_1100, ER=1_3_5_7_9 }" $ns at 0.50 "$src1 start" # Link giua LSR5 va LSR7 bi dut tu 2.0s, den 3.5s thi khoi phuc lai $ns rtmodel-at 2.0 down $LSR5 $LSR7 $ns rtmodel-at 3.5 up $LSR5 $LSR7 $ns at 5.0 "$src1 stop" $ns at 5.5 "recv-pkts" $ns at 5.5 "finish" $ns run Bai5.tcl ######################################################################## # BAI 5: KHOI PHUC DUONG THEO CO CHE DU PHONG DAO (REVERSE BACKUP) # # (MO HINH HASKIN) # ######################################################################## # Tao mot doi tuong mo phong set ns [new Simulator] $ns rtproto LS # Tao file de xuat ket qua cho NAM set nf [open bai5.nam w] $ns namtrace-all $nf # Tao cac file de luu du lieu cho xgraph set f1 [open luong_1.tr w] set f2 [open luong_seq.tr w] # So ket noi mang # 1M 2M 1M # LSR2 -LSR4 -LSR6 -LSR8 # / / / / \ # / / / / \ # 1M / 1M / 1M / 1M / \ 2M # / / / / \ # / / / / \ # R0 -LSR1 -LSR3 -LSR5 -LSR7 LSR9 R10 # 2M 1M 2M 1M # Khai bao nut IP (R0,R10) va nut MPLS (LSR1 > LSR9) set R0 [$ns node] foreach i "1 9" { set LSR$i [$ns mpls-node] set m LSR$i 95 eval $$m color blue } set R10 [$ns node] # Khai bAo link: odes bw delay queue $ns duplex-link $R0 $LSR1 3Mb 10ms DropTail $ns duplex-link $LSR1 $LSR3 2Mb 30ms DropTail $ns duplex-link $LSR3 $LSR5 1Mb 30ms DropTail $ns duplex-link $LSR5 $LSR7 2Mb 30ms DropTail $ns duplex-link $LSR7 $LSR9 1Mb 30ms DropTail $ns duplex-link $LSR9 $R10 3Mb 10ms DropTail $ns duplex-link $LSR1 $LSR2 1Mb 30ms DropTail $ns duplex-link $LSR2 $LSR4 1Mb 30ms DropTail $ns duplex-link $LSR4 $LSR6 2Mb 30ms DropTail $ns duplex-link $LSR6 $LSR8 1Mb 30ms DropTail $ns duplex-link $LSR8 $LSR9 2Mb 30ms DropTail $ns duplex-link $LSR3 $LSR4 1Mb 30ms DropTail $ns duplex-link $LSR5 $LSR6 1Mb 30ms DropTail $ns duplex-link $LSR7 $LSR8 1Mb 30ms DropTail # Ve dang so mang $ns duplex-link-op $R0 $LSR1 orient right $ns duplex-link-op $LSR1 $LSR3 orient right $ns duplex-link-op $LSR3 $LSR5 orient right $ns duplex-link-op $LSR5 $LSR7 orient right $ns duplex-link-op $LSR7 $LSR9 orient right $ns duplex-link-op $LSR9 $R10 orient right $ns duplex-link-op $LSR1 $LSR2 orient 0.333 $ns duplex-link-op $LSR2 $LSR4 orient right $ns duplex-link-op $LSR4 $LSR6 orient right $ns duplex-link-op $LSR6 $LSR8 orient right $ns duplex-link-op $LSR8 $LSR9 orient 1.667 $ns duplex-link-op $LSR3 $LSR4 orient 0.333 $ns duplex-link-op $LSR5 $LSR6 orient 0.333 $ns duplex-link-op $LSR7 $LSR8 orient 0.333 # Ghi chu $ns duplex-link-op $LSR1 $LSR3 label " 2M " $ns duplex-link-op $LSR3 $LSR5 label " 1M " $ns duplex-link-op $LSR5 $LSR7 label " 2M " $ns duplex-link-op $LSR7 $LSR9 label " 1M " $ns duplex-link-op $LSR1 $LSR2 label " 1M " $ns duplex-link-op $LSR2 $LSR4 label " 1M " $ns duplex-link-op $LSR4 $LSR6 label " 2M " $ns duplex-link-op $LSR6 $LSR8 label " 1M " $ns duplex-link-op $LSR8 $LSR9 label " 2M" $ns duplex-link-op $LSR3 $LSR4 label " 1M " $ns duplex-link-op $LSR5 $LSR6 label " 1M " $ns duplex-link-op $LSR7 $LSR8 label " 1M " $R0 label "Nguon" $R10 label "Dich" $LSR1 label "Ingress " $LSR9 label " Egress" # Cau hinh LDP agent tren tat ca cac nut MPLS $ns configure-ldp-on-all-mpls-nodes # Dat color cho cac ban tin LDP $ns ldp-request-color blue $ns ldp-mapping-color red $ns ldp-withdraw-color magenta $ns ldp-release-color orange $ns ldp-notification-color green # -# Dinh nghia cac ham su dung chuong trinh chinh # -# Tao mot procedure ghi nhan bang thong theo mot chu ki $time proc record {} { global sink1 f1 set ns [Simulator instance] # Dinh chu ki ghi nhan bang thong set time 0.1 # Lay so luong packet nhan duoc chu ky o moi sink 96 set bw1 [$sink1 set bytes_] set now [$ns now] puts $f1 "$now [expr $bw1/$time*8/1000000]" Reset gia tri bytes_ cua sink $sink1 set bytes_ #Dinh thoi goi lai ham record sau chu ky $time $ns at [expr $now+$time] "record" } # -set prvseqnb -1 set seqerrnb # Thu tuc ghi lai so packet nhan duoc dung thu tu proc seq-record {size rate ftime} { global prvseqnb seqerrnb sink1 f2 set ns [Simulator instance] # Dat chu ky thoi gian chay lai thu tuc set tsize [parse-bw $size] set trate [parse-bw $rate] set time [expr double($tsize)/double($trate)/8.0] set now [$ns now] # Tim so thu tu cua packet set revseqnb [$sink1 set expected_] if {$prvseqnb > $revseqnb} { incr seqerrnb } # Ghi so thu tu cua packet vao file if {$prvseqnb != $revseqnb} { puts $f2 "$now [$sink1 set expected_]" set prvseqnb $revseqnb } # Dinh thoi goi lai ham seq-record if { [expr $now+$time] < $ftime } { $ns at [expr $now+$time] "seq-record $size $rate $ftime" } } # -# Ham tao mot nguon luu luong gan vao node voi sink, size goi, # burst, idle time, rate va colour cua luu luong proc attach-expoo-traffic { node sink size burst idle rate } { set ns [Simulator instance] set source [new Agent/CBR/UDP] $ns attach-agent $node $source set traffic [new Traffic/Expoo] $traffic set packet-size $size $traffic set burst-time $burst $traffic set idle-time $idle $traffic set rate $rate $source attach-traffic $traffic $ns connect $source $sink return $source } # -# Thu tuc sau thong bao ER/CR-LSP da thiet lap de thuc hien tac vu khac proc notify-erlsp-setup {node lspid} { global src1 src2 LSR3 LSR5 LSR7 set ns [Simulator instance] set msg " [string range [$ns now] 3]s: Tunnel LSP_$lspid (Ingress=LSR[$node id]) da duoc thiet lap xong !" puts $msg $ns trace-annotate $msg set module [$node get-module "MPLS"] switch $lspid { 1100 { $module bind-flow-erlsp 10 100 $lspid } 1200 { 97 $module reroute-lsp-binding 1100 $lspid } 1300 { [$LSR3 get-module "MPLS"] reroute-lsp-binding [$LSR5 get-module "MPLS"] reroute-lsp-binding [$LSR7 get-module "MPLS"] reroute-lsp-binding 1100 1100 1100 $lspid $lspid $lspid } default { puts " Error!" exit } } } proc notify-erlsp-fail {node status lspid tr} { set ns [Simulator instance] set module [$node get-module "MPLS"] if { [$node id] == && $status=="BSNodeError" } { $module set-lib-error-for-lspid $lspid set msg " [string range [$ns now] 3]s: Phat hien loi tren duong lam viec LSP_$lspid Chuyen sang duong bao ve LSP_1200 !" } if { [$node id] == && $status=="NodeRepair" } { $module set-lib-error-for-lspid $lspid -1 set msg " [string range [$ns now] 3]s: Loi da duoc khoi phuc Chuyen luu luong tro lai duong lam viec LSP_$lspid !" } puts $msg $ns trace-annotate $msg } # -# Thu tuc xuat tong so packet nhan duoc o cac sink proc recv-pkts {} { global sink1 seqerrnb set ns [Simulator instance] set msg " Luong da truyen [$sink1 set expected_] goi, mat [$sink1 set nlost_] goi, ti le mat goi la [string range [expr [$sink1 set nlost_]*100.0/[$sink1 set expected_]] 3] */*" puts $msg $ns trace-annotate $msg set msg " Tong so packet bi sai thu tu : $seqerrnb goi" puts $msg $ns trace-annotate $msg } # -# Thu tuc dong file va the hien ket qua ket thuc mo phong proc finish {} { global ns nf f1 f2 $ns flush-trace close $nf close $f1 close $f2 exec xgraph luong_1.tr -M -nb -bg white -fg black -zg black \ -geometry 500x230 -y "BW (Mbps)" -x "Time (sec)" \ -t "Bai 5: Khoi phuc duong theo co che Haskin" -tf "helvetica-12" & exec xgraph luong_seq.tr -p -nl -nb -bg white -fg black -zg black \ -geometry 500x250 -y "Packet No." -x "Time (sec)" \ -t "Bai 5: Bieu so thu tu packet theo thoi gian" -tf "helvetica12" & exec nam -r 2ms bai5.nam & exit } # -# Tao sink1 gan voi nut R10 (day la noi thu nhan traffic) set sink1 [new Agent/LossMonitor] $ns attach-agent $R10 $sink1 # Tao nguon luu luong src1 gan voi nut R0 bang cach # goi ham attach-expoo-traffic Luong co packet_size=600, rate=0.8Mbps 98 set src1 [attach-expoo-traffic $R0 $sink1 600B 0 0.8M ] $src1 set fid_ 100 $ns color 100 red # Cai dat co che khoi phuc: HASKIN $ns enable-reroute drop [$LSR3 get-module "MPLS"] set-protection-lsp 0.7 0.01 1100 [$LSR5 get-module "MPLS"] set-protection-lsp 0.7 0.01 1100 [$LSR7 get-module "MPLS"] set-protection-lsp 0.7 0.01 1100 # Bat dau mo phong exec clear >@ stdout puts "\n BAI 5: KHOI PHUC DUONG CO CHE REVERSE BACKUP (HASKIN) \n " $ns at 0.0 "record" $ns at 0.0 "seq-record 600 800k 5.5" # Thiet lap LSP lam viec $ns at 0.1 "$ns trace-annotate {Bao hieu thiet lap duong lam viec: LSP_1100, ER=1_3_5_7_9 }" $ns at 0.1 "[$LSR1 get-module "MPLS"] setup-erlsp 1_3_5_7_9 1100” # Thiet lap LSP bao ve $ns at 0.1 "$ns trace-annotate {Bao hieu thiet lap duong bao ve: LSP_1200, ER=1_2_4_6_8_9 }" $ns at 0.1 "[$LSR1 get-module "MPLS"] setup-erlsp 1_2_4_6_8_9 1200” Thiet lap LSP du phong dao (reverse backup) $ns at 0.3 "$ns trace-annotate {Bao hieu thiet lap duong reverse backup: LSP_1300, ER=9_7_5_3_1_L1200 }" $ns at 0.3 "[$LSR9 get-module "MPLS"] setup-erlsp 9_7_5_3_1_L1200 1300” $ns at 0.5 "$ns trace-annotate {Luong 1: BW=0.8M (start=0.5 stop=5.0) su dung LSP_1100, ER=1_3_5_7_9 }" $ns at 0.5 "$src1 start" # Link giua LSR5 va LSR7 bi dut tu 2.0s, den 3.5s thi khoi phuc lai $ns rtmodel-at 2.0 down $LSR5 $LSR7 $ns rtmodel-at 3.5 up $LSR5 $LSR7 $ns at 5.0 "$src1 stop" $ns at 5.5 "recv-pkts" $ns at 5.5 "finish" $ns run Bai6.tcl ###################################################################### # BAI 6: KHOI PHUC DUONG THEO CO CHE SHORTEST-DYNAMIC # ###################################################################### # Tao mot doi tuong mo phong set ns [new Simulator] $ns rtproto LS # Tao file de xuat ket qua cho NAM set nf [open bai6.nam w] $ns namtrace-all $nf # Tao cac file de luu du lieu cho xgraph set f1 [open luong_1.tr w] set f2 [open luong_seq.tr w] # So ket noi mang # # 1M 2M 1M # LSR2 -LSR4 -LSR6 -LSR8 # / / / / \ # / / / / \ # 1M / 1M / 1M / 1M / \ 2M # / / / / \ # / / / / \ # R0 -LSR1 -LSR3 -LSR5 -LSR7 LSR9 R10 # 2M 1M 2M 1M # Khai bao nut IP (R0,R10) va nut MPLS (LSR1 > LSR9) set R0 [$ns node] foreach i "1 9" { 99 set LSR$i [$ns mpls-node] set m LSR$i eval $$m color blue } set R10 [$ns node] # Khai bao link: odes bw delay queue $ns duplex-link $R0 $LSR1 3Mb 10ms DropTail $ns duplex-link $LSR1 $LSR3 2Mb 30ms DropTail $ns duplex-link $LSR3 $LSR5 1Mb 30ms DropTail $ns duplex-link $LSR5 $LSR7 2Mb 30ms DropTail $ns duplex-link $LSR7 $LSR9 1Mb 30ms DropTail $ns duplex-link $LSR9 $R10 3Mb 10ms DropTail $ns duplex-link $LSR1 $LSR2 1Mb 30ms DropTail $ns duplex-link $LSR2 $LSR4 1Mb 30ms DropTail $ns duplex-link $LSR4 $LSR6 2Mb 30ms DropTail $ns duplex-link $LSR6 $LSR8 1Mb 30ms DropTail $ns duplex-link $LSR8 $LSR9 2Mb 30ms DropTail $ns duplex-link $LSR3 $LSR4 1Mb 30ms DropTail $ns duplex-link $LSR5 $LSR6 1Mb 30ms DropTail $ns duplex-link $LSR7 $LSR8 1Mb 30ms DropTail # Ve dang so mang $ns duplex-link-op $R0 $LSR1 orient right $ns duplex-link-op $LSR1 $LSR3 orient right $ns duplex-link-op $LSR3 $LSR5 orient right $ns duplex-link-op $LSR5 $LSR7 orient right $ns duplex-link-op $LSR7 $LSR9 orient right $ns duplex-link-op $LSR9 $R10 orient right $ns duplex-link-op $LSR1 $LSR2 orient 0.333 $ns duplex-link-op $LSR2 $LSR4 orient right $ns duplex-link-op $LSR4 $LSR6 orient right $ns duplex-link-op $LSR6 $LSR8 orient right $ns duplex-link-op $LSR8 $LSR9 orient 1.667 $ns duplex-link-op $LSR3 $LSR4 orient 0.333 $ns duplex-link-op $LSR5 $LSR6 orient 0.333 $ns duplex-link-op $LSR7 $LSR8 orient 0.333 # Ghi chu $ns duplex-link-op $LSR1 $LSR3 label " 2M " $ns duplex-link-op $LSR3 $LSR5 label " 1M " $ns duplex-link-op $LSR5 $LSR7 label " 2M " $ns duplex-link-op $LSR7 $LSR9 label " 1M " $ns duplex-link-op $LSR1 $LSR2 label " 1M " $ns duplex-link-op $LSR2 $LSR4 label " 1M " $ns duplex-link-op $LSR4 $LSR6 label " 2M " $ns duplex-link-op $LSR6 $LSR8 label " 1M " $ns duplex-link-op $LSR8 $LSR9 label " 2M" $ns duplex-link-op $LSR3 $LSR4 label " 1M " $ns duplex-link-op $LSR5 $LSR6 label " 1M " $ns duplex-link-op $LSR7 $LSR8 label " 1M " $R0 label "Nguon" $R10 label "Dich" $LSR1 label "Ingress " $LSR9 label " Egress" # Cau hinh LDP agent tren tat ca cac nut MPLS $ns configure-ldp-on-all-mpls-nodes # Dat color cho cac ban tin LDP $ns ldp-request-color blue $ns ldp-mapping-color red $ns ldp-withdraw-color magenta $ns ldp-release-color orange $ns ldp-notification-color green # Dinh nghia cac ham su dung chuong trinh chinh # -# Tao mot procedure ghi nhan bang thong theo mot chu ki $time proc record {} { global sink1 f1 set ns [Simulator instance] 100 # Dinh chu ki ghi nhan bang thong set time 0.1 # Lay so luong packet nhan duoc chu ky o moi sink set bw1 [$sink1 set bytes_] set now [$ns now] puts $f1 "$now [expr $bw1/$time*8/1000000]" # Reset gia tri bytes_ cua sink $sink1 set bytes_ #Dinh thoi goi lai ham record sau chu ky $time $ns at [expr $now+$time] "record" } # -set prvseqnb -1 set seqerrnb # Thu tuc ghi lai so packet nhan duoc dung thu tu proc seq-record {size rate ftime} { global prvseqnb seqerrnb sink1 f2 set ns [Simulator instance] # Dat chu ky thoi gian chay lai thu tuc set tsize [parse-bw $size] set trate [parse-bw $rate] set time [expr double($tsize)/double($trate)/8.0] set now [$ns now] # Tim so thu tu cua packet set revseqnb [$sink1 set expected_] if {$prvseqnb > $revseqnb} { incr seqerrnb } # Ghi so thu tu cua packet vao file if {$prvseqnb != $revseqnb} { puts $f2 "$now [$sink1 set expected_]" set prvseqnb $revseqnb } # Dinh thoi goi lai ham seq-record if { [expr $now+$time] < $ftime } { $ns at [expr $now+$time] "seq-record $size $rate $ftime" } } # -# Ham tao mot nguon luu luong gan vao node voi sink, size goi, # burst, idle time, rate va colour cua luu luong proc attach-expoo-traffic { node sink size burst idle rate } { set ns [Simulator instance] set source [new Agent/CBR/UDP] $ns attach-agent $node $source set traffic [new Traffic/Expoo] $traffic set packet-size $size $traffic set burst-time $burst $traffic set idle-time $idle $traffic set rate $rate $source attach-traffic $traffic $ns connect $source $sink return $source } # -# Thu tuc sau thong bao ER/CR-LSP da thiet lap de thuc hien tac vu khac proc notify-erlsp-setup {node lspid} { global src1 src2 LSR3 LSR5 LSR7 set ns [Simulator instance] set msg " [string range [$ns now] 3]s: Tunnel LSP_$lspid (Ingress=LSR[$node id]) da duoc thiet lap xong !" puts $msg $ns trace-annotate $msg set module [$node get-module "MPLS"] switch $lspid { 1100 { $module bind-flow-erlsp 10 100 $lspid 101 } 1101 { # LSP_1101 tu dong chon duong ngan nhat vong qua loi $module secondary-lsp-binding 1100 $lspid } default { puts " Error!" exit } } } roc notify-erlsp-fail {node status lspid tr} { set ns [Simulator instance] set module [$node get-module "MPLS"] if { [$node id] == && $status=="BSNodeError" } { $module set-lib-error-for-lspid $lspid set msg " [string range [$ns now] 3]s: Phat hien loi tren duong lam viec LSP_$lspid Chuyen sang duong bao ve LSP_1200 !" } if { [$node id] == && $status=="NodeRepair" } { $module set-lib-error-for-lspid $lspid -1 set msg " [string range [$ns now] 3]s: Loi da duoc khoi phuc Chuyen luu luong tro lai duong lam viec LSP_$lspid !" } puts $msg $ns trace-annotate $msg } # -# Thu tuc xuat tong so packet nhan duoc o cac sink proc recv-pkts {} { global sink1 seqerrnb set ns [Simulator instance] set msg " Luong da truyen [$sink1 set expected_] goi, mat [$sink1 set nlost_] goi, ti le mat goi la [string range [expr [$sink1 set nlost_]*100.0/[$sink1 set expected_]] 3] */*" puts $msg $ns trace-annotate $msg set msg " Tong so packet bi sai thu tu : $seqerrnb goi" puts $msg $ns trace-annotate $msg } # -# Thu tuc dong file va the hien ket qua ket thuc mo phong proc finish {} { global ns nf f1 f2 $ns flush-trace close $nf close $f1 close $f2 exec xgraph luong_1.tr -M -nb -bg white -fg black -zg black \ -geometry 500x250 -y "BW (Mbps)" -x "Time (sec)" \ -t "Bai 6: Khoi phuc duong theo co che Shortest-Dynamic" -tf "helvetica-12" & exec xgraph luong_seq.tr -p -nl -nb -bg white -fg black -zg black \ -geometry 500x250 -y "Packet No." -x "Time (sec)" \ -t "Bai 6: Bieu so thu tu packet theo thoi gian" -tf "helvetica12" & exec nam -r 2ms bai6.nam & exit } # -# Tao sink1 gan voi nut R10 (day la noi thu nhan traffic) set sink1 [new Agent/LossMonitor] $ns attach-agent $R10 $sink1 # Tao nguon luu luong src1 gan voi nut R0 bang cach # goi ham attach-expoo-traffic Luong co packet_size=600, rate=0.8Mbps set src1 [attach-expoo-traffic $R0 $sink1 600B 0 0.8M ] 102 $src1 set fid_ 100 $ns color 100 red # Cai dat co che khoi phuc: SHORTEST-DYNAMIC $ns enable-reroute shortest-dynamic [$LSR5 get-module "MPLS"] set-protection-lsp 0.7 0.01 1100 [$LSR9 get-module "MPLS"] enable-reroute-egress-lsr # Bat dau mo phong exec clear >@ stdout puts "\n BAI 6: KHOI PHUC DUONG THEO CO CHE SHORTEST-DYNAMIC \n " $ns at 0.0 "record" $ns at 0.0 "seq-record 600 800k 5.5" # Thiet lap LSP lam viec $ns at 0.2 "$ns trace-annotate {Bao hieu thiet lap duong lam viec: LSP_1100, ER=1_3_5_7_9 }" $ns at 0.2 "[$LSR1 get-module "MPLS"] setup-erlsp 1_3_5_7_9 1100” $ns at 0.5 "$ns trace-annotate {Luong 1: BW=0.8M (start=0.5 stop=5.0) su dung LSP_1100, ER=1_3_5_7_9 }" $ns at 0.5 "$src1 start" # Link giua LSR5 va LSR7 bi dut tu 2.0s, den 3.5s thi khoi phuc lai $ns rtmodel-at 2.0 down $LSR5 $LSR7 $ns rtmodel-at 3.5 up $LSR5 $LSR7 $ns at 5.0 "$src1 stop" $ns at 5.5 "recv-pkts" $ns at 5.5 "finish" $ns run Bai7.tcl ####################################################################### # BAI 7: KHOI PHUC DUONG THEO CO CHE SIMPLE-DYNAMIC # ####################################################################### # Tao mot doi tuong mo phong set ns [new Simulator] $ns rtproto LS # Tao file de xuat ket qua cho NAM set nf [open bai7.nam w] $ns namtrace-all $nf # Tao cac file de luu du lieu cho xgraph set f1 [open luong_1.tr w] set f2 [open luong_seq.tr w] # So ket noi mang # 1M 2M 1M # LSR2 -LSR4 -LSR6 -LSR8 # / / / / \ # / / / / \ # 1M / 1M / 1M / 1M / \ 2M # / / / / \ # / / / / \ # R0 -LSR1 -LSR3 -LSR5 -LSR7 LSR9 R10 # 2M 1M 2M 1M # Khai bao nut IP (R0,R10) va nut MPLS (LSR1 > LSR9) set R0 [$ns node] foreach i "1 9" { set LSR$i [$ns mpls-node] set m LSR$i eval $$m color blue } set R10 [$ns node] # Khai bao link: odes bw delay queue $ns duplex-link $R0 $LSR1 3Mb 10ms DropTail $ns duplex-link $LSR1 $LSR3 2Mb 30ms DropTail $ns duplex-link $LSR3 $LSR5 1Mb 30ms DropTail $ns duplex-link $LSR5 $LSR7 2Mb 30ms DropTail $ns duplex-link $LSR7 $LSR9 1Mb 30ms DropTail $ns duplex-link $LSR9 $R10 3Mb 10ms DropTail $ns duplex-link $LSR1 $LSR2 1Mb 30ms DropTail $ns duplex-link $LSR2 $LSR4 1Mb 30ms DropTail 103 $ns duplex-link $LSR4 $LSR6 2Mb 30ms DropTail $ns duplex-link $LSR6 $LSR8 1Mb 30ms DropTail $ns duplex-link $LSR8 $LSR9 2Mb 30ms DropTail $ns duplex-link $LSR3 $LSR4 1Mb 30ms DropTail $ns duplex-link $LSR5 $LSR6 1Mb 30ms DropTail $ns duplex-link $LSR7 $LSR8 1Mb 30ms DropTail # Ve dang so mang $ns duplex-link-op $R0 $LSR1 orient right $ns duplex-link-op $LSR1 $LSR3 orient right $ns duplex-link-op $LSR3 $LSR5 orient right $ns duplex-link-op $LSR5 $LSR7 orient right $ns duplex-link-op $LSR7 $LSR9 orient right $ns duplex-link-op $LSR9 $R10 orient right $ns duplex-link-op $LSR1 $LSR2 orient 0.333 $ns duplex-link-op $LSR2 $LSR4 orient right $ns duplex-link-op $LSR4 $LSR6 orient right $ns duplex-link-op $LSR6 $LSR8 orient right $ns duplex-link-op $LSR8 $LSR9 orient 1.667 $ns duplex-link-op $LSR3 $LSR4 orient 0.333 $ns duplex-link-op $LSR5 $LSR6 orient 0.333 $ns duplex-link-op $LSR7 $LSR8 orient 0.333 # Ghi chu $ns duplex-link-op $LSR1 $LSR3 label " 2M " $ns duplex-link-op $LSR3 $LSR5 label " 1M " $ns duplex-link-op $LSR5 $LSR7 label " 2M " $ns duplex-link-op $LSR7 $LSR9 label " 1M " $ns duplex-link-op $LSR1 $LSR2 label " 1M " $ns duplex-link-op $LSR2 $LSR4 label " 1M " $ns duplex-link-op $LSR4 $LSR6 label " 2M " $ns duplex-link-op $LSR6 $LSR8 label " 1M " $ns duplex-link-op $LSR8 $LSR9 label " 2M" $ns duplex-link-op $LSR3 $LSR4 label " 1M " $ns duplex-link-op $LSR5 $LSR6 label " 1M " $ns duplex-link-op $LSR7 $LSR8 label " 1M " $R0 label "Nguon" $R10 label "Dich" $LSR1 label "Ingress " $LSR9 label " Egress" # Cau hinh LDP agent tren tat ca cac nut MPLS $ns configure-ldp-on-all-mpls-nodes # Dat color cho cac ban tin LDP $ns ldp-request-color blue $ns ldp-mapping-color red $ns ldp-withdraw-color magenta $ns ldp-release-color orange $ns ldp-notification-color green # -# Dinh nghia cac ham su dung chuong trinh chinh # -# Tao mot procedure ghi nhan bang thong theo mot chu ki $time proc record {} { global sink1 f1 set ns [Simulator instance] # Dinh chu ki ghi nhan bang thong set time 0.1 # Lay so luong packet nhan duoc chu ky o moi sink set bw1 [$sink1 set bytes_] set now [$ns now] puts $f1 "$now [expr $bw1/$time*8/1000000]" # Reset gia tri bytes_ cua sink $sink1 set bytes_ #Dinh thoi goi lai ham record sau chu ky $time $ns at [expr $now+$time] "record" } # -set prvseqnb -1 set seqerrnb # Thu tuc ghi lai so packet nhan duoc dung thu tu 104 proc seq-record {size rate ftime} { global prvseqnb seqerrnb sink1 f2 set ns [Simulator instance] # Dat chu ky thoi gian chay lai thu tuc set tsize [parse-bw $size] set trate [parse-bw $rate] set time [expr double($tsize)/double($trate)/8.0] set now [$ns now] # Tim so thu tu cua packet set revseqnb [$sink1 set expected_] if {$prvseqnb > $revseqnb} { incr seqerrnb } # Ghi so thu tu cua packet vao file if {$prvseqnb != $revseqnb} { puts $f2 "$now [$sink1 set expected_]" set prvseqnb $revseqnb } # Dinh thoi goi lai ham seq-record if { [expr $now+$time] < $ftime } { $ns at [expr $now+$time] "seq-record $size $rate $ftime" } } # -# Ham tao mot nguon luu luong gan vao node voi sink, size goi, # burst, idle time, rate va colour cua luu luong proc attach-expoo-traffic { node sink size burst idle rate } { set ns [Simulator instance] set source [new Agent/CBR/UDP] $ns attach-agent $node $source set traffic [new Traffic/Expoo] $traffic set packet-size $size $traffic set burst-time $burst $traffic set idle-time $idle $traffic set rate $rate $source attach-traffic $traffic $ns connect $source $sink return $source } # -# Thu tuc sau thong bao ER/CR-LSP da thiet lap de thuc hien tac vu khac proc notify-erlsp-setup {node lspid} { global src1 src2 LSR3 LSR5 LSR7 set ns [Simulator instance] set module [$node get-module "MPLS"] switch $lspid { 9999 { # LSP_9999 tu dong chon duong vong den egress set msg " [string range [$ns now] 3]s: Tunnel LSP_$lspid (Ingress=LSR[$node id]) tu dong chon duong ngan nhat den Egress !" puts $msg $ns trace-annotate $msg } default { puts " Error!" exit } } } # -# Thu tuc xuat tong so packet nhan duoc o cac sink proc recv-pkts {} { global sink1 seqerrnb set ns [Simulator instance] set msg " Luong da truyen [$sink1 set expected_] goi, mat [$sink1 set nlost_] goi, ti le mat goi la [string range [expr [$sink1 set nlost_]*100.0/[$sink1 set expected_]] 3] */*" puts $msg $ns trace-annotate $msg 105 set msg " Tong so packet bi sai thu tu : $seqerrnb goi" puts $msg $ns trace-annotate $msg } # -# Thu tuc dong file va the hien ket qua ket thuc mo phong proc finish {} { global ns nf f1 f2 $ns flush-trace close $nf close $f1 close $f2 exec xgraph luong_1.tr -M -nb -bg white -fg black -zg black \ -geometry 500x250 -y "BW (Mbps)" -x "Time (sec)" \ -t "Bai 7: Khoi phuc duong theo co che Simple-Dynamic" -tf "helvetica-12" & exec xgraph luong_seq.tr -p -nl -nb -bg white -fg black -zg black \ -geometry 500x250 -y "Packet No." -x "Time (sec)" \ -t "Bai 7: Bieu so thu tu packet theo thoi gian" -tf "helvetica-12" & exec nam -r 2ms bai7.nam & exit } # -# Tao sink1 gan voi nut R10 (day la noi thu nhan traffic) set sink1 [new Agent/LossMonitor] $ns attach-agent $R10 $sink1 # Tao nguon luu luong src1 gan voi nut R0 bang cach # goi ham attach-expoo-traffic Luong co packet_size=600, rate=0.8Mbps set src1 [attach-expoo-traffic $R0 $sink1 600B 0 0.8M ] $src1 set fid_ 100 $ns color 100 red # Cai dat co che khoi phuc: SIMPLE-DYNAMIC $ns enable-reroute simple-dynamic [$LSR5 get-module "MPLS"] set-protection-flow 0.1 0.01 10 -1 [$LSR1 get-module "MPLS"] enable-data-driven # Bat dau mo phong exec clear >@ stdout puts "\n BAI 7: KHOI PHUC DUONG THEO CO CHE SIMPLE-DYNAMIC \n " $ns at 0.0 "record" $ns at 0.0 "seq-record 600 800k 5.5" $ns at 0.5 "$ns trace-annotate {Luong 1: BW=0.8M (start=0.5 stop=5.0) su dung LSP_1100, ER=1_3_5_7_9 }" $ns at 0.5 "$src1 start" # Link giua LSR5 va LSR7 bi dut tu 2.0s, den 3.5s thi khoi phuc lai $ns rtmodel-at 2.0 down $LSR5 $LSR7 $ns rtmodel-at 3.5 up $LSR5 $LSR7 $ns at 5.0 "$src1 stop" $ns at 5.5 "recv-pkts" $ns at 5.5 "finish" $ns run 106 ... mạch nhãn biên Máy chủ mạng L2TP Đường chuyển mạch nhãn Bộ định tuyến chuyển mạch nhãn Đa điểm tới đa điểm Miền đa điểm Chuyển mạch nhãn đa giao thức Kỹ thuật lưu lượng Đường hầm đa điểm Giao. .. tối đa số lượng nhãn phân bổ miền ATM-LSR 41 CHƯƠNG KỸ THUẬT LƯU LƯỢNG TRONG MPLS 1.5 Kỹ thuật lưu lượng ( Traffic Engineering ) Kỹ thuật lưu lượng (TE) trình điều khiển cách thức luồng lưu lượng. .. cạnh chuyển mạch kênh, chuyển mạch gói đời vào thập kỷ 70 Ngày nay, sử dụng nhiều kỹ thuật chuyển mạch khác nhau, bản, kỹ thuật chuyển mạch dựa sở hai phương pháp chuyển mạch kênh chuyển mạch

Ngày đăng: 03/10/2021, 12:43

Hình ảnh liên quan

1.1.1.4 Bảng chuyển tiờ́p chuyển mạch nhón (LSFT) - Kỹ thuật lưu lượng trong chuyển mạch nhãn đa giao thức (mpls   te)

1.1.1.4.

Bảng chuyển tiờ́p chuyển mạch nhón (LSFT) Xem tại trang 21 của tài liệu.
Bảng 3.1: Cỏc lớp dịch vụ lưu lượng - Kỹ thuật lưu lượng trong chuyển mạch nhãn đa giao thức (mpls   te)

Bảng 3.1.

Cỏc lớp dịch vụ lưu lượng Xem tại trang 46 của tài liệu.
Hỡnh 4.7: Xuất nội dung bảng LI Bở cỏc LSR ra màn hỡnh console - Kỹ thuật lưu lượng trong chuyển mạch nhãn đa giao thức (mpls   te)

nh.

4.7: Xuất nội dung bảng LI Bở cỏc LSR ra màn hỡnh console Xem tại trang 72 của tài liệu.

Tài liệu cùng người dùng

Tài liệu liên quan