################################################################################ # Version 1.0 $Revision: 1 $ # $Author: cnicutar $ # # Copyright © 1997 - 2009 by IXIA # All Rights Reserved. # # Revision Log: # # ################################################################################ ################################################################################ # # # LEGAL NOTICE: # # ============== # # The following code and documentation (hereinafter "the script") is an # # example script for demonstration purposes only. # # The script is not a standard commercial product offered by Ixia and have # # been developed and is being provided for use only as indicated herein. The # # script [and all modifications, enhancements and updates thereto (whether # # made by Ixia and/or by the user and/or by a third party)] shall at all times # # remain the property of Ixia. # # # # Ixia does not warrant (i) that the functions contained in the script will # # meet the user's requirements or (ii) that the script will be without # # omissions or error-free. # # THE SCRIPT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, AND IXIA # # DISCLAIMS ALL WARRANTIES, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, # # INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR # # A PARTICULAR PURPOSE OR OF NON-INFRINGEMENT. # # THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SCRIPT IS WITH THE # # USER. # # IN NO EVENT SHALL IXIA BE LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING # # OUT OF THE USE OF, OR THE INABILITY TO USE THE SCRIPT OR ANY PART THEREOF, # # INCLUDING BUT NOT LIMITED TO ANY LOST PROFITS, LOST BUSINESS, LOST OR # # DAMAGED DATA OR SOFTWARE OR ANY INDIRECT, INCIDENTAL, PUNITIVE OR # # CONSEQUENTIAL DAMAGES, EVEN IF IXIA HAS BEEN ADVISED OF THE POSSIBILITY OF # # SUCH DAMAGES IN ADVANCE. # # Ixia will not be required to provide any software maintenance or support # # services of any kind (e.g., any error corrections) in connection with the # # script or any part thereof. The user acknowledges that although Ixia may # # from time to time and in its sole discretion provide maintenance or support # # services for the script, any such services are subject to the warranty and # # damages limitations set forth herein and will not obligate Ixia to provide # # any additional maintenance or support services. # # # ################################################################################ ################################################################################ # # # Description: # # This sample creates BGP peers and routes, and sends traffic over it # # using ixnetwork_540 traffic_generator and tracking by qos. # # # # It uses two Ixia ports. BGP peers and routes are configured on both # # ports. Streams are generated using ixnetwork_540 traffic_generator # # Traffic statistics are collected for each flow. # # # ################################################################################ # This script runs back-to-back. proc increment_ipv4_address_script {ip_addr ip_addr_step} { set addr_words [split $ip_addr .] set step_words [split $ip_addr_step .] set index 3 set result [list] set carry 0 while {$index >= 0} { scan [lindex $addr_words $index] "%u" addr_word scan [lindex $step_words $index] "%u" step_word set value [expr $addr_word + $step_word + $carry] set carry [expr $value / 0xFF] set value [expr $value % 0xFF] lappend result $value incr index -1 } set new_addr [format "%u" [lindex $result 3]] for {set i 2} {$i >= 0} {incr i -1} { append new_addr ".[format "%u" [lindex $result $i]]" } return $new_addr } package require Ixia set test_name bgp_config set chassis_ip sylvester ### points to where ixNetwork Tcl Server is running set network_tcl_server_ip localhost ### points to where Ixia Tcl Server is running - only when using UNIX clients set tcl_server_ip localhost set port_list [list 3/3 3/4] set num_of_bgp_neighbors 10 set num_of_prefix 1 set prefix_ce1 55.0.0.1 set prefix_ce2 70.0.0.1 ################################################################################# # Connects to the IxNetwork Tcl Server, Tcl Server, and the chassis. # Takes ownership of the ports. # Notes: # IxNetwork Tcl Server must be running on a client PC; # Tcl Server must be running on a client PC; ################################################################################# # When using P2NO HLTSET, for loading the IxTclNetwork package please # provide –ixnetwork_tcl_server parameter to ::ixia::connect set connect_status [::ixia::connect \ -reset \ -device $chassis_ip \ -ixnetwork_tcl_server $network_tcl_server_ip \ -tcl_server $tcl_server_ip \ -port_list $port_list \ -break_locks 1 \ -username ixiaApiUser \ ] if {[keylget connect_status status] != $::SUCCESS} { return "FAIL - $test_name - [keylget connect_status log]" } set port_handle_list [::ixia::get_port_list_from_connect \ $connect_status $chassis_ip $port_list] set port_0 [lindex $port_handle_list 0] set port_1 [lindex $port_handle_list 1] ################################################################################ # Configure layer 1 port settings (speed) ################################################################################ set speed auto ;# CHOICES ether10 ether100 ether1000 auto DEFAULT ether100 (for 10/100/1000 Ethernet cards) set autonegotiation 1 ;# CHOICES 0 1 DEFAULT 1 set duplex auto ;# CHOICES half full auto DEFAULT full set phy_mode copper ;# CHOICES copper fiber DEFAULT copper set interface_status [::ixia::interface_config \ -port_handle $port_handle_list \ -autonegotiation $autonegotiation \ -speed $speed \ -duplex $duplex \ -phy_mode $phy_mode \ ] if {[keylget interface_status status] != $::SUCCESS} { return "FAIL - $test_name - [keylget interface_status log]" } ################################################################################ # Configure multiple BGP Peers with count option ################################################################################ set bgp_config_status [::ixia::emulation_bgp_config \ -port_handle $port_0 \ -mode reset \ -ip_version 4 \ -local_ip_addr 192.1.1.2 \ -remote_ip_addr 192.1.1.1 \ -local_addr_step 0.0.1.0 \ -remote_addr_step 0.0.1.0 \ -vlan_id 2 \ -vlan_id_step 1 \ -count $num_of_bgp_neighbors \ -neighbor_type internal \ -local_as 200 \ -local_as_step 1 \ -local_as_mode increment \ ] if {[keylget bgp_config_status status] != $::SUCCESS} { return "FAIL - $test_name - $port_0 BGP neighbors configuration failed. -\ [keylget bgp_config_status log]" } set ce_bgp_neighbor_handle_list [keylget bgp_config_status handles] foreach bgp_neighbor_handle $ce_bgp_neighbor_handle_list { ############################################################################ # Configure BGP routes on each BGP peer ############################################################################ set bgp_route_config_status [::ixia::emulation_bgp_route_config \ -mode add \ -handle $bgp_neighbor_handle \ -prefix $prefix_ce1 \ -prefix_step 1 \ -netmask 255.255.255.0 \ -num_routes $num_of_prefix \ -ip_version 4 \ -origin_route_enable 1 \ -origin igp \ ] if {[keylget bgp_route_config_status status] != $::SUCCESS} { return "FAIL - $test_name - $port_0 BGP routes configuration failed. -\ [keylget bgp_route_config_status log]" } set prefix_ce1 [increment_ipv4_address_script $prefix_ce1 0.1.0.0] } ################################################################################ # Configure multiple BGP Peers and BGP routes on the second Ixia port ################################################################################ set bgp_config_status [::ixia::emulation_bgp_config \ -port_handle $port_1 \ -mode reset \ -ip_version 4 \ -local_ip_addr 192.1.1.1 \ -remote_ip_addr 192.1.1.2 \ -local_addr_step 0.0.1.0 \ -remote_addr_step 0.0.1.0 \ -vlan_id 2 \ -vlan_id_step 1 \ -count $num_of_bgp_neighbors \ -neighbor_type internal \ -local_as 200 \ -local_as_step 1 \ -local_as_mode increment \ ] if {[keylget bgp_config_status status] != $::SUCCESS} { return "FAIL - $test_name - $port_1 BGP neighbors configuration failed. -\ [keylget bgp_config_status log]" } set pe_bgp_neighbor_handle_list [keylget bgp_config_status handles] foreach bgp_neighbor_handle $pe_bgp_neighbor_handle_list { set bgp_route_config_status [::ixia::emulation_bgp_route_config \ -mode add \ -handle $bgp_neighbor_handle \ -prefix $prefix_ce2 \ -prefix_step 1 \ -netmask 255.255.255.0 \ -num_routes $num_of_prefix \ -ip_version 4 \ -origin_route_enable 1 \ -origin igp \ ] if {[keylget bgp_config_status status] != $::SUCCESS} { return "FAIL - $test_name - $port_1 BGP neighbors configuration failed. -\ [keylget bgp_config_status log]" } set prefix_ce2 [increment_ipv4_address_script $prefix_ce2 0.1.0.0] } ################################################################################ # Start the BGP sessions ################################################################################ set bgp_control_status [::ixia::emulation_bgp_control \ -port_handle $port_0 \ -mode start \ ] if {[keylget bgp_config_status status] != $::SUCCESS} { return "FAIL - $test_name - $port_0 - Failed to start BGP CE emulation. -\ [keylget bgp_config_status log]" } set bgp_control_status [::ixia::emulation_bgp_control \ -port_handle $port_1 \ -mode start \ ] if {[keylget bgp_config_status status] != $::SUCCESS} { return "FAIL - $test_name - $port_1 - Failed to start BGP PE emulation. -\ [keylget bgp_config_status log]" } # this sleep is in lieu of the stats code working puts "Waiting for 10 seconds... (first port)" sleep 10 puts "Done." update idletasks ### ################################################################################ # Use ixnetwork traffic generator to configure traffic from bgp routes on # the first port to the bgp routes on the second port. # The traffic flow is tracked by source/destination endpoint pair. ################################################################################ set traffic_status [::ixia::traffic_config \ -mode create \ -traffic_generator ixnetwork_540 \ -transmit_mode continuous \ -name "IPv4_TRAFFIC" \ -src_dest_mesh one_to_one \ -route_mesh one_to_one \ -circuit_type none \ -circuit_endpoint_type ipv4 \ -emulation_src_handle $ce_bgp_neighbor_handle_list \ -emulation_dst_handle $pe_bgp_neighbor_handle_list \ -track_by endpoint_pair \ -stream_packing one_stream_per_endpoint_pair \ -rate_percent 10 \ -tx_delay 10 \ -length_mode fixed \ -frame_size 512 \ -qos_type_ixn custom \ -qos_value_ixn 8 \ -qos_value_ixn_mode incr \ -qos_value_ixn_step 2 \ -qos_value_ixn_count 2 \ -qos_value_ixn_tracking 1 \ -enable_data_integrity 0 \ ] if {[keylget traffic_status status] != $::SUCCESS} { return "FAIL - $test_name - [keylget traffic_status log]" } ################################################################################ # Start the traffic ################################################################################ set traffic_status [::ixia::traffic_control \ -action run \ -traffic_generator ixnetwork_540 \ ] if {[keylget traffic_status status] != $::SUCCESS} { return "FAIL - $test_name - [keylget traffic_status log]" } ################################################################################ # Wait for 10 seconds for the traffic to flow! ################################################################################ after 10000 set flow_traffic_status [::ixia::traffic_stats \ -mode flow \ -traffic_generator ixnetwork_540 \ ] if {[keylget flow_traffic_status status] != $::SUCCESS} { puts "FAIL - $test_name - [keylget flow_traffic_status log]" return 0 } ################################################################################ # Stop the traffic ################################################################################ set traffic_status [::ixia::traffic_control \ -action stop \ -traffic_generator ixnetwork_540 \ ] if {[keylget traffic_status status] != $::SUCCESS} { return "FAIL - $test_name - [keylget traffic_status log]" } ################################################################################ # Wait for the traffic to stop - necessary for next step (stats retrieval) ################################################################################ set flow_results [list \ "Tx Port" tx.port \ "Rx Port" rx.port \ "Tx Frames" tx.total_pkts \ "Tx Frame Rate" tx.total_pkt_rate \ "Rx Frames" rx.total_pkts \ "Frames Delta" rx.loss_pkts \ "Rx Frame Rate" rx.total_pkt_rate \ "Loss %" rx.loss_percent \ "Rx Bytes" rx.total_pkts_bytes \ "Rx Rate (Bps)" rx.total_pkt_byte_rate \ "Rx Rate (bps)" rx.total_pkt_bit_rate \ "Rx Rate (Kbps)" rx.total_pkt_kbit_rate \ "Rx Rate (Mbps)" rx.total_pkt_mbit_rate \ "Avg Latency (ns)" rx.avg_delay \ "Min Latency (ns)" rx.min_delay \ "Max Latency (ns)" rx.max_delay \ "First Timestamp" rx.first_tstamp \ "Last Timestamp" rx.last_tstamp \ ] set flows [keylget flow_traffic_status flow] foreach flow [keylkeys flows] { set flow_key [keylget flow_traffic_status flow.$flow] puts "\tFlow $flow" foreach {name key} [subst $[subst flow_results]] { puts "\t\t$name: [keylget flow_traffic_status flow.$flow.$key]" } } return "SUCCESS - $test_name - [clock format [clock seconds]]"