• 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.

    hostname R1

    interface f0/0

    ip address 172.16.1.1 255.255.255.0

    no shutdown

    exit

    interface f0/1

    ip address 172.16.2.1 255.255.255.0

    no shutdown

    exit

    line console 0

    logging synchronous

    exec-timeout 0 0

    exit

    no ip domain-lookup



    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.

    C:\iperf> iperf -c 172.16.2.2 -t 10 -i 1

    ————————————————————

    Client connecting to 172.16.2.2, TCP port 5001

    TCP window size: 63.0 KByte (default)

    ————————————————————

    [ 3] local 172.16.1.2 port 2500 connected with 172.16.2.2 port 5001

    [ ID] Interval Transfer Bandwidth

    [ 3] 0.0- 1.0 sec 10.4 MBytes 87.0 Mbits/sec

    [ 3] 1.0- 2.0 sec 10.1 MBytes 84.9 Mbits/sec

    [ 3] 2.0- 3.0 sec 10.2 MBytes 86.0 Mbits/sec

    [ 3] 3.0- 4.0 sec 10.2 MBytes 86.0 Mbits/sec

    [ 3] 4.0- 5.0 sec 10.2 MBytes 86.0 Mbits/sec

    [ 3] 5.0- 6.0 sec 10.2 MBytes 86.0 Mbits/sec

    [ 3] 6.0- 7.0 sec 10.2 MBytes 86.0 Mbits/sec

    [ 3] 7.0- 8.0 sec 10.1 MBytes 84.9 Mbits/sec

    [ 3] 8.0- 9.0 sec 10.2 MBytes 86.0 Mbits/sec

    [ 3] 9.0-10.0 sec 10.5 MBytes 88.1 Mbits/sec

    [ 3] 0.0-10.0 sec 103 MBytes 85.9 Mbits/sec



    C:\iperf>



    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.


    access-list 100 permit ip 172.16.1.2 0.0.0.0 172.16.2.2 0.0.0.0

    class-map 1M

    match access-group 100

    exit

    policy-map shape.1M

    class 1M

    shape average 1000000

    exit

    interface f0/1

    service-policy output shape.1M

    exit



    Để 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.

    C:\iperf> iperf -c 172.16.2.2 -t 10 -i 1

    ————————————————————

    Client connecting to 172.16.2.2, TCP port 5001

    TCP window size: 63.0 KByte (default)

    ————————————————————

    [ 3] local 172.16.1.2 port 2631 connected with 172.16.2.2 port 5001

    [ ID] Interval Transfer Bandwidth

    [ 3] 0.0- 1.0 sec 256 KBytes 2.10 Mbits/sec

    [ 3] 1.0- 2.0 sec 128 KBytes 1.05 Mbits/sec

    [ 3] 2.0- 3.0 sec 128 KBytes 1.05 Mbits/sec

    [ 3] 3.0- 4.0 sec 128 KBytes 1.05 Mbits/sec

    [ 3] 4.0- 5.0 sec 128 KBytes 1.05 Mbits/sec

    [ 3] 5.0- 6.0 sec 128 KBytes 1.05 Mbits/sec

    [ 3] 6.0- 7.0 sec 0.00 Bytes 0.00 bits/sec

    [ 3] 7.0- 8.0 sec 128 KBytes 1.05 Mbits/sec

    [ 3] 8.0- 9.0 sec 128 KBytes 1.05 Mbits/sec

    [ 3] 9.0-10.0 sec 128 KBytes 1.05 Mbits/sec

    [ 3] 0.0-11.5 sec 1.38 MBytes 1.01 Mbits/sec



    C:\iperf>



    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.



    R1# show int f0/1

    FastEthernet0/1 is up, line protocol is up

    Hardware is MV96340 Ethernet, address is 0024.c412.04a9 (bia 0024.c412.04a9)

    Internet address is 172.16.2.1/24

    MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec,

    reliability 255/255, txload 1/255, rxload 1/255

    Encapsulation ARPA, loopback not set

    Keepalive set (10 sec)

    Full-duplex, 100Mb/s, 100BaseTX/FX

    ARP type: ARPA, ARP Timeout 04:00:00

    Last input 00:00:11, output 00:00:02, output hang never

    Last clearing of “show interface” counters 00:01:12

    Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0

    Queueing strategy: fifo

    Output queue: 0/40 (size/max)

    5 minute input rate 3000 bits/sec, 4 packets/sec

    5 minute output rate 72000 bits/sec, 9 packets/sec

    762 packets input, 45732 bytes

    Received 1 broadcasts, 0 runts, 0 giants, 0 throttles

    0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored

    0 watchdog

    0 input packets with dribble condition detected

    2137 packets output, 2737284 bytes, 0 underruns

    0 output errors, 0 collisions, 0 interface resets

    –More–



    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 tòan các lưu lượng vượt ngưỡng băng thông cho phép.



    policy-map shape.1M

    class 1M

    shape average 1000000

    exit

    interface f0/1

    service-policy output shape.1M

    exit



    interface f0/1

    no service-policy output shape.1M

    exit



    policy-map shape.1M

    class 1M

    no shape average 1000000

    police cir 1000000

    exit

    interface f0/1

    service-policy output shape.1M

    exit



    Để 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.

    C:\iperf> iperf -c 172.16.2.2 -t 10 -i 1

    ————————————————————

    Client connecting to 172.16.2.2, TCP port 5001

    TCP window size: 63.0 KByte (default)

    ————————————————————

    [ 3] local 172.16.1.2 port 2767 connected with 172.16.2.2 port 5001

    [ ID] Interval Transfer Bandwidth

    [ 3] 0.0- 1.0 sec 256 KBytes 2.10 Mbits/sec

    [ 3] 1.0- 2.0 sec 0.00 Bytes 0.00 bits/sec

    [ 3] 2.0- 3.0 sec 128 KBytes 1.05 Mbits/sec

    [ 3] 3.0- 4.0 sec 128 KBytes 1.05 Mbits/sec

    [ 3] 4.0- 5.0 sec 0.00 Bytes 0.00 bits/sec

    [ 3] 5.0- 6.0 sec 128 KBytes 1.05 Mbits/sec

    [ 3] 6.0- 7.0 sec 128 KBytes 1.05 Mbits/sec

    [ 3] 7.0- 8.0 sec 0.00 Bytes 0.00 bits/sec

    [ 3] 8.0- 9.0 sec 128 KBytes 1.05 Mbits/sec

    [ 3] 9.0-10.0 sec 0.00 Bytes 0.00 bits/sec

    [ 3] 0.0-11.7 sec 1.00 MBytes 717 Kbits/sec



    C:\iperf>



    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.



    R1# show interfaces f0/1

    FastEthernet0/1 is up, line protocol is up

    Hardware is MV96340 Ethernet, address is 0024.c412.04a9 (bia 0024.c412.04a9)

    Internet address is 172.16.2.1/24

    MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec,

    reliability 255/255, txload 1/255, rxload 1/255

    Encapsulation ARPA, loopback not set

    Keepalive set (10 sec)

    Full-duplex, 100Mb/s, 100BaseTX/FX

    ARP type: ARPA, ARP Timeout 04:00:00

    Last input 00:00:41, output 00:00:08, output hang never

    Last clearing of “show interface” counters never

    Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 262

    Queueing strategy: fifo

    Output queue: 0/40 (size/max)

    5 minute input rate 0 bits/sec, 0 packets/sec

    5 minute output rate 0 bits/sec, 0 packets/sec

    39279 packets input, 4159794 bytes

    Received 134 broadcasts, 0 runts, 0 giants, 0 throttles

    0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored

    0 watchdog

    0 input packets with dribble condition detected

    110808 packets output, 127564205 bytes, 0 underruns

    0 output errors, 0 collisions, 1 interface resets

    –More–



    R1# clear counters f0/1

    Clear “show interface” counters on this interface [confirm] <enter>

    R1# show int f0/1

    FastEthernet0/1 is up, line protocol is up

    Hardware is MV96340 Ethernet, address is 0024.c412.04a9 (bia 0024.c412.04a9)

    Internet address is 172.16.2.1/24

    MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec,

    reliability 255/255, txload 1/255, rxload 1/255

    Encapsulation ARPA, loopback not set

    Keepalive set (10 sec)

    Full-duplex, 100Mb/s, 100BaseTX/FX

    ARP type: ARPA, ARP Timeout 04:00:00

    Last input 00:00:29, output 00:00:02, output hang never

    Last clearing of “show interface” counters 00:00:02

    Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0

    Queueing strategy: fifo

    Output queue: 0/40 (size/max)

    5 minute input rate 0 bits/sec, 0 packets/sec

    5 minute output rate 0 bits/sec, 0 packets/sec

    0 packets input, 0 bytes

    Received 0 broadcasts, 0 runts, 0 giants, 0 throttles

    0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored

    0 watchdog

    0 input packets with dribble condition detected

    1 packets output, 60 bytes, 0 underruns

    0 output errors, 0 collisions, 0 interface resets

    –More–



    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.



    access-list 100 permit ip 172.16.1.2 0.0.0.0 172.16.2.2 0.0.0.0

    access-list 101 permit ip 172.16.1.3 0.0.0.0 172.16.2.2 0.0.0.0

    class-map 1M

    match access-group 100

    exit

    class-map 2M

    match access-group 101

    exit

    policy-map shape.1M

    class 1M

    police cir 1000000

    exit

    class 2M

    shape average 2000000

    exit

    interface f0/1

    service-policy output shape.1M

    exit



    Để 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.

    C:\iperf> iperf -c 172.16.2.2 -t 10 -i 1

    ————————————————————

    Client connecting to 172.16.2.2, TCP port 5001

    TCP window size: 63.0 KByte (default)

    ————————————————————

    [ 3] local 172.16.1.3 port 2961 connected with 172.16.2.2 port 5001

    [ ID] Interval Transfer Bandwidth

    [ 3] 0.0- 1.0 sec 384 KBytes 3.15 Mbits/sec

    [ 3] 1.0- 2.0 sec 256 KBytes 2.10 Mbits/sec

    [ 3] 2.0- 3.0 sec 128 KBytes 1.05 Mbits/sec

    [ 3] 3.0- 4.0 sec 256 KBytes 2.10 Mbits/sec

    [ 3] 4.0- 5.0 sec 256 KBytes 2.10 Mbits/sec

    [ 3] 5.0- 6.0 sec 256 KBytes 2.10 Mbits/sec

    [ 3] 6.0- 7.0 sec 256 KBytes 2.10 Mbits/sec

    [ 3] 7.0- 8.0 sec 128 KBytes 1.05 Mbits/sec

    [ 3] 8.0- 9.0 sec 256 KBytes 2.10 Mbits/sec

    [ 3] 9.0-10.0 sec 256 KBytes 2.10 Mbits/sec

    [ 3] 0.0-10.7 sec 2.50 MBytes 1.95 Mbits/sec



    C:\iperf>



    Kết quả hiển thị tại Iperf Server.

    Thầy Bùi Quốc Kỳ – VnPro
    Phạm Thanh Đông Khê
    Email: dongkhe@vnpro.org
    Hãy share hoặc like nếu thông tin hữu ích!
    ---------------------------------------------------------------------------------------------------------------------------------------------------
Trung Tâm Tin Học VnPro
149/1D Ung Văn Khiêm, P.25, Q.Bình Thạnh, Tp.HCM
Tel: (08) 35124257 (5 lines)
Fax: (08) 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
FB: http://facebook.com/VnPro
Working...
X