📄 test_routing1.sh
字号:
#!/usr/bin/env bash## $XORP: xorp/bgp/harness/test_routing1.sh,v 1.24 2006/08/16 22:10:14 atanu Exp $### Test basic BGP routing with three peers.## This script started with no arguments will start all required process and# terminate them at the end of the tests.## Preconditons# 1) Run a finder process# 2) Run "../fea/xorp_fea_dummy"# 3) Run xorp "../rib/xorp_rib"# 4) Run xorp "../xorp_bgp"# 5) Run "./test_peer -s peer1"# 6) Run "./test_peer -s peer2"# 7) Run "./test_peer -s peer3"# 8) Run "./coord"## Peers 1 and 2 are E-BGP Peer 3 is I-BGP#set -eonexit(){ last=$? if [ $last = "0" ] then echo "$0: Tests Succeeded" else echo "$0: Tests Failed" fi trap '' 0 2}trap onexit 0 2if [ "X${srcdir}" = "X" ] ; then srcdir=`dirname $0` ; fi. ${srcdir}/xrl_shell_funcs.sh "". ${srcdir}/../xrl_shell_funcs.sh "". ${srcdir}/../../rib/xrl_shell_funcs.sh ""HOST=127.0.0.1PORT1=10001PORT2=10002PORT3=10003PORT1_IPV6=10004PORT2_IPV6=10005PORT3_IPV6=10006PEER_PORT1=20001PEER_PORT2=20002PEER_PORT3=20003PEER_PORT1_IPV6=20004PEER_PORT2_IPV6=20005PEER_PORT3_IPV6=20006AS=65008PEER1_AS=64001PEER2_AS=64002PEER3_AS=$ASPEER1_AS_IPV6=64004PEER2_AS_IPV6=64005PEER3_AS_IPV6=$ASHOLDTIME=20# Next Hops#NH1=10.10.10.10#NH2=20.20.20.20IF1=172.16.1.1IF2=172.16.2.1IF3=172.16.3.1IF1_IPV6=40:40:40:40:40:40:40:41IF2_IPV6=50:50:50:50:50:50:50:51IF3_IPV6=60:60:60:60:60:60:60:61NH1=172.16.1.2NH2=172.16.2.2NH3=172.16.3.2NH1_IPV6=40:40:40:40:40:40:40:42NH2_IPV6=50:50:50:50:50:50:50:52NH3_IPV6=60:60:60:60:60:60:60:62NEXT_HOP=192.150.187.78configure_bgp(){ LOCALHOST=$HOST AS=65008 ID=192.150.187.78 local_config $AS $ID # EBGP - IPV4 PEER=$HOST PORT=$PORT1;PEER_PORT=$PEER_PORT1;PEER_AS=$PEER1_AS IPTUPLE="$LOCALHOST $PORT $PEER $PEER_PORT" add_peer $IPTUPLE $PEER_AS $NEXT_HOP $HOLDTIME set_parameter $IPTUPLE MultiProtocol.IPv4.Unicast true enable_peer $IPTUPLE # EBGP - IPV4 PEER=$HOST PORT=$PORT2;PEER_PORT=$PEER_PORT2;PEER_AS=$PEER2_AS IPTUPLE="$LOCALHOST $PORT $PEER $PEER_PORT" add_peer $IPTUPLE $PEER_AS $NEXT_HOP $HOLDTIME set_parameter $IPTUPLE MultiProtocol.IPv4.Unicast true enable_peer $IPTUPLE # IBGP - IPV4 PEER=$HOST PORT=$PORT3;PEER_PORT=$PEER_PORT3;PEER_AS=$PEER3_AS IPTUPLE="$LOCALHOST $PORT $PEER $PEER_PORT" add_peer $IPTUPLE $PEER_AS $NEXT_HOP $HOLDTIME set_parameter $IPTUPLE MultiProtocol.IPv4.Unicast true enable_peer $IPTUPLE # EBGP - IPV6 PEER=$HOST PORT=$PORT1_IPV6;PEER_PORT=$PEER_PORT1_IPV6;PEER_AS=$PEER1_AS_IPV6 IPTUPLE="$LOCALHOST $PORT $PEER $PEER_PORT" add_peer $IPTUPLE $PEER_AS $NEXT_HOP $HOLDTIME set_parameter $IPTUPLE MultiProtocol.IPv6.Unicast true enable_peer $IPTUPLE # EBGP - IPV6 PEER=$HOST PORT=$PORT2_IPV6;PEER_PORT=$PEER_PORT2_IPV6;PEER_AS=$PEER2_AS_IPV6 IPTUPLE="$LOCALHOST $PORT $PEER $PEER_PORT" add_peer $IPTUPLE $PEER_AS $NEXT_HOP $HOLDTIME set_parameter $IPTUPLE MultiProtocol.IPv6.Unicast true enable_peer $IPTUPLE # IBGP - IPV6 PEER=$HOST PORT=$PORT3_IPV6;PEER_PORT=$PEER_PORT3_IPV6;PEER_AS=$PEER3_AS_IPV6 IPTUPLE="$LOCALHOST $PORT $PEER $PEER_PORT" add_peer $IPTUPLE $PEER_AS $NEXT_HOP $HOLDTIME set_parameter $IPTUPLE MultiProtocol.IPv6.Unicast true enable_peer $IPTUPLE}configure_rib(){ make_rib_errors_fatal VIF0="vif0" VIF1="vif1" VIF2="vif2" VIF0_IPV6="vif3" VIF1_IPV6="vif4" VIF2_IPV6="vif5" new_vif $VIF0 new_vif $VIF1 new_vif $VIF2 new_vif $VIF0_IPV6 new_vif $VIF1_IPV6 new_vif $VIF2_IPV6 add_vif_addr4 $VIF0 $IF1 $IF1/24 add_vif_addr4 $VIF1 $IF2 $IF2/24 add_vif_addr4 $VIF2 $IF3 $IF3/24 add_vif_addr6 $VIF0_IPV6 $IF1_IPV6 $IF1_IPV6/24 add_vif_addr6 $VIF1_IPV6 $IF2_IPV6 $IF2_IPV6/24 add_vif_addr6 $VIF2_IPV6 $IF3_IPV6 $IF3_IPV6/24}test1(){ echo "TEST1 - Establish three peerings" coord reset coord target $HOST $PORT1 coord initialise attach peer1 coord peer1 establish AS $PEER1_AS \ holdtime $HOLDTIME \ id 10.10.10.1 \ keepalive false coord peer1 assert established coord target $HOST $PORT2 coord initialise attach peer2 coord peer2 establish AS $PEER2_AS \ holdtime $HOLDTIME \ id 10.10.10.2 \ keepalive false coord peer2 assert established coord target $HOST $PORT3 coord initialise attach peer3 coord peer3 establish AS $PEER3_AS \ holdtime $HOLDTIME \ id 10.10.10.3 \ keepalive false coord peer3 assert established}test1_ipv6(){ echo "TEST1 IPV6 - Establish three peerings" coord reset coord target $HOST $PORT1_IPV6 coord initialise attach peer1 coord peer1 establish AS $PEER1_AS_IPV6 \ holdtime $HOLDTIME \ id 10.10.10.1 \ keepalive false \ ipv6 true coord peer1 assert established coord target $HOST $PORT2_IPV6 coord initialise attach peer2 coord peer2 establish AS $PEER2_AS_IPV6 \ holdtime $HOLDTIME \ id 10.10.10.2 \ keepalive false \ ipv6 true coord peer2 assert established coord target $HOST $PORT3_IPV6 coord initialise attach peer3 coord peer3 establish AS $PEER3_AS_IPV6 \ holdtime $HOLDTIME \ id 10.10.10.3 \ keepalive false \ ipv6 true coord peer3 assert established}test2(){# 1) Add a route (A) via peer1# 2) Verify that route (A) appears at peer3 # 3) Add a better route (B) via peer2# 4) Verify that route (B) appears at peer3# 5) Withdraw route (b) via peer2# 6) Verify that route (A) appears at peer3 echo "TEST2 - Adding and deleting routes" coord reset coord target $HOST $PORT1 coord initialise attach peer1 coord peer1 establish AS $PEER1_AS \ holdtime $HOLDTIME \ id 10.10.10.1 \ keepalive false coord peer1 assert established coord target $HOST $PORT2 coord initialise attach peer2 coord peer2 establish AS $PEER2_AS \ holdtime $HOLDTIME \ id 10.10.10.2 \ keepalive false coord peer2 assert established coord target $HOST $PORT3 coord initialise attach peer3 coord peer3 establish AS $PEER3_AS \ holdtime $HOLDTIME \ id 10.10.10.3 \ keepalive false coord peer3 assert established # Add a route from peer1. coord peer1 send packet update \ origin 2 \ aspath "$PEER1_AS,2,[3,4,5],6,[7,8],9" \ nexthop $NH1 \ nlri 10.10.10.0/24 \ nlri 20.20.20.20/24 sleep 2 coord peer1 trie sent lookup 10.10.10.0/24 \ aspath "$PEER1_AS,2,[3,4,5],6,[7,8],9" coord peer2 trie recv lookup 10.10.10.0/24 \ aspath "65008,$PEER1_AS,2,[3,4,5],6,[7,8],9" coord peer3 trie recv lookup 10.10.10.0/24 \ aspath "$PEER1_AS,2,[3,4,5],6,[7,8],9" # Add a better route from peer2. coord peer2 send packet update \ origin 2 \ aspath "$PEER2_AS" \ nexthop $NH2 \ nlri 10.10.10.10/24 \ nlri 20.20.20.20/24 sleep 2 coord peer1 trie recv lookup 10.10.10.0/24 aspath "65008,$PEER2_AS" coord peer2 trie sent lookup 10.10.10.0/24 aspath "$PEER2_AS" coord peer3 trie recv lookup 10.10.10.0/24 aspath "$PEER2_AS" # Withdraw the better route. coord peer2 send packet update \ origin 2 \ aspath "$PEER2_AS" \ nexthop $NH2 \ withdraw 10.10.10.10/24 \ withdraw 20.20.20.20/24 sleep 2 coord peer1 trie sent lookup 10.10.10.0/24 \ aspath "$PEER1_AS,2,[3,4,5],6,[7,8],9" coord peer2 trie recv lookup 10.10.10.0/24 \ aspath "65008,$PEER1_AS,2,[3,4,5],6,[7,8],9" coord peer3 trie recv lookup 10.10.10.0/24 \ aspath "$PEER1_AS,2,[3,4,5],6,[7,8],9"# At the end of the test we expect all the peerings to still be established. coord peer1 assert established coord peer2 assert established coord peer3 assert established}test2_ipv6(){# 1) Add a route (A) via peer1# 2) Verify that route (A) appears at peer3 # 3) Add a better route (B) via peer2# 4) Verify that route (B) appears at peer3# 5) Withdraw route (b) via peer2# 6) Verify that route (A) appears at peer3 echo "TEST2 IPV6 - Adding and deleting routes" coord reset coord target $HOST $PORT1_IPV6 coord initialise attach peer1 coord peer1 establish AS $PEER1_AS_IPV6 \ holdtime $HOLDTIME \ id 10.10.10.1 \ keepalive false \ ipv6 true coord peer1 assert established coord target $HOST $PORT2_IPV6 coord initialise attach peer2 coord peer2 establish AS $PEER2_AS_IPV6 \ holdtime $HOLDTIME \ id 10.10.10.2 \ keepalive false \ ipv6 true coord peer2 assert established coord target $HOST $PORT3_IPV6 coord initialise attach peer3 coord peer3 establish AS $PEER3_AS_IPV6 \ holdtime $HOLDTIME \ id 10.10.10.3 \ keepalive false \ ipv6 true coord peer3 assert established NLRI1=10:10:10:10:10:00:00:00/80 NLRI2=20:20:20:20:20:00:00:00/80 # Add a route from peer1. coord peer1 send packet update \ origin 2 \ aspath "$PEER1_AS_IPV6,2,[3,4,5],6,[7,8],9" \ nexthop6 $NH1_IPV6 \ nlri6 $NLRI1 \ nlri6 $NLRI2 sleep 2 coord peer1 trie sent lookup $NLRI1 \ aspath "$PEER1_AS_IPV6,2,[3,4,5],6,[7,8],9" coord peer2 trie recv lookup $NLRI1 \ aspath "65008,$PEER1_AS_IPV6,2,[3,4,5],6,[7,8],9" coord peer3 trie recv lookup $NLRI1 \ aspath "$PEER1_AS_IPV6,2,[3,4,5],6,[7,8],9" coord peer1 trie sent lookup $NLRI2 \ aspath "$PEER1_AS_IPV6,2,[3,4,5],6,[7,8],9" coord peer2 trie recv lookup $NLRI2 \ aspath "65008,$PEER1_AS_IPV6,2,[3,4,5],6,[7,8],9" coord peer3 trie recv lookup $NLRI2 \ aspath "$PEER1_AS_IPV6,2,[3,4,5],6,[7,8],9" # Add a better route from peer2. coord peer2 send packet update \ origin 2 \ aspath "$PEER2_AS_IPV6" \ nexthop6 $NH2_IPV6 \ nlri6 $NLRI1 \ nlri6 $NLRI2 sleep 2 coord peer1 trie recv lookup $NLRI1 aspath "65008,$PEER2_AS_IPV6" coord peer2 trie sent lookup $NLRI1 aspath "$PEER2_AS_IPV6" coord peer3 trie recv lookup $NLRI1 aspath "$PEER2_AS_IPV6" coord peer1 trie recv lookup $NLRI2 aspath "65008,$PEER2_AS_IPV6" coord peer2 trie sent lookup $NLRI2 aspath "$PEER2_AS_IPV6" coord peer3 trie recv lookup $NLRI2 aspath "$PEER2_AS_IPV6" # Withdraw the better route. coord peer2 send packet update \ origin 2 \ aspath "$PEER2_AS_IPV6" \ nexthop6 $NH2_IPV6 \ withdraw6 $NLRI1 \ withdraw6 $NLRI2 sleep 2 coord peer1 trie sent lookup $NLRI1 \ aspath "$PEER1_AS_IPV6,2,[3,4,5],6,[7,8],9" coord peer2 trie recv lookup $NLRI1 \ aspath "65008,$PEER1_AS_IPV6,2,[3,4,5],6,[7,8],9" coord peer3 trie recv lookup $NLRI1 \ aspath "$PEER1_AS_IPV6,2,[3,4,5],6,[7,8],9" coord peer1 trie sent lookup $NLRI2 \ aspath "$PEER1_AS_IPV6,2,[3,4,5],6,[7,8],9" coord peer2 trie recv lookup $NLRI2 \ aspath "65008,$PEER1_AS_IPV6,2,[3,4,5],6,[7,8],9" coord peer3 trie recv lookup $NLRI2 \ aspath "$PEER1_AS_IPV6,2,[3,4,5],6,[7,8],9"# At the end of the test we expect all the peerings to still be established. coord peer1 assert established coord peer2 assert established coord peer3 assert established}test3(){# Route A is better than route B which is better than route C.# 1) Add a route (B) via peer1# 2) Add a route (C) via peer2 # 3) Add a route (A) via peer2 echo "TEST3 - Add routes on the same peer." coord reset coord target $HOST $PORT1 coord initialise attach peer1 coord peer1 establish AS $PEER1_AS \ holdtime $HOLDTIME \ id 10.10.10.1 \ keepalive false coord peer1 assert established coord target $HOST $PORT2 coord initialise attach peer2 coord peer2 establish AS $PEER2_AS \ holdtime $HOLDTIME \ id 10.10.10.2 \ keepalive false coord peer2 assert established
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -