Commit 2a953c92 authored by Jonathon Duerig's avatar Jonathon Duerig
Browse files

initial ipassign import

parent 55974abc
ipassign requires the METIS library.
To compile, simply run the 'build' shell script. This will create ipassign and
its associated utilities in the bin/ directory. To test, run bin/autocheck
from the mini-root.
Input
-----
The input consists of a series of specifications for LANs (a link is just a
LAN with only two nodes). Each LAN is specified by a number representing the
weight (this must be integral), followed by a series of integers, each one
representing a node which the LAN is connected to. The LANs are automatically
numbered in order of appearance (starting at 0).
Currently, the program assumes IPv4 addresses and a 10.* prefix. However,
should the need arise, this can easily be changed to an IPv6 address or
some other prefix.
Output
------
The first line of the output is a header. It consists of three integers,
representing the number of bits allocated for the global network, the number
of bits for the LANs in each network, and the number of bits for the hosts in
each LAN, respectively. This allows the outside to calculate bitmasks for
every address.
The bitmask for a global net is 0xFFFFFFFF << (lanBits + hostBits).
The bitmask for a lan net is (0xFFFFFFFF >> hostBits) << hostBits.
The bitmask for a host is 0xFFFFFFFF.
Unless I got mixed up somewhere along the line. If so, someone email me. :)
These bitmasks would change if one were using IPv6 addresses (changeable at
compile time through some constants).
Each additional line of output is a specification of an IP address. There
are two numbers and an IP dotted quadruplet. The first number is the LAN
number (which is the ordinality of that LAN - 1). The second is the number
of a node.
This means that the node has the IP address on the interface connected with
the LAN.
Process
-------
The input is used to populate a graph object. This object contains many
LANs, each LAN being a node in the graph. It is important to realize that
the graph the program is interested in is a graph of a bunch of LANs connected
to each other by nodes. A kind of inverse of the graph we normally think of.
This LAN-graph is then converted into an appropriate form and fed into the
METIS graph-partitioning algorithm. The result is that each LAN is given
a partition number from 0 to numPartitions-1. There is a slight inconsistency
if numPartitions == 1. METIS changes every LAN's partition number to 1 rather
than 0. This is accounted for and each node is set to 0 in this case.
Then IP addresses are generated. The global-net number of each node is the
partition number. For each global-net number, successive LANs in that
global-net are given LAN-net numbers. And for each host in a LAN, successive
host numbers are given. Host numbers that are all 0s or all 1s are avoided.
Errors
------
Non-numeric and non-whitespace characters in the input are invalid.
LANs must have at least two nodes connected to them.
Right now the size of the bitspace used for hosts and LANs is pretty
conservative. The largest network defines the space for LANs and the largest
LAN defines the space for hosts. Therefore with large graphs, it is possible
to run out of bitspace, which is an error.
Room for Improvement
--------------------
One could be a lot smarter about how to allocate which bits for which level
of the hierarchy. If there are a few large lans, for instance, it is more
bit-conservative to assign them multiple blocks rather than increase the
block size.
One could increase the number of levels in the hierarchy. Right now there
are only 3. If this were increased, one might be able to create even
smaller routing tables.
Bugs
----
None that I know of.
#!/bin/sh
# make the proper directories
mkdir tmp
mkdir tmp/result
mkdir bin
# for now we assume that METIS has been installed and the include and
# library files are in accessible locations.
g++ -c -o tmp/ipassign.o src/ipassign.cc
g++ -c -o tmp/Graph.o src/Graph.cc
g++ -o bin/ipassign tmp/ipassign.o tmp/Graph.o -lmetis -lm
g++ -o bin/top2graph src/top2graph.cc -lm
g++ -o bin/autocheck src/autocheck.cc -lm
g++ -o bin/boolcmp src/boolcmp.cc -lm
bin/autocheck
# Lines starting with a '#' are comments and are ignored.
# Lines starting with '=' mark a divider. A horizontal line is written at
# that point. Anything else on the line is ignored.
# Lines starting with a '$' define a variable. Paths and filenames are
# relative to the working directory of autocheck. Slashes are
# automatically converted to be compatible with your os.
# All of the paths default to '.'
# Where to put the output generated by the script. This output file is
# checked against the output file with the same name in $keyOutputPath.
$trialOutputPath tmp/result/
# This is the path where the test scripts are held.
$scriptPath graph/
# This is where the master copies of the script output files are held.
$keyOutputPath result/
### The three command variables must have a value.
# This is the command that is used to execute scripts.
$runCommand bin/ipassign
# This is the command that is used to compare two output or two program files.
$compareCommand bin/boolcmp
# Every other line must contain a word, some whitespace, then a number.
# For example (if the next line didn't have the '#'):
# word 15
# For each value from 1 to the number, a test will be run and the following
# files will be created (relative to the current directory):
# $trialOutputPath/word1.result
# And so on for 2..14
# $trialOutputPath/word14-output.txt
# After those files are created, then comparisons are made to determine
# whether the test passes or failed.
# If '$trialOutputPath/word?.result' is identical to
# '$keyOutputPath/word?.result', then the output test passes.
# Where ? means the number of the test (between 1 and 15 in this case)
# Note that this means that both word and number should only contain
# characters that can be put in a filename. And the number should
# be an integer.
# Note if the 'zero index' flag is set, then the number range would be
# 0..14 in this example.
# word number
# ---- ------
=
kgraph 5
=
torus-real 1
=
narrows 9
=
tree 3
=
1 0 1
1 0 2
1 0 3
1 1 2
1 1 3
1 2 3
1 0 1
1 0 2
1 0 3
1 0 4
1 1 2
1 1 3
1 1 4
1 2 3
1 2 4
1 3 4
1 0 1 2 3 4 5 6 7 8 9 10
1 10 11 12 13 14 15 16 17 18 19 20
1 20 21 22
1 23 24 25 26 0
1 0 1 2 3 4 5 6 7 8
1 8 9 10 11 12 13 14 15 16
1 0 1 2 3 4 5 6 7 8 9 10
1 0 11
1 11 12 13 14 15 16 17 18 19 20 21
1 0 1
1 1 2
1 2 3
1 3 4
1 2 5
1 5 6
1 5 7
1 5 8
1 2 9
1 9 10
1 0 1 2
1 2 3 4
1 4 5 6
1 3 7 8
1 8 9
1 9 10
1 7 11 12
1 11 13 14
1 12 15 16
1 0 1 2
1 0 3 4
1 0 4 5
1 0 6 7
1 13 14
1 13 122
1 13 79
1 13 33
1 119 120
1 119 42
1 119 71
1 119 1
1 120 121
1 120 72
1 120 2
1 121 122
1 121 73
1 121 3
1 122 74
1 122 4
1 14 15
1 14 80
1 14 38
1 15 17
1 15 81
1 15 43
1 17 21
1 17 83
1 17 47
1 21 24
1 21 86
1 21 51
1 24 28
1 24 89
1 24 54
1 28 32
1 28 93
1 28 57
1 32 37
1 32 97
1 32 59
1 37 42
1 37 101
1 37 61
1 42 105
1 42 62
1 79 80
1 79 74
1 79 16
1 71 72
1 71 105
1 71 63
1 72 73
1 72 64
1 73 74
1 73 65
1 74 66
1 80 81
1 80 18
1 81 83
1 81 20
1 83 86
1 83 23
1 86 89
1 86 27
1 89 93
1 89 31
1 93 97
1 93 36
1 97 101
1 97 41
1 101 105
1 101 46
1 105 50
1 16 18
1 16 66
1 16 82
1 63 64
1 63 50
1 63 5
1 64 65
1 64 6
1 65 66
1 65 7
1 66 8
1 18 20
1 18 84
1 20 23
1 20 87
1 23 27
1 23 90
1 27 31
1 27 94
1 31 36
1 31 98
1 36 41
1 36 102
1 41 46
1 41 106
1 46 50
1 46 109
1 50 112
1 82 84
1 82 8
1 82 19
1 5 6
1 5 112
1 5 123
1 6 7
1 6 124
1 7 8
1 7 125
1 8 0
1 84 87
1 84 22
1 87 90
1 87 26
1 90 94
1 90 30
1 94 98
1 94 35
1 98 102
1 98 40
1 102 106
1 102 45
1 106 109
1 106 49
1 109 112
1 109 53
1 112 56
1 19 22
1 19 0
1 19 85
1 123 124
1 123 56
1 123 75
1 124 125
1 124 76
1 125 0
1 125 77
1 0 78
1 22 26
1 22 88
1 26 30
1 26 92
1 30 35
1 30 96
1 35 40
1 35 100
1 40 45
1 40 104
1 45 49
1 45 108
1 49 53
1 49 111
1 53 56
1 53 114
1 56 116
1 85 88
1 85 78
1 85 25
1 75 76
1 75 116
1 75 67
1 76 77
1 76 68
1 77 78
1 77 69
1 78 70
1 88 92
1 88 29
1 92 96
1 92 34
1 96 100
1 96 39
1 100 104
1 100 44
1 104 108
1 104 48
1 108 111
1 108 52
1 111 114
1 111 55
1 114 116
1 114 58
1 116 60
1 25 29
1 25 70
1 25 91
1 67 68
1 67 60
1 67 9
1 68 69
1 68 10
1 69 70
1 69 11
1 70 12
1 29 34
1 29 95
1 34 39
1 34 99
1 39 44
1 39 103
1 44 48
1 44 107
1 48 52
1 48 110
1 52 55
1 52 113
1 55 58
1 55 115
1 58 60
1 58 117
1 60 118
1 91 95
1 91 12
1 91 33
1 9 10
1 9 118
1 9 1
1 10 11
1 10 2
1 11 12
1 11 3
1 12 4
1 95 99
1 95 38
1 99 103
1 99 43
1 103 107
1 103 47
1 107 110
1 107 51
1 110 113
1 110 54
1 113 115
1 113 57
1 115 117
1 115 59
1 117 118
1 117 61
1 118 62
1 33 38
1 33 4
1 1 2
1 1 62
1 2 3
1 3 4
1 38 43
1 43 47
1 47 51
1 51 54
1 54 57
1 57 59
1 59 61
1 61 62
1 0 1
1 0 2
1 0 3
1 1 4
1 4 5 6
1 1 7
1 7 8 9
1 1 10
1 10 11 12
1 2 13
1 2 14
1 2 15
1 13 16 17
1 14 18 19
1 15 20 21
1 3 22
1 3 23
1 3 24
1 22 25 26
1 23 27 28
1 24 29 30
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment