• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
Xin chào ! Nếu đây là lần đầu tiên bạn đến với diễn đàn, xin vui lòng danh ra một phút bấm vào đây để đăng kí và tham gia thảo luận cùng VnPro.

Announcement

Collapse
No announcement yet.

Giới hạn bandwidth bằng QoS trên Cisco Router

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Giới hạn bandwidth bằng QoS trên Cisco Router


    Yêu cầu:
    1. Cấu hình cơ bản trên các thiết bị.
    2. Sử dụng Iperf đo băng thông khả dụng giữa PC1 và PC2.
    3. Cấu hình QoS trên R1 giới hạn băng thông giữa PC1 và PC2 xuống còn 1M.

    Thực hiện:

    Yêu cầu 1. Cấu hình cơ bản trên các thiết bị.

    Cấu hình trên R1.
    Code:
    [B]hostname R1[/B]
    [B]interface f0/0[/B] [B] 
    ip address 172.16.1.1 255.255.255.0[/B] [B] 
    no shutdown[/B] [B] 
    exit[/B]
    [B]interface f0/1[/B] [B] 
    ip address 172.16.2.1 255.255.255.0[/B] [B] 
    no shutdown[/B] [B] 
    exit[/B]
    [B]line console 0[/B]
    [B]  logging synchronous[/B] [B] 
    exec-timeout 0 0[/B] [B] 
    exit[/B]
    [B]no ip domain-lookup[/B]
    Yêu cầu 2. Sử dụng Iperf đo băng thông khả dụng giữa PC1 và PC2.
    Bật chức năng Iperf Server trên PC2.



    Bật chức năng Iperf Client trên PC1.
    Code:
    [B]C:\iperf
    > iperf-c 172.16.2.2 -t 10 -i 1[/B]
    
    [B]------------------------------------------------------------[/B]
    
    [B]Client connecting to 172.16.2.2, TCP port 5001[/B] [B]TCP window size: 63.0 KByte (default)[/B]
    
    [B]------------------------------------------------------------[/B]
    
    [B][  3] local 172.16.1.2 port 2500 connected with 172.16.2.2 port 5001[/B]
    
    [B][ ID] Interval       Transfer     Bandwidth[/B]
    
    [B][  3]  0.0- 1.0 sec  10.4 MBytes  87.0 Mbits/sec[/B]
    
    [B][  3]  1.0- 2.0 sec  10.1 MBytes  84.9 Mbits/sec[/B]
    
    [B][  3]  2.0- 3.0 sec  10.2 MBytes  86.0 Mbits/sec[/B]
    
    [B][  3]  3.0- 4.0 sec  10.2 MBytes  86.0 Mbits/sec[/B]
    
    [B][  3]  4.0- 5.0 sec  10.2 MBytes  86.0 Mbits/sec[/B]
    
    [B][  3]  5.0- 6.0 sec  10.2 MBytes  86.0 Mbits/sec[/B]
    
    [B][  3]  6.0- 7.0 sec  10.2 MBytes  86.0 Mbits/sec[/B]
    
    [B][  3]  7.0- 8.0 sec  10.1 MBytes  84.9 Mbits/sec[/B]
    
    [B][  3]  8.0- 9.0 sec  10.2 MBytes  86.0 Mbits/sec[/B]
    
    [B][  3]  9.0-10.0 sec  10.5 MBytes  88.1 Mbits/sec[/B]
    
    [B][  3]  0.0-10.0 sec   103 MBytes  85.9 Mbits/sec[/B]
    
     [B]C:\iperf>[/B]
    Kết quả đo được trên Iperf Server với băng thông trung bình đo được là 85.9 Mbits/sec.





    Yêu cầu 3. Cấu hình QoS trên R1 giới hạn băng thông giữa PC1 và PC2 xuống còn 1M.
    • shape average 1000000: đảm bảo tốc độ không vượt quá 1M, các gói tin vượt ngưỡng 1M sẽ được lưu trữ tạm thời vào bộ lưu trữ cache trên Router.

    Code:
    [B]access-list 100 permit ip 172.16.1.2 0.0.0.0 172.16.2.2 0.0.0.0[/B] [B]class-map 1M[/B] 
    
    [B]match access-group 100[/B] 
    
    [B]exit[/B]
    
    [B]policy-map shape.1M[/B] 
    
    [B]class 1M[/B] 
    
    [B]shape average 1000000[/B] 
    
    [B]exit[/B]
    
    [B]interface f0/1[/B]
    
    [B]  service-policy output shape.1M[/B]
    
    [B]  exit[/B]
    Để kiểm tra, ta tiến hành bật chức năng Iperf Server trên PC2.



    Tiến hành bật chức năng Iperf Client trên PC1 trỏ về IP của Iperf Server.

    Code:
    [B]C:\iperf> iperf -c 172.16.2.2 -t 10 -i 1[/B]
    
    [B]------------------------------------------------------------[/B]
    
    [B]Client connecting to 172.16.2.2, TCP port 5001[/B] [B]TCP window size: 63.0 KByte (default)[/B]
    
    [B]------------------------------------------------------------[/B]
    
    [B][  3] local 172.16.1.2 port 2631 connected with 172.16.2.2 port 5001[/B]
    
    [B][ ID] Interval       Transfer     Bandwidth[/B]
    
    [B][  3]  0.0- 1.0 sec   256 KBytes  2.10 Mbits/sec[/B]
    
    [B][  3]  1.0- 2.0 sec   128 KBytes  1.05 Mbits/sec[/B]
    
    [B][  3]  2.0- 3.0 sec   128 KBytes  1.05 Mbits/sec[/B]
    
    [B][  3]  3.0- 4.0 sec   128 KBytes  1.05 Mbits/sec[/B]
    
    [B][  3]  4.0- 5.0 sec   128 KBytes  1.05 Mbits/sec[/B]
    
    [B][  3]  5.0- 6.0 sec   128 KBytes  1.05 Mbits/sec[/B]
    
    [B][  3]  6.0- 7.0 sec  0.00 Bytes  0.00 bits/sec[/B]
    
    [B][  3]  7.0- 8.0 sec   128 KBytes  1.05 Mbits/sec[/B]
    
    [B][  3]  8.0- 9.0 sec   128 KBytes  1.05 Mbits/sec[/B]
    
    [B][  3]  9.0-10.0 sec   128 KBytes  1.05 Mbits/sec[/B]
    
    [B][  3]  0.0-11.5 sec  1.38 MBytes  1.01 Mbits/sec[/B] 
    
    [B]C:\iperf>[/B]
    Kết quả hiển thị tại Iperf Server đo được với tốc độ là 961 Kbits/sec.



    Với tính năng shape average, các packet không hề bị drop bỏ mà sẽ được lưu trữ tạm tại bộ nhớ cache trên Router.

    Code:
    [B]R1# show int f0/1[/B]
    
    [B]FastEthernet0/1 is up, line protocol is up[/B]
    
    [B]  Hardware is MV96340 Ethernet, address is 0024.c412.04a9 (bia 0024.c412.04a9)[/B]
    
    [B]  Internet address is 172.16.2.1/24[/B] 
    
    [B]  MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec, [/B]
    
    [B]  reliability 255/255, txload 1/255, rxload 1/255[/B] 
    
    [B]  Encapsulation ARPA, loopback not set[/B] 
    
    [B]  Keepalive set (10 sec)[/B] 
    
    [B]  Full-duplex, 100Mb/s, 100BaseTX/FX[/B] 
    
    [B]  ARP type: ARPA, ARP Timeout 04:00:00[/B] 
    
    [B]  Last input 00:00:11, output 00:00:02, output hang never[/B]
    
    [B]  Last clearing of "show interface" counters 00:01:12[/B] 
    
    [B]  Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0[/B] 
    
    [B]  Queueing strategy: fifo[/B] 
    
    [B]  Output queue: 0/40 (size/max)[/B] 
    
    [B]  5 minute input rate 3000 bits/sec, 4 packets/sec[/B] 
    
    [B]  5 minute output rate 72000 bits/sec, 9 packets/sec[/B] 
    
    [B]  762 packets input, 45732 bytes[/B] 
    
    [B]  Received 1 broadcasts, 0 runts, 0 giants, 0 throttles[/B] 
    
    [B]  0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored[/B] 
    
    [B]  0 watchdog[/B] 
    
    [B]  0 input packets with dribble condition detected[/B] 
    
    [B]  2137 packets output, 2737284 bytes, 0 underruns[/B] 
    
    [B]  0 output errors, 0 collisions, 0 interface resets[/B] 
    
    [B]--More--[/B]
    Tính năng shape có thể làm tiêu tốn tài nguyên xử lý trên Router, vì thế ta có thể tận dụng tính năng CIR giúp drop bỏ hoàn toàn các lưu lượng vượt ngưỡng băng thông cho phép.

    Code:
    [B]policy-map shape.1M[/B] 
    
    [B]class 1M[/B]
    
    [B]  shape average 1000000[/B] 
    
    [B]exit[/B]
    
    [B]interface f0/1[/B]
    
    [B]  service-policy output shape.1M[/B]
    
    [B]  exit[/B]
    
      [B]interface f0/1[/B]
    
    [B]  no service-policy output shape.1M[/B]
    
    [B]  exit[/B]
    
     [B]policy-map shape.1M[/B]
    
    [B]  class 1M[/B]
    
    [B]  no shape average 1000000[/B]
    
    [B]  police cir 1000000[/B]
    
    [B]  exit[/B]
    
    [B]interface f0/1[/B]
    
    [B]  service-policy output shape.1M[/B]
    
    [B]  exit[/B]
    Để kiểm tra, bật chức năng Iperf Server trên PC2.





    Trên PC1, bật chức năng Iperf Client.

    Code:
    [B]C:\iperf> iperf -c 172.16.2.2 -t 10 -i 1[/B]
    
    [B]------------------------------------------------------------[/B]
    
    [B]Client connecting to 172.16.2.2, TCP port 5001[/B] [B]TCP window size: 63.0 KByte (default)[/B]
    
    [B]------------------------------------------------------------[/B]
    
    [B][  3] local 172.16.1.2 port 2767 connected with 172.16.2.2 port 5001[/B]
    
    [B][ ID] Interval       Transfer     Bandwidth[/B]
    
    [B][  3]  0.0- 1.0 sec   256 KBytes  2.10 Mbits/sec[/B]
    
    [B][  3]  1.0- 2.0 sec  0.00 Bytes  0.00 bits/sec[/B]
    
    [B][  3]  2.0- 3.0 sec   128 KBytes  1.05 Mbits/sec[/B] 
    
    [B][  3]  3.0- 4.0 sec   128 KBytes  1.05 Mbits/sec[/B]
    
    [B][  3]  4.0- 5.0 sec  0.00 Bytes  0.00 bits/sec[/B]
    
    [B][  3]  5.0- 6.0 sec   128 KBytes  1.05 Mbits/sec[/B]
    
    [B][  3]  6.0- 7.0 sec   128 KBytes  1.05 Mbits/sec[/B]
    
    [B][  3]  7.0- 8.0 sec  0.00 Bytes  0.00 bits/sec[/B]
    
    [B][  3]  8.0- 9.0 sec   128 KBytes  1.05 Mbits/sec[/B]
    
    [B][  3]  9.0-10.0 sec  0.00 Bytes  0.00 bits/sec[/B]
    
    [B][  3]  0.0-11.7 sec  1.00 MBytes   717 Kbits/sec[/B] 
    
    [B]C:\iperf>[/B]
    Kết quả hiển thị tại Iperf Server cho thấy bandwidth đo được là 645 Kbits/sec, tính năng police cir sẽ tiến hành drop bỏ các lưu lượng vượt ngưỡng 1M nên PC1 sẽ phải truyền lại các gói tin bị mất dẫn đến tốc độ sẽ giảm hơn hẳn so với tính năng shape average.



    Kiểm tra số lượng gói tin đã bị drop bỏ do tính năng police cir.

    Code:
      [B]R1# show interfaces f0/1[/B]
    
    [B]  FastEthernet0/1 is up, line protocol is up[/B]
    
    [B]  Hardware is MV96340 Ethernet, address is 0024.c412.04a9 (bia 0024.c412.04a9)[/B] 
    
    [B]  Internet address is 172.16.2.1/24[/B] 
    
    [B]  MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec, [/B]
    
    [B]  reliability 255/255, txload 1/255, rxload 1/255[/B] 
    
    [B]  Encapsulation ARPA, loopback not set[/B] 
    
    [B]  Keepalive set (10 sec)[/B] 
    
    [B]  Full-duplex, 100Mb/s, 100BaseTX/FX[/B] 
    
    [B]  ARP type: ARPA, ARP Timeout 04:00:00[/B] 
    
    [B]  Last input 00:00:41, output 00:00:08, output hang never[/B] 
    
    [B]  Last clearing of "show interface" counters never[/B] 
    
    [B]  Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 262[/B] 
    
    [B]  Queueing strategy: fifo[/B] 
    
    [B]  Output queue: 0/40 (size/max)[/B] 
    
    [B]  5 minute input rate 0 bits/sec, 0 packets/sec[/B] 
    
    [B]  5 minute output rate 0 bits/sec, 0 packets/sec[/B] 
    
    [B]  39279 packets input, 4159794 bytes[/B] 
    
    [B]  Received 134 broadcasts, 0 runts, 0 giants, 0 throttles[/B] 
    
    [B]  0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored[/B] 
    
    [B]  0 watchdog[/B] 
    
    [B]  0 input packets with dribble condition detected[/B] 
    
    [B]  110808 packets output, 127564205 bytes, 0 underruns[/B] 
    
    [B]  0 output errors, 0 collisions, 1 interface resets[/B] 
    
    [B]--More--[/B]
    
     
    
    [B]R1# clear counters f0/1[/B]
    
    [B]Clear "show interface" counters on this interface [confirm][/B]
    
    [B]R1# show int f0/1[/B]
    
    [B]FastEthernet0/1 is up, line protocol is up[/B]
    
    [B]  Hardware is MV96340 Ethernet, address is 0024.c412.04a9 (bia 0024.c412.04a9)[/B] 
    
    [B]  Internet address is 172.16.2.1/24[/B] 
    
    [B]  MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec, [/B]
    
    [B]  reliability 255/255, txload 1/255, rxload 1/255[/B] 
    
    [B]  Encapsulation ARPA, loopback not set[/B] 
    
    [B]  Keepalive set (10 sec)[/B] 
    
    [B]  Full-duplex, 100Mb/s, 100BaseTX/FX[/B] 
    
    [B]  ARP type: ARPA, ARP Timeout 04:00:00[/B] 
    
    [B]  Last input 00:00:29, output 00:00:02, output hang never[/B] 
    
    [B]Last clearing of "show interface" counters 00:00:02[/B] 
    
    [B]Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0[/B] 
    
    [B]Queueing strategy: fifo[/B] 
    
    [B]Output queue: 0/40 (size/max)[/B] 
    
    [B]5 minute input rate 0 bits/sec, 0 packets/sec[/B] 
    
    [B]5 minute output rate 0 bits/sec, 0 packets/sec[/B] 
    
    [B]0 packets input, 0 bytes[/B] 
    
    [B]Received 0 broadcasts, 0 runts, 0 giants, 0 throttles[/B] 
    
    [B]0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored[/B] 
    
    [B]0 watchdog[/B] 
    
    [B]0 input packets with dribble condition detected[/B] 
    
    [B]1 packets output, 60 bytes, 0 underruns[/B] 
    
    [B]0 output errors, 0 collisions, 0 interface resets[/B]
    
    [B] --More--[/B]
    Ta có thể filter nhiều loại lưu lượng rồi thực thi chính sách QoS bằng cách tạo ra nhiều định nghĩa class-map như sau.

    Code:
    [B]access-list 100 permit ip 172.16.1.2 0.0.0.0 172.16.2.2 0.0.0.0[/B]
    
    [B]access-list 101 permit ip 172.16.1.3 0.0.0.0 172.16.2.2 0.0.0.0[/B]
    
    [B]class-map 1M[/B]
    
    [B]  match access-group 100[/B]
    
    [B]  exit[/B]
    
    [B]class-map 2M[/B]
    
    [B]  match access-group 101[/B]
    
    [B]  exit[/B]
    
    [B]policy-map shape.1M[/B]
    
    [B]  class 1M[/B] 
    
    [B]  police cir 1000000[/B]
    
    [B]    exit[/B]
    
    [B]  class 2M[/B]
    
    [B]    shape average 2000000[/B]
    
    [B]    exit[/B]
    
    [B]interface f0/1[/B]
    
    [B]  service-policy output shape.1M[/B]
    
    [B]  exit[/B]
    Để kiểm tra, bật chức năng Iperf Server trên PC2.





    Trên PC1, bật chức năng Iperf Client.

    Code:
    [B]C:\iperf> iperf -c 172.16.2.2 -t 10 -i 1[/B]
    
    [B]------------------------------------------------------------[/B]
    
    [B]Client connecting to 172.16.2.2, TCP port 5001[/B] [B]TCP window size: 63.0 KByte (default)[/B]
    
    [B]------------------------------------------------------------[/B]
    
    [B][  3] local 172.16.1.3 port 2961 connected with 172.16.2.2 port 5001[/B]
    
    [B][ ID] Interval       Transfer     Bandwidth[/B]
    
    [B][  3]  0.0- 1.0 sec   384 KBytes  3.15 Mbits/sec[/B]
    
    [B][  3]  1.0- 2.0 sec   256 KBytes  2.10 Mbits/sec[/B]
    
    [B][  3]  2.0- 3.0 sec   128 KBytes  1.05 Mbits/sec[/B]
    
    [B][  3]  3.0- 4.0 sec   256 KBytes  2.10 Mbits/sec[/B]
    
    [B][  3]  4.0- 5.0 sec   256 KBytes  2.10 Mbits/sec[/B]
    
    [B][  3]  5.0- 6.0 sec   256 KBytes  2.10 Mbits/sec[/B]
    
    [B][  3]  6.0- 7.0 sec   256 KBytes  2.10 Mbits/sec[/B]
    
    [B][  3]  7.0- 8.0 sec   128 KBytes  1.05 Mbits/sec[/B]
    
    [B][  3]  8.0- 9.0 sec   256 KBytes  2.10 Mbits/sec[/B]
    
    [B][  3]  9.0-10.0 sec   256 KBytes  2.10 Mbits/sec[/B]
    
    [B][  3]  0.0-10.7 sec  2.50 MBytes  1.95 Mbits/sec[/B]
    
     [B]C:\iperf>[/B]
    Kết quả hiển thị tại Iperf Server.



    Thầy Bùi Quốc Kỳ - VnPro
    Phan Trung Tín
    Email: phantrungtin@vnpro.org
    .
Trung Tâm Tin Học VnPro
149/1D Ung Văn Khiêm, P.25, Q.Bình Thạnh, Tp.HCM
Tel: (028) 35124257 (028) 36222234
Fax: (028) 35124314

Home Page: http://www.vnpro.vn
Forum: http://www.vnpro.org
Twitter: https://twitter.com/VnVnpro
LinkedIn: https://www.linkedin.com/in/VnPro
- Chuyên đào tạo quản trị mạng và hạ tầng Internet
- Phát hành sách chuyên môn
- Tư vấn và tuyển dụng nhân sự IT
- Tư vấn thiết kế và hỗ trợ kỹ thuật hệ thống mạng

Videos: http://www.dancisco.com
Blog: http://www.vnpro.org/blog
Facebook: http://facebook.com/VnPro
Zalo: https://zalo.me/1005309060549762169
​​​​​​
Working...
X