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

Traffic shaping

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

  • Traffic shaping

    TRAFFIC SHAPING



    Mô tả:
    Traffic Shaping giải quyết những vấn đề quan trọng liên quan đến Qos. Việc đảm bảo tốc độ được cam kết, hay điều tiết tốc độ traffic ở mức cho phép mà không vượt qua tốc độ được thuê. Kỷ thuật này sử dụng phổ biến trong trường hợp khi tốc độ thực của cổng ra lớn hơn tốc độ được thuê ở ISP. Tuy nhiên không như Policing, ở đây traffic vược mức sẽ được giữ lại trong một hàng đợi đặc biệt hay còn gọi là hàng đợi Shaping, lợi điểm của kỷ thuật này là do không lập tức loại bỏ gói mà lưu lại vào hàng đợi Shaping do đó đối với những phiên TCP sẽ không bị ngắt và thiết lập lại dẫn đến vấn đề đồng bộ tuy nhiên nhược điểm là sẽ tạo ra trể cao không phù hợp cho những loại traffic đòi hỏi tính thời gian thực như VoIP.
    Bằng cách dùng các khái niệm như Bucket và Token, Shaping sẽ quyết định việc traffic có vượt tốc độ cho phép hay không.

    Yêu cầu:
    Trong bài thực hành này chúng ta sẽ thực hiện Shaping trên R2, cho các loại traffic, mặc dù có nhiều công cụ để thực hiện Shaping nhưng trong bài thực hành này sẽ dùng Class-Based Shaping.

    Thực hiện
    Cấu hình ban đầu của hệ thống:

    Cấu hình trên R1:
    R1#show run
    Building configuration...

    Current configuration : 1311 bytes
    !
    version 12.2
    service timestamps debug datetime msec
    service timestamps log datetime msec
    no service password-encryption
    !
    hostname R1
    !
    logging queue-limit 100
    !
    memory-size iomem 10
    ip subnet-zero
    !
    !
    !
    ip cef
    mpls ldp logging neighbor-changes
    !
    !
    no voice hpi capture buffer
    no voice hpi capture destination
    !
    !
    mta receive maximum-recipients 0
    !
    !
    !
    interface Ethernet0/0
    ip address 192.168.0.1 255.255.255.0
    half-duplex
    !
    interface Serial0/0
    ip address 192.168.1.1 255.255.255.0
    !
    no ip http server
    ip classless
    ip route 0.0.0.0 0.0.0.0 192.168.1.2
    !
    !
    !
    call rsvp-sync
    !
    voice-port 1/1/0
    !
    voice-port 1/1/1
    !
    !
    mgcp profile default
    !
    dial-peer cor custom
    !
    !
    !
    dial-peer voice 1 pots
    destination-pattern 101
    port 1/1/0
    !
    dial-peer voice 2 voip
    destination-pattern 201
    session target ipv4:192.168.2.2
    !
    !
    line con 0
    line aux 0
    line vty 0 4
    privilege level 15
    no login
    !
    !
    end

    R1#

    Cấu hình ban đầu trên R2:
    R2#sh run
    Building configuration...

    Current configuration : 1453 bytes
    !
    version 12.2
    service timestamps debug datetime msec
    service timestamps log datetime msec
    no service password-encryption
    !
    hostname R2
    !
    logging queue-limit 100
    !
    ip subnet-zero
    !
    !
    no ip domain lookup
    ip host R3 192.168.2.2
    ip host R1 192.168.1.1
    !
    ip cef
    mpls ldp logging neighbor-changes
    !
    !
    !
    !
    no voice hpi capture buffer
    no voice hpi capture destination
    !
    !
    mta receive maximum-recipients 0
    !
    !
    interface Ethernet0/0
    ip address 172.16.1.1 255.255.255.0
    half-duplex
    no cdp enable
    !
    interface Serial0/0
    ip address 192.168.1.2 255.255.255.0
    no ip route-cache cef
    no ip mroute-cache
    clockrate 2000000
    no cdp enable
    !
    interface Serial0/1
    bandwidth 128
    ip address 192.168.2.1 255.255.255.0
    load-interval 30
    no cdp enable
    !
    ip http server
    ip classless
    ip route 100.1.1.0 255.255.255.0 192.168.2.2
    ip route 101.1.1.0 255.255.255.0 192.168.2.2
    ip route 192.168.0.0 255.255.255.0 192.168.1.1
    !
    !
    !
    no cdp run
    !
    !
    tftp-server flash:
    call rsvp-sync
    !
    !
    mgcp profile default
    !
    dial-peer cor custom
    !
    !
    !
    !
    line con 0
    line aux 0
    line vty 0 4
    privilege level 15
    no login
    !
    !
    end

    R2#

    Cấu hình ban đầu trên R3:
    R3#sh run
    Building configuration...

    Current configuration : 1060 bytes
    !
    version 12.2
    service timestamps debug datetime msec
    service timestamps log datetime msec
    no service password-encryption
    !
    hostname R3
    !
    !
    ip subnet-zero
    !
    !
    voice call carrier capacity active
    !
    !
    mta receive maximum-recipients 0
    !
    !
    interface Loopback0
    ip address 100.1.1.1 255.255.255.0
    !
    interface Loopback1
    ip address 101.1.1.1 255.255.255.0
    !
    !
    interface Ethernet0/0
    no ip address
    half-duplex
    !
    interface Serial0/0
    ip address 192.168.2.2 255.255.255.0

    !
    ip classless
    ip route 0.0.0.0 0.0.0.0 192.168.2.1
    ip http server

    !
    call rsvp-sync
    !
    voice-port 1/0/0
    !
    voice-port 1/0/1
    !
    !
    mgcp profile default
    !
    dial-peer cor custom
    !
    dial-peer voice 1 pots
    destination-pattern 201
    port 1/0/0
    !
    dial-peer voice 2 voip
    destination-pattern 101
    session target ipv4:192.168.1.1
    !
    !
    !
    line con 0
    line aux 0
    line vty 0 4
    privilege level 15
    no login
    !
    !
    end

    R3#

    Bước 1: cấu hình đánh dấu lưu lượng trên R1

    Cấu hình ACL chọn các lưu lượng đến 2 đích đến 100.1.1.1 và 101.1.1.1

    access-list 100 permit ip any host 100.1.1.1
    access-list 101 permit ip any host 101.1.1.1

    Cấu hình class-map chọn lưu lượng voip, lưu lượng thỏa ACL 100 và 101

    class-map match-all VoIP
    match ip rtp 16384 16383
    class-map match-all D-100
    match access-group 100
    class-map match-all D-101
    match access-group 101

    Cấu hình policy-map dùng để đánh dấu lưu lượng voip

    policy-map CLASSIFY
    class VoIP
    set dscp ef << đánh dấu lưu lượng voip thành ef
    class D-100
    set dscp af21 << đánh dấu lưu lượng thỏa ACL 100 thành af21
    class D-101
    set dscp af23 << đánh dấu lưu lượng thỏa ACL 101 thành af23

    Bước 2: Cấu hình R2 phân loại lưu lượng dựa trên giá trị đã đánh dấu và tiến hành shape.

    Cấu hình phân loại lưu lượng dựa trên giá trị đánh dấu:

    class-map match-all VoIP
    match dscp ef
    class-map match-all D-100
    match dscp af21
    class-map match-all D-101
    match dscp af23
    !
    Cấu hình policy-map TRAFFIC dùng để định hình (shaping tốc độ gửi) với yêu cầu voip được shape xuống 32 kbps, đích đến 100.1.1.1 được shape 20 kbps, đích đến 101.1.1.1 được shape xuống 20 kbps, lớp mặc định được shape xuống 20 kbps.

    policy-map TRAFFIC
    class VoIP
    shape average 32000
    class D-100
    shape average 20000
    class D-101
    shape average 20000
    class class-default
    shape average 20000
    !
    Áp dụng lên cổng s0/1 của R2

    R2(config)#int s0/1
    R2(config-if)# service-policy output TRAFFIC

    Kiểm tra

    Dùng câu lệnh show policy-map interface trên R2 để tra kết quả

    R2#sh policy-map interface
    Serial0/1

    Service-policy output: TRAFFIC

    Class-map: VoIP (match-all)
    45961 packets, 2941427 bytes
    30 second offered rate 0 bps, drop rate 0 bps
    Match: dscp ef
    Traffic Shaping
    Target/Average Byte Sustain Excess Interval Increment
    Rate Limit bits/int bits/int (ms) (bytes)
    32000/32000 2000 8000 8000 250 1000

    Adapt Queue Packets Bytes Packets Bytes Shaping
    Active Depth Delayed Delayed Active
    - 0 12813 819974 0 0 no

    Class-map: D-100 (match-all)
    3941 packets, 3065372 bytes
    30 second offered rate 20000 bps, drop rate 0 bps
    Match: dscp af21
    Traffic Shaping
    Target/Average Byte Sustain Excess Interval Increment
    Rate Limit bits/int bits/int (ms) (bytes)
    20000/20000 2000 8000 8000 400 1000

    Adapt Queue Packets Bytes Packets Bytes Shaping
    Active Depth Delayed Delayed Active
    - 11 3928 3057436 3114 2181660 yes

    Class-map: D-101 (match-all)
    3912 packets, 3042084 bytes
    30 second offered rate 19000 bps, drop rate 0 bps
    Match: dscp af23
    Traffic Shaping
    Target/Average Byte Sustain Excess Interval Increment
    Rate Limit bits/int bits/int (ms) (bytes)
    20000/20000 2000 8000 8000 400 1000



    Adapt Queue Packets Bytes Packets Bytes Shaping
    Active Depth Delayed Delayed Active
    - 7 3904 3037312 2160 1394436 yes

    Class-map: class-default (match-any)
    787 packets, 258863 bytes
    30 second offered rate 0 bps, drop rate 205529000 bps
    Match: any
    Traffic Shaping
    Target/Average Byte Sustain Excess Interval Increment
    Rate Limit bits/int bits/int (ms) (bytes)
    20000/20000 2000 8000 8000 400 1000

    Adapt Queue Packets Bytes Packets Bytes Shaping
    Active Depth Delayed Delayed Active
    - 0 653 255771 273 211668 no

    Lưu ý giá trị Queue Depth có giá trị khác 0 thì cột Shaping Active thay đổi sang trạng thái Yes, lý do của việc hàng đợi shaping được kích hoạt. Vào thời điểm này traffic thuộc lớp D-100 và lớp D-101 sẽ bị Shaping nhưng traffic của lớp VoIP và lớp class-default không bị shaping, nghĩa là traffic của hai lớp này vẫn còn ở tốc độ cho phép.

    Cấu hình cuối cùng trên R1 và R2:

    Cấu hình trên R1:
    R1#show run
    Building configuration...

    Current configuration : 1311 bytes
    !
    version 12.2
    service timestamps debug datetime msec
    service timestamps log datetime msec
    no service password-encryption
    !
    hostname R1
    !
    logging queue-limit 100
    !
    memory-size iomem 10
    ip subnet-zero
    !
    !
    !
    ip cef
    mpls ldp logging neighbor-changes
    !
    !
    no voice hpi capture buffer
    no voice hpi capture destination
    !
    !
    mta receive maximum-recipients 0
    !
    !
    class-map match-all VoIP
    match ip rtp 16384 16383
    class-map match-all D-100
    match access-group 100
    class-map match-all D-101
    match access-group 101
    !
    !
    policy-map CLASSIFY
    class VoIP
    set dscp ef
    class D-100
    set dscp af21
    class D-101
    set dscp af23
    !
    !
    interface Ethernet0/0
    ip address 192.168.0.1 255.255.255.0
    half-duplex
    !
    interface Serial0/0
    ip address 192.168.1.1 255.255.255.0
    service-policy output CLASSIFY
    !
    no ip http server
    ip classless
    ip route 0.0.0.0 0.0.0.0 192.168.1.2
    !
    !
    !
    access-list 100 permit ip any host 100.1.1.1
    access-list 101 permit ip any host 101.1.1.1
    !
    !
    call rsvp-sync
    !
    voice-port 1/1/0
    !
    voice-port 1/1/1
    !
    !
    mgcp profile default
    !
    dial-peer cor custom
    !
    !
    !
    dial-peer voice 1 pots
    destination-pattern 101
    port 1/1/0
    !
    dial-peer voice 2 voip
    destination-pattern 201
    session target ipv4:192.168.2.2
    !
    !
    line con 0
    line aux 0
    line vty 0 4
    privilege level 15
    no login
    !
    !
    end

    R1#

    Cấu hình trên R2:
    R2#sh run
    Building configuration...

    Current configuration : 1453 bytes
    !
    version 12.2
    service timestamps debug datetime msec
    service timestamps log datetime msec
    no service password-encryption
    !
    hostname R2
    !
    logging queue-limit 100
    !
    ip subnet-zero
    !
    !
    no ip domain lookup
    ip host R3 192.168.2.2
    ip host R1 192.168.1.1
    !
    ip cef
    mpls ldp logging neighbor-changes
    !
    !
    !
    !
    no voice hpi capture buffer
    no voice hpi capture destination
    !
    !
    mta receive maximum-recipients 0
    !
    !
    class-map match-all VoIP
    match dscp ef
    class-map match-all D-100
    match dscp af21
    class-map match-all D-101
    match dscp af23
    !
    !
    policy-map TRAFFIC
    class VoIP
    shape average 32000
    class D-100
    shape average 20000
    class D-101
    shape average 20000
    class class-default
    shape average 20000
    !
    !
    !
    !
    interface Ethernet0/0
    ip address 172.16.1.1 255.255.255.0
    half-duplex
    no cdp enable
    !
    interface Serial0/0
    ip address 192.168.1.2 255.255.255.0
    no ip route-cache cef
    no ip mroute-cache
    clockrate 2000000
    no cdp enable
    !
    interface Serial0/1
    bandwidth 128
    ip address 192.168.2.1 255.255.255.0
    service-policy output TRAFFIC
    load-interval 30
    no cdp enable
    !
    ip http server
    ip classless
    ip route 100.1.1.0 255.255.255.0 192.168.2.2
    ip route 101.1.1.0 255.255.255.0 192.168.2.2
    ip route 192.168.0.0 255.255.255.0 192.168.1.1
    !
    !
    !
    no cdp run
    !
    !
    tftp-server flash:
    call rsvp-sync
    !
    !
    mgcp profile default
    !
    dial-peer cor custom
    !
    !
    !
    !
    line con 0
    line aux 0
    line vty 0 4
    privilege level 15
    no login
    !
    !
    end
    Last edited by phamminhtuan; 05-05-2011, 01:31 AM.
    Phạm Minh Tuấn

    Email : phamminhtuan@vnpro.org
    Yahoo : phamminhtuan_vnpro
    -----------------------------------------------------------------------------------------------
Trung Tâm Tin Học VnPro
149/1D Ung Văn Khiêm P25 Q.Bình thạnh TPHCM
Tel : (08) 35124257 (5 lines)
Fax: (08) 35124314

Home page: http://www.vnpro.vn
Support Forum: http://www.vnpro.org
- 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

Network channel: http://www.dancisco.com
Blog: http://www.vnpro.org/blog

  • #2
    anh ơi ko có hình lab ạ :-s....

    Comment


    • #3
      Chào bạn,

      Hình đã được add lại.
      Phạm Minh Tuấn

      Email : phamminhtuan@vnpro.org
      Yahoo : phamminhtuan_vnpro
      -----------------------------------------------------------------------------------------------
      Trung Tâm Tin Học VnPro
      149/1D Ung Văn Khiêm P25 Q.Bình thạnh TPHCM
      Tel : (08) 35124257 (5 lines)
      Fax: (08) 35124314

      Home page: http://www.vnpro.vn
      Support Forum: http://www.vnpro.org
      - 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

      Network channel: http://www.dancisco.com
      Blog: http://www.vnpro.org/blog

      Comment

      • Working...
        X