~ubuntu-branches/ubuntu/jaunty/xorp/jaunty

« back to all changes in this revision

Viewing changes to ospf/test_routing1.py

  • Committer: Bazaar Package Importer
  • Author(s): Jose Calhariz, Javier Fernandez-Sanguino, Jose Calhariz
  • Date: 2008-01-23 01:24:37 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080123012437-7l2u9r0k8e7op8st
Tags: 1.5~cvs.20080128-1
[ Javier Fernandez-Sanguino ]
* Update to latest CVS contents
* Modify debian/rules to prevent autobuilders from building 
  the binary-independent components: (Closes: #441121)
  - Create a new Build-Depends-Indep with all the TeX
  components used to build documentation
  - Since autobuilders call build, which in turns calls build-indep, hack
    the debian rules file so that the documentation is only built if ps2pdf,
    dvips and pslatex are available. 
* Modify the init.d script:
  - restart action: Do not attempt to stop xorp if not running
  - stop function: fix errors in the script
  - add a try-restart action
  - restructure the init.d script, move the restart code to a function
  - review the use of echo calls and exit values
* Use, as examples, the new boot files at rtrmgr/config/

[ Jose Calhariz ]
* Add depends on ncurses-dev, I don't know why xorp use tigetstr
  function from curses.  This way the depends field change less between
  build environments.
* Removed pushd and popd commands from Makefile and replaced with cd
  commands, was a bashism and FTBFS (closes: #453637)
* debian/control converted to utf-8 (closes: #454026) (closes: #453485)
* init.d/xorp now returns 0 if disabled.
* Added Vcs-Browser and Vcs-Svn fields pointing to the repository of the
  package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
2
 
3
 
# Copyright (c) 2001-2007 International Computer Science Institute
 
3
# Copyright (c) 2001-2008 International Computer Science Institute
4
4
#
5
5
# Permission is hereby granted, free of charge, to any person obtaining a
6
6
# copy of this software and associated documentation files (the "Software")
12
12
# notice is a summary of the XORP LICENSE file; the license in that file is
13
13
# legally binding.
14
14
 
15
 
# $XORP: xorp/ospf/test_routing1.py,v 1.25 2007/03/19 09:02:21 atanu Exp $
 
15
# $XORP: xorp/ospf/test_routing1.py,v 1.28 2008/01/04 03:16:58 pavlin Exp $
16
16
 
17
17
import getopt
18
18
import sys
35
35
    ['r5V3', True, 'v3'],
36
36
    ['r6V3', True, 'v3'],
37
37
    ['r7V3', True, 'v3'],
 
38
    ['r8V2', True, 'v2'],
 
39
    ['r9V2', True, 'v2'],
 
40
    ['r10V2', True, 'v2'],
 
41
    ['r11V3', True, 'v3'],
 
42
    ['r12V3', True, 'v3'],
 
43
    ['r13V3', True, 'v3'],
38
44
    ]
39
45
 
40
46
def start_routing_interactive(verbose, protocol):
797
803
    else:
798
804
        return False
799
805
 
 
806
def r8V2(verbose, protocol):
 
807
    """
 
808
    Simple two router case the next two tests will add another link between
 
809
    RT1 and RT2.
 
810
    """
 
811
 
 
812
    # RT1 is this router
 
813
    # RT2 is its direct neighbour
 
814
    # A single route should be installed for 10.1.1.0/24 via 10.1.2.1
 
815
                               
 
816
    #            +-----+                     +-----+
 
817
    #            | RT1 |                     | RT2 |
 
818
    #            |     |                     |     |
 
819
    #            |     |                     |     |
 
820
    # 10.2.2.0/24|     |                     |     |10.1.1.0/24
 
821
    # -----------|     |                     |     |------------
 
822
    #            |     |     10.1.2.0/24     |     |         
 
823
    #            |     |---------------------|     |
 
824
    #            |     |10.1.2.2     10.1.2.1|     |
 
825
    #            |     |     metric 1        |     |
 
826
    #            +-----+                     +-----+
 
827
 
 
828
    fp = start_routing_interactive(verbose, protocol)
 
829
 
 
830
    RT1 = "RouterLsa E-bit lsid 127.1.0.2 adv 127.1.0.2 \
 
831
    stub lsid 10.2.2.0 ldata  255.255.255.0 metric 1 \
 
832
    transit lsid 10.1.2.2 ldata 10.1.2.2 metric 1 \
 
833
    "
 
834
 
 
835
    RT2 = "RouterLsa E-bit lsid 127.1.0.1 adv 127.1.0.1 \
 
836
    stub lsid 10.1.1.0 ldata  255.255.255.0 metric 1 \
 
837
    transit lsid 10.1.2.2 ldata 10.1.2.1 metric 1 \
 
838
    "
 
839
 
 
840
    RT1_NETWORK1 = "NetworkLsa E-bit lsid 10.1.2.2 adv 127.1.0.2 \
 
841
    netmask 0xffffff00 \
 
842
    add-router 127.1.0.2 \
 
843
    add-router 127.1.0.1 \
 
844
    "
 
845
 
 
846
    RT1_NETWORK2 = "NetworkLsa E-bit lsid  99.1.1.2 adv 127.1.0.2 \
 
847
    netmask 0xffffff00 \
 
848
    add-router 127.1.0.2 \
 
849
    add-router 127.1.0.1 \
 
850
    "
 
851
 
 
852
    command = """
 
853
set_router_id 127.1.0.2
 
854
create 0.0.0.0 normal
 
855
select 0.0.0.0
 
856
replace %s
 
857
add %s
 
858
add %s
 
859
add %s
 
860
compute 0.0.0.0
 
861
verify_routing_table_size 1
 
862
verify_routing_entry 10.1.1.0/24 10.1.2.1 2 false false
 
863
""" % (RT1, RT2, RT1_NETWORK1, RT1_NETWORK2)
 
864
 
 
865
    print >>fp, command
 
866
 
 
867
    if not fp.close():
 
868
        return True
 
869
    else:
 
870
        return False
 
871
 
 
872
def r9V2(verbose, protocol):
 
873
    """
 
874
    Test that when there are two paths between two routers the one
 
875
    with the lowest metric is choosen. This test is the same as the
 
876
    previous test apart from the addition of the more expensive path.
 
877
    """
 
878
 
 
879
    # RT1 is this router
 
880
    # RT2 is its direct neighbour via two interfaces.
 
881
    # A single route should be installed for 10.1.1.0/24 via 10.1.2.1
 
882
 
 
883
    #            +-----+                     +-----+
 
884
    #            | RT1 |     99.1.2.0/24     | RT2 |
 
885
    #            |     |---------------------|     |
 
886
    #            |     |99.1.2.2     99.1.2.1|     |
 
887
    # 10.2.2.0/24|     |     metric 10       |     |10.1.1.0/24
 
888
    # -----------|     |                     |     |------------
 
889
    #            |     |     10.1.2.0/24     |     |         
 
890
    #            |     |---------------------|     |
 
891
    #            |     |10.1.2.2     10.1.2.1|     |
 
892
    #            |     |     metric 1        |     |
 
893
    #            +-----+                     +-----+
 
894
                               
 
895
    fp = start_routing_interactive(verbose, protocol)
 
896
 
 
897
    RT1 = "RouterLsa E-bit lsid 127.1.0.2 adv 127.1.0.2 \
 
898
    age 1074 seqno 0x8000001a cksum 0x9976 \
 
899
    transit lsid 99.1.1.2 ldata 99.1.1.2 metric 10 \
 
900
    stub lsid 10.2.2.0 ldata  255.255.255.0 metric 1 \
 
901
    transit lsid 10.1.2.2 ldata 10.1.2.2 metric 1 \
 
902
    "
 
903
 
 
904
    RT2 = "RouterLsa E-bit lsid 127.1.0.1 adv 127.1.0.1 \
 
905
    age 1076 seqno 0x8000001a cksum 0x4cc9 \
 
906
    transit lsid 99.1.1.2 ldata 99.1.1.1 metric 10 \
 
907
    stub lsid 10.1.1.0 ldata  255.255.255.0 metric 1 \
 
908
    transit lsid 10.1.2.2 ldata 10.1.2.1 metric 1 \
 
909
    "
 
910
 
 
911
    RT1_NETWORK1 = "NetworkLsa E-bit lsid 10.1.2.2 adv 127.1.0.2 \
 
912
    age 1075 seqno 0x80000019 cksum 0x3676 \
 
913
    netmask 0xffffff00 \
 
914
    add-router 127.1.0.2 \
 
915
    add-router 127.1.0.1 \
 
916
    "
 
917
 
 
918
    RT1_NETWORK2 = "NetworkLsa E-bit lsid  99.1.1.2 adv 127.1.0.2 \
 
919
    age 1074 seqno 0x80000019 cksum 0xb79c \
 
920
    netmask 0xffffff00 \
 
921
    add-router 127.1.0.2 \
 
922
    add-router 127.1.0.1 \
 
923
    "
 
924
 
 
925
    command = """
 
926
set_router_id 127.1.0.2
 
927
create 0.0.0.0 normal
 
928
select 0.0.0.0
 
929
replace %s
 
930
add %s
 
931
add %s
 
932
add %s
 
933
compute 0.0.0.0
 
934
verify_routing_table_size 1
 
935
verify_routing_entry 10.1.1.0/24 10.1.2.1 2 false false
 
936
""" % (RT1, RT2, RT1_NETWORK1, RT1_NETWORK2)
 
937
 
 
938
    print >>fp, command
 
939
 
 
940
    if not fp.close():
 
941
        return True
 
942
    else:
 
943
        return False
 
944
 
 
945
def r10V2(verbose, protocol):
 
946
    """
 
947
    Test that when there are two paths between two routers the one
 
948
    with the lowest metric is choosen. This test is identical to the
 
949
    previous test apart from the order of the transit links in the
 
950
    Router-LSAs.
 
951
    """
 
952
 
 
953
    # RT1 is this router
 
954
    # RT2 is its direct neighbour via two interfaces.
 
955
    # A single route should be installed for 10.1.1.0/24 via 10.1.2.1
 
956
 
 
957
    #            +-----+                     +-----+
 
958
    #            | RT1 |     99.1.2.0/24     | RT2 |
 
959
    #            |     |---------------------|     |
 
960
    #            |     |99.1.2.2     99.1.2.1|     |
 
961
    # 10.2.2.0/24|     |     metric 10       |     |10.1.1.0/24
 
962
    # -----------|     |                     |     |------------
 
963
    #            |     |     10.1.2.0/24     |     |         
 
964
    #            |     |---------------------|     |
 
965
    #            |     |10.1.2.2     10.1.2.1|     |
 
966
    #            |     |     metric 1        |     |
 
967
    #            +-----+                     +-----+
 
968
 
 
969
    fp = start_routing_interactive(verbose, protocol)
 
970
 
 
971
    RT1 = "RouterLsa E-bit lsid 127.1.0.2 adv 127.1.0.2 \
 
972
    age 1074 seqno 0x8000001a cksum 0x9976 \
 
973
    transit lsid 10.1.2.2 ldata 10.1.2.2 metric 1 \
 
974
    stub lsid 10.2.2.0 ldata  255.255.255.0 metric 1 \
 
975
    transit lsid 99.1.1.2 ldata 99.1.1.2 metric 10 \
 
976
    "
 
977
 
 
978
    RT2 = "RouterLsa E-bit lsid 127.1.0.1 adv 127.1.0.1 \
 
979
    age 1076 seqno 0x8000001a cksum 0x4cc9 \
 
980
    transit lsid 10.1.2.2 ldata 10.1.2.1 metric 1 \
 
981
    stub lsid 10.1.1.0 ldata  255.255.255.0 metric 1 \
 
982
    transit lsid 99.1.1.2 ldata 99.1.1.1 metric 10 \
 
983
    "
 
984
 
 
985
    RT1_NETWORK1 = "NetworkLsa E-bit lsid 10.1.2.2 adv 127.1.0.2 \
 
986
    age 1075 seqno 0x80000019 cksum 0x3676 \
 
987
    netmask 0xffffff00 \
 
988
    add-router 127.1.0.2 \
 
989
    add-router 127.1.0.1 \
 
990
    "
 
991
 
 
992
    RT1_NETWORK2 = "NetworkLsa E-bit lsid  99.1.1.2 adv 127.1.0.2 \
 
993
    age 1074 seqno 0x80000019 cksum 0xb79c \
 
994
    netmask 0xffffff00 \
 
995
    add-router 127.1.0.2 \
 
996
    add-router 127.1.0.1 \
 
997
    "
 
998
 
 
999
    command = """
 
1000
set_router_id 127.1.0.2
 
1001
create 0.0.0.0 normal
 
1002
select 0.0.0.0
 
1003
replace %s
 
1004
add %s
 
1005
add %s
 
1006
add %s
 
1007
compute 0.0.0.0
 
1008
verify_routing_table_size 1
 
1009
verify_routing_entry 10.1.1.0/24 10.1.2.1 2 false false
 
1010
""" % (RT1, RT2, RT1_NETWORK1, RT1_NETWORK2)
 
1011
 
 
1012
    print >>fp, command
 
1013
 
 
1014
    if not fp.close():
 
1015
        return True
 
1016
    else:
 
1017
        return False
 
1018
 
 
1019
def r11database():
 
1020
    """
 
1021
    Return the database for test r11V3
 
1022
    """
 
1023
 
 
1024
    # RT1 is this router.
 
1025
    # RTC is an area border router that generates an Inter-Area-Prefix-LSA.
 
1026
    # RT1 is connected to RTC via transit.
 
1027
 
 
1028
    #                            +
 
1029
    #     +---+1       1+---+1   |
 
1030
    #     |RT1|---------|RTC|----| Other Area
 
1031
    #     +---+         +---+    |
 
1032
    #                            +
 
1033
 
 
1034
    # Network           IPv6 prefix
 
1035
    # -----------------------------------
 
1036
    # Other Area        3ffe:4725:c404::/64
 
1037
 
 
1038
    # Router    Interface   Interface ID   link-local address
 
1039
    # -------------------------------------------------------
 
1040
    # RT1       to RTC      4              fe80::8:800:200c:4300
 
1041
    # RTC       to RT1      3              fe80::8:800:200c:4350
 
1042
 
 
1043
    RT1 = "RouterLsa V6-bit E-bit R-bit lsid 0.0.0.0 adv 10.80.52.103 \
 
1044
    transit iid 4 nid 4 nrid 10.80.52.103 metric 1 \
 
1045
    "
 
1046
    RT1_LINK = "LinkLsa lsid 0.0.0.4 adv 10.80.52.103 \
 
1047
    link-local-address fe80::8:800:200c:4300"
 
1048
 
 
1049
    RT1_NETWORK = "NetworkLsa lsid 0.0.0.4 adv 10.80.52.103 \
 
1050
    add-router 10.80.52.103 \
 
1051
    add-router 10.80.52.107 \
 
1052
    "
 
1053
 
 
1054
    RTC = "RouterLsa bit-B V6-bit E-bit R-bit lsid 0.0.0.1 adv 10.80.52.107 \
 
1055
    transit iid 3 nid 4 nrid 10.80.52.103 metric 1 \
 
1056
    "
 
1057
 
 
1058
    RTC_LINK = "LinkLsa lsid 0.0.0.3 adv 10.80.52.107 \
 
1059
    link-local-address fe80::8:800:200c:4350"
 
1060
 
 
1061
    RTC_INTER = "SummaryNetworkLsa lsid 0.0.0.2 adv 10.80.52.107 \
 
1062
    metric 1 \
 
1063
    IPv6Prefix 3ffe:4725:c404::/64 \
 
1064
    "
 
1065
 
 
1066
    database = """
 
1067
replace %s
 
1068
add %s
 
1069
add %s
 
1070
add %s
 
1071
add %s
 
1072
add %s
 
1073
""" % (RT1,RT1_LINK,RT1_NETWORK,
 
1074
       RTC,RTC_LINK,RTC_INTER)
 
1075
 
 
1076
    return database
 
1077
 
 
1078
def r11V3(verbose, protocol):
 
1079
    """
 
1080
    Verify the correct processing of Inter-Area-Prefix-LSAs, when this router
 
1081
    is connected to the generating router by a Network-LSA.
 
1082
    """
 
1083
 
 
1084
    fp = start_routing_interactive(verbose, protocol)
 
1085
 
 
1086
    command = """
 
1087
set_router_id 10.80.52.103
 
1088
create 0.0.0.0 normal
 
1089
select 0.0.0.0
 
1090
%s
 
1091
compute 0.0.0.0
 
1092
verify_routing_table_size 1
 
1093
verify_routing_entry 3ffe:4725:c404::/64 fe80::8:800:200c:4350 2 false false
 
1094
""" % r11database()
 
1095
 
 
1096
    print >>fp, command
 
1097
 
 
1098
    if not fp.close():
 
1099
        return True
 
1100
    else:
 
1101
        return False
 
1102
 
 
1103
def r12database():
 
1104
    """
 
1105
    Return the database for test r12V3
 
1106
    """
 
1107
 
 
1108
    # RT1 is this router.
 
1109
    # RTB is an area border router that generates an Intra-Area-Prefix-LSA.
 
1110
    # RT1 is connected to RTB via transit.
 
1111
 
 
1112
    #                            +
 
1113
    #     +---+1       1+---+1   |
 
1114
    #     |RT1|---------|RTB|----| Other Area
 
1115
    #     +---+         +---+    |
 
1116
    #                            +
 
1117
 
 
1118
    # Network           IPv6 prefix
 
1119
    # -----------------------------------
 
1120
    # Other Area        3ffe:4725:c404::/64
 
1121
 
 
1122
    # Router    Interface   Interface ID   link-local address
 
1123
    # -------------------------------------------------------
 
1124
    # RT1       to RTB      5              fe80::8:800:200c:4200
 
1125
    # RTB       to RT1      2              fe80::8:800:200c:4250
 
1126
 
 
1127
    RT1 = "RouterLsa V6-bit E-bit R-bit lsid 0.0.0.0 adv 10.80.52.103 \
 
1128
    transit iid 5 nid 5 nrid 10.80.52.103 metric 1 \
 
1129
    "
 
1130
    RT1_LINK = "LinkLsa lsid 0.0.0.5 adv 10.80.52.103 \
 
1131
    link-local-address fe80::8:800:200c:4200"
 
1132
 
 
1133
    RT1_NETWORK = "NetworkLsa lsid 0.0.0.5 adv 10.80.52.103 \
 
1134
    add-router 10.80.52.103 \
 
1135
    add-router 10.80.52.106 \
 
1136
    "
 
1137
 
 
1138
    RTB = "RouterLsa bit-B V6-bit E-bit R-bit lsid 0.0.0.1 adv 10.80.52.106 \
 
1139
    transit iid 2 nid 5 nrid 10.80.52.103 metric 1 \
 
1140
    "
 
1141
 
 
1142
    RTB_LINK = "LinkLsa lsid 0.0.0.2 adv 10.80.52.106 \
 
1143
    link-local-address fe80::8:800:200c:4250"
 
1144
 
 
1145
    RTB_INTRA = "IntraAreaPrefixLsa lsid 0.0.0.2 adv 10.80.52.106 \
 
1146
    rlstype 0x2001 rlsid 0.0.0.0 radv 10.80.52.106 \
 
1147
    IPv6Prefix 3ffe:4725:c404::/64 metric 3 \
 
1148
    "
 
1149
 
 
1150
    database = """
 
1151
replace %s
 
1152
add %s
 
1153
add %s
 
1154
add %s
 
1155
add %s
 
1156
add %s
 
1157
""" % (RT1,RT1_LINK,RT1_NETWORK,
 
1158
       RTB,RTB_LINK,RTB_INTRA)
 
1159
 
 
1160
    return database
 
1161
 
 
1162
def r12V3(verbose, protocol):
 
1163
    """
 
1164
    Verify the correct processing of Intra-Area-Prefix-LSAs.
 
1165
    """
 
1166
 
 
1167
    fp = start_routing_interactive(verbose, protocol)
 
1168
 
 
1169
    command = """
 
1170
set_router_id 10.80.52.103
 
1171
create 36.0.0.0 normal
 
1172
select 36.0.0.0
 
1173
%s
 
1174
compute 36.0.0.0
 
1175
verify_routing_table_size 1
 
1176
verify_routing_entry 3ffe:4725:c404::/64 fe80::8:800:200c:4250 4 false false
 
1177
""" % r12database()
 
1178
 
 
1179
    print >>fp, command
 
1180
 
 
1181
    if not fp.close():
 
1182
        return True
 
1183
    else:
 
1184
        return False
 
1185
 
 
1186
def r13V3(verbose, protocol):
 
1187
    """
 
1188
    Verify that Intra-Area-Prefix-LSAs always win over Inter-Area-Prefix-LSAs.
 
1189
    The same route is introduced into thebackbone 0.0.0.0 and area 36.0.0.0,
 
1190
    In the backbone 0.0.0.0 it is an Inter-Area-Prefix-LSA, in area 36.0.0.0
 
1191
    it is an Intra-Area-Prefix-LSA.
 
1192
 
 
1193
    The two area databases are introduced in various orders and the
 
1194
    computations run to make sure that however the LSAs are introduced
 
1195
    the IntraAreaPrefixLsa always wins.
 
1196
    """
 
1197
 
 
1198
    init = """
 
1199
set_router_id 10.80.52.103
 
1200
create 0.0.0.0 normal
 
1201
create 36.0.0.0 normal
 
1202
"""
 
1203
 
 
1204
    area0 = """
 
1205
select 0.0.0.0
 
1206
%s
 
1207
""" % (r11database())
 
1208
 
 
1209
    verify0 = """
 
1210
verify_routing_table_size 1
 
1211
verify_routing_entry 3ffe:4725:c404::/64 fe80::8:800:200c:4350 2 false false
 
1212
"""
 
1213
 
 
1214
    area36 = """
 
1215
select 36.0.0.0
 
1216
%s
 
1217
""" % (r12database())
 
1218
 
 
1219
    verify36 = """
 
1220
verify_routing_table_size 1
 
1221
verify_routing_entry 3ffe:4725:c404::/64 fe80::8:800:200c:4250 4 false false
 
1222
"""
 
1223
 
 
1224
    fp = start_routing_interactive(verbose, protocol)
 
1225
 
 
1226
    print >>fp, init
 
1227
    print >>fp, area0
 
1228
    print >>fp, "compute 0.0.0.0"
 
1229
    print >>fp, verify0
 
1230
    print >>fp, area36
 
1231
    print >>fp, "compute 36.0.0.0"
 
1232
    print >>fp, verify36
 
1233
 
 
1234
    if fp.close():
 
1235
        return False
 
1236
 
 
1237
    fp = start_routing_interactive(verbose, protocol)
 
1238
 
 
1239
    print >>fp, init
 
1240
    print >>fp, area36
 
1241
    print >>fp, "compute 36.0.0.0"
 
1242
    print >>fp, verify36
 
1243
    print >>fp, area0
 
1244
    print >>fp, "compute 0.0.0.0"
 
1245
    print >>fp, verify36
 
1246
 
 
1247
    if fp.close():
 
1248
        return False
 
1249
 
 
1250
    fp = start_routing_interactive(verbose, protocol)
 
1251
 
 
1252
    print >>fp, init
 
1253
    print >>fp, area0
 
1254
    print >>fp, area36
 
1255
    print >>fp, "compute 0.0.0.0"
 
1256
    print >>fp, verify0
 
1257
 
 
1258
    if fp.close():
 
1259
        return False
 
1260
 
 
1261
    return True
 
1262
 
800
1263
def main():
801
1264
    def usage():
802
1265
        us = \