test_peering1.sh
来自「BCAST Implementation for NS2」· Shell 代码 · 共 884 行 · 第 1/2 页
SH
884 行
#!/usr/bin/env bash## $XORP: xorp/bgp/harness/test_peering1.sh,v 1.19 2003/10/30 04:55:40 atanu Exp $### Test basic BGP error generation and connection creation.## 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 a FEA process.# 3) Run a RIB process.# 4) Run xorp "../xorp_bgp"# 5) Run "./test_peer -s peer1"# 6) Run "./coord"#set -e# srcdir is set by make for check targetif [ "X${srcdir}" = "X" ] ; then srcdir=`dirname $0` ; fi. ${srcdir}/xrl_shell_funcs.sh "". ${srcdir}/../xrl_shell_funcs.sh ""onexit(){ last=$? if [ $last = "0" ] then echo "$0: Tests Succeeded" else echo "$0: Tests Failed" fi trap '' 0 2}trap onexit 0 2HOST=localhostLOCALHOST=$HOSTID=192.150.187.78AS=65008# IBGP - IPV4PEER1=$HOSTPORT1=10001PEER1_PORT=20001PEER1_AS=$AS# EBGP - IPV4PEER2=$HOSTPORT2=10002PEER2_PORT=20002PEER2_AS=65000# IBGP - IPV6PEER3=$HOSTPORT3=10003PEER3_PORT=20003PEER3_AS=$AS# EBGP - IPV6PEER4=$HOSTPORT4=10004PEER4_PORT=20004PEER4_AS=65000HOLDTIME=30configure_bgp(){ local_config $AS $ID # Don't try and talk to the rib. register_rib "" # IBGP - IPV4 PEER=$PEER1 NEXT_HOP=192.150.187.78 add_peer $LOCALHOST $PORT1 $PEER $PEER1_PORT $PEER1_AS $NEXT_HOP $HOLDTIME enable_peer $LOCALHOST $PORT1 $PEER $PEER1_PORT # EBGP - IPV4 PEER=$PEER2 NEXT_HOP=192.150.187.78 add_peer $LOCALHOST $PORT2 $PEER $PEER2_PORT $PEER2_AS $NEXT_HOP $HOLDTIME enable_peer $LOCALHOST $PORT2 $PEER $PEER2_PORT # IBGP - IPV6 PEER=$PEER3 NEXT_HOP=192.150.187.78 add_peer $LOCALHOST $PORT3 $PEER $PEER3_PORT $PEER3_AS $NEXT_HOP $HOLDTIME set_parameter $LOCALHOST $PORT3 $PEER $PEER3_PORT MultiProtocol.IPv6.Unicast enable_peer $LOCALHOST $PORT3 $PEER $PEER3_PORT # IBGP - IPV6 PEER=$PEER4 NEXT_HOP=192.150.187.78 add_peer $LOCALHOST $PORT4 $PEER $PEER4_PORT $PEER4_AS $NEXT_HOP $HOLDTIME set_parameter $LOCALHOST $PORT4 $PEER $PEER4_PORT MultiProtocol.IPv6.Unicast enable_peer $LOCALHOST $PORT4 $PEER $PEER4_PORT}HOLD_TIMER=4FSM_ERROR=5OPEN_ERROR=2UNACCEPTHOLDTIME=6UPDATEMSGERR=3 # Update error MALATTRLIST=1 # Malformed Attribute ListMISSWATTR=3 # Missing Well-known Attributereset(){ coord reset coord target $HOST $PORT1 coord initialise attach peer1}test1(){ echo "TEST1 - Establish a peering with a holdtime of $HOLDTIME wait for expiration" reset # XXX # This test is a little suspect as the number of keepalives sent # by the peer is implementation dependent although it is # recommended that the keepalive interval is determined by # dividing the holdtime by three. There should be a way of # soaking up keepalives. coord peer1 expect packet open asnum $AS bgpid $ID holdtime $HOLDTIME coord peer1 expect packet keepalive coord peer1 expect packet keepalive coord peer1 expect packet keepalive coord peer1 expect packet keepalive coord peer1 expect packet notify $HOLD_TIMER coord peer1 establish AS $PEER1_AS \ holdtime $HOLDTIME \ id 192.150.187.100 \ keepalive false sleep $HOLDTIME sleep 2 sleep 2 coord peer1 assert queue 0}test2(){ echo "TEST2 - Make a connection and send an update packet" reset coord peer1 connect sleep 2 coord peer1 expect packet notify $FSM_ERROR coord peer1 send packet update sleep 2 coord peer1 assert queue 0}test3(){ echo "TEST3 - Try and send an illegal hold time of 1" reset coord peer1 expect packet open asnum $AS bgpid $ID holdtime $HOLDTIME coord peer1 expect packet notify $OPEN_ERROR $UNACCEPTHOLDTIME coord peer1 establish AS $PEER1_AS \ holdtime 1 \ id 192.150.187.100 \ keepalive false sleep 2 coord peer1 assert queue 0}test4(){ echo "TEST4 - Send an update packet and don't get it back" PACKET='packet update origin 2 aspath 1,2,(3,4,5),6,(7,8),9 nexthop 20.20.20.20 nlri 10.10.10.0/24 nlri 20.20.20.20/24 localpref 100' reset coord peer1 establish AS $PEER1_AS holdtime 0 id 192.150.187.100 coord peer1 assert established coord peer1 expect $PACKET coord peer1 send $PACKET sleep 2 coord peer1 assert queue 1 coord peer1 assert established}test5(){ echo "TEST5 - Passively wait for a connection." coord reset coord target $HOST $PEER1_PORT coord initialise attach peer1 coord peer1 establish \ active false \ AS $PEER1_AS \ holdtime $HOLDTIME \ id 192.150.187.100 # Toggle the BGP peering to force a connection attempt. disable_peer $LOCALHOST $PORT1 $PEER1 $PEER1_PORT $PEER1_AS enable_peer $LOCALHOST $PORT1 $PEER1 $PEER1_PORT $PEER1_AS echo "Sleeping $HOLDTIME" sleep $HOLDTIME coord peer1 expect packet notify $HOLD_TIMER}test6(){ echo "TEST6 - Send an update packet without an origin" PACKET='packet update aspath 1,2,(3,4,5),6,(7,8),9 nexthop 20.20.20.20 nlri 10.10.10.0/24 nlri 20.20.20.20/24' reset coord peer1 establish AS $PEER1_AS holdtime 0 id 192.150.187.100 coord peer1 expect packet notify $UPDATEMSGERR $MISSWATTR 1 coord peer1 send $PACKET sleep 2 coord peer1 assert queue 0}test7(){ echo "TEST7 - Send an update packet without an aspath" PACKET='packet update origin 1 nexthop 20.20.20.20 nlri 10.10.10.0/24 nlri 20.20.20.20/24' reset coord peer1 establish AS $PEER1_AS holdtime 0 id 192.150.187.100 coord peer1 expect packet notify $UPDATEMSGERR $MISSWATTR 2 coord peer1 send $PACKET sleep 2 coord peer1 assert queue 0}test8(){ echo "TEST8 - Send an update packet without a nexthop" PACKET='packet update origin 1 aspath 1 nlri 10.10.10.0/24 nlri 20.20.20.20/24' reset coord peer1 establish AS $PEER1_AS holdtime 0 id 192.150.187.100 sleep 2 coord peer1 expect packet notify $UPDATEMSGERR $MISSWATTR 3 coord peer1 send $PACKET coord peer1 assert queue 0}test8_ipv6(){ echo "TEST8 IPv6" echo " 1) Establish an EBGP IPv6 peering" echo " 2) Send a multiprotocol nlri with no nexthop" coord reset coord target $HOST $PORT4 coord initialise attach peer1 coord peer1 establish AS $PEER4_AS holdtime 0 id 192.150.187.100 ipv6 true PACKET="packet update origin 1 aspath $PEER4_AS nlri6 2000::/3" coord peer1 expect packet notify $UPDATEMSGERR $MISSWATTR 3 coord peer1 send $PACKET sleep 2 coord peer1 assert queue 0 coord peer1 assert idle}test9(){ echo "TEST9:" echo " 1) Send an update packet as an IBGP peer with no local pref" echo " 2) This is not an error. Our BGP emits a warning" PACKET='packet update origin 1 aspath 1 nexthop 20.20.20.20 nlri 10.10.10.0/24 nlri 20.20.20.20/24' reset coord peer1 establish AS $AS holdtime 0 id 192.150.187.100 coord peer1 assert established coord peer1 expect packet notify $UPDATEMSGERR $MISSWATTR 5 coord peer1 send $PACKET sleep 2 coord peer1 assert queue 1 coord peer1 assert established}test10(){ echo "TEST10:" echo " 1) Send an update packet as an EBGP peer with local pref" echo " 2) This is not an error. Our BGP emits a warning" PACKET="packet update origin 1 aspath $PEER2_AS nexthop 20.20.20.20 localpref 100 nlri 10.10.10.0/24 nlri 20.20.20.20/24" coord reset coord target $HOST $PORT2 coord initialise attach peer1 coord peer1 establish AS $PEER2_AS holdtime 0 id 192.150.187.100 coord peer1 assert established#we dont expect an error - the line below is to trap one if it does occur coord peer1 expect packet notify $UPDATEMSGERR $MISSWATTR coord peer1 send $PACKET sleep 2 coord peer1 assert queue 1 coord peer1 assert established}test11(){ echo "TEST11:" echo " 1) Send an update packet with two NLRIs" echo " 2) Then send an update packet to withdraw both NLRIs" PACKET_1="packet update origin 1 aspath $PEER2_AS nexthop 20.20.20.20 nlri 10.10.10.0/24 nlri 20.20.20.20/24" PACKET_2='packet update withdraw 10.10.10.0/24 withdraw 20.20.20.20/24' coord reset coord target $HOST $PORT2 coord initialise attach peer1 coord peer1 establish AS $PEER2_AS holdtime 0 id 192.150.187.100 coord peer1 assert established coord peer1 expect packet notify $UPDATEMSGERR $MISSWATTR coord peer1 send $PACKET_1 sleep 2 coord peer1 assert queue 1 coord peer1 assert established sleep 2 coord peer1 assert established coord peer1 expect packet notify $UPDATEMSGERR $MISSWATTR coord peer1 send $PACKET_2 sleep 2 coord peer1 assert queue 2 coord peer1 assert established}test12(){ echo "TEST12 - Send an update packet on an IBGP peer twice" PACKET='packet update origin 1 aspath 1 localpref 2 nexthop 20.20.20.20 nlri 10.10.10.0/24 nlri 20.20.20.20/24' reset coord peer1 establish AS $AS holdtime 0 id 192.150.187.100 coord peer1 assert established coord peer1 expect packet notify $UPDATEMSGERR $MISSWATTR coord peer1 send $PACKET coord peer1 send $PACKET sleep 2 coord peer1 assert queue 1 coord peer1 assert established}test13(){ echo "TEST13:"
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?