Commit 140e085b authored by Jonathon Duerig's avatar Jonathon Duerig
Browse files

Removed ipassign routing module. All routing must new be done through...

Removed ipassign routing module. All routing must new be done through distributed-dijkstra or through the old routing module. RIP.
parent 3f12b98b
......@@ -12,20 +12,8 @@ ${CC} ${COMPILE_FLAGS} -c -o tmp/Assigner.o -I${EXTRA_INCLUDE_PATH} -DROUTECALC=
${CC} ${COMPILE_FLAGS} -c -o tmp/ConservativeAssigner.o -I${EXTRA_INCLUDE_PATH} -DROUTECALC=\"bin/routecalc\" src/ConservativeAssigner.cc
${CC} ${COMPILE_FLAGS} -c -o tmp/HierarchicalAssigner.o -I${EXTRA_INCLUDE_PATH} -DROUTECALC=\"bin/routecalc\" src/HierarchicalAssigner.cc
${CC} ${COMPILE_FLAGS} -c -o tmp/Framework.o -I${EXTRA_INCLUDE_PATH} -DROUTECALC=\"bin/routecalc\" src/Framework.cc
#${CC} ${COMPILE_FLAGS} -c -o tmp/HostRouter.o -I${EXTRA_INCLUDE_PATH} -DROUTECALC=\"bin/routecalc\" src/HostRouter.cc
${CC} ${COMPILE_FLAGS} -c -o tmp/Router.o -I${EXTRA_INCLUDE_PATH} -DROUTECALC=\"bin/routecalc\" src/Router.cc
#${CC} ${COMPILE_FLAGS} -c -o tmp/LanRouter.o -I${EXTRA_INCLUDE_PATH} -DROUTECALC=\"bin/routecalc\" src/LanRouter.cc
${CC} ${COMPILE_FLAGS} -c -o tmp/NetRouter.o -I${EXTRA_INCLUDE_PATH} -DROUTECALC=\"bin/routecalc\" src/NetRouter.cc
${CC} ${COMPILE_FLAGS} -c -o tmp/coprocess.o -I${EXTRA_INCLUDE_PATH} -DROUTECALC=\"bin/routecalc\" src/coprocess.cc
${CC} ${LINK_FLAGS} -o bin/ipassign -L${EXTRA_LIB_PATH}/ tmp/ipassign.o tmp/bitmath.o tmp/Assigner.o tmp/ConservativeAssigner.o tmp/HierarchicalAssigner.o tmp/Framework.o tmp/Router.o tmp/NetRouter.o tmp/coprocess.o -lmetis -lm
#tmp/LanRouter.o
#tmp/HostRouter.o
${CC} -O3 -c -o tmp/routestat.o -I${EXTRA_INCLUDE_PATH} src/routestat.cc
${CC} -O3 -o bin/routestat -L${EXTRA_LIB_PATH} tmp/routestat.o tmp/bitmath.o -lmetis -lm
${CC} -O3 -o bin/routecalc src/routecalc.cc
${CC} ${LINK_FLAGS} -o bin/ipassign -L${EXTRA_LIB_PATH}/ tmp/ipassign.o tmp/bitmath.o tmp/Assigner.o tmp/ConservativeAssigner.o tmp/HierarchicalAssigner.o tmp/Framework.o tmp/coprocess.o -lmetis -lm
#${CC} -o bin/difference src/difference.cc
#${CC} -o bin/add-x src/add-x.cc
......
......@@ -12,10 +12,6 @@
#include "Assigner.h"
#include "ConservativeAssigner.h"
#include "HierarchicalAssigner.h"
#include "Router.h"
//#include "HostRouter.h"
//#include "LanRouter.h"
#include "NetRouter.h"
#include "Partition.h"
#include "FixedPartition.h"
#include "SearchPartition.h"
......@@ -26,7 +22,6 @@
using namespace std;
Framework::Framework(int argCount, char ** argArray)
: m_doRouting(true)
{
if (argCount <= 0 || argArray == NULL)
{
......@@ -53,11 +48,6 @@ Framework::Framework(Framework const & right)
// You don't want to know.
m_assign.reset(right.m_assign->clone().release());
}
if (right.m_route.get() != NULL)
{
// See above.
m_route.reset(right.m_route->clone().release());
}
if (right.m_partition.get() != NULL)
{
// See above.
......@@ -71,9 +61,7 @@ Framework & Framework::operator=(Framework const & right)
// Herb Sutter's 'Exceptional C++' book.
Framework temp(right);
swap(m_assign, temp.m_assign);
swap(m_route, temp.m_route);
swap(m_partition, temp.m_partition);
swap(m_doRouting, temp.m_doRouting);
return *this;
}
......@@ -142,35 +130,15 @@ void Framework::ipAssign(void)
m_assign->ipAssign();
}
void Framework::route(void)
{
if (m_doRouting)
{
m_assign->getGraph(m_route->getTree(), m_route->getLans());
m_route->setHosts(m_assign->getHosts());
m_route->calculateRoutes();
}
}
void Framework::printIP(ostream & output) const
{
m_assign->print(output);
}
void Framework::printRoute(ostream & output) const
{
if (m_doRouting)
{
m_route->print(output);
}
}
void Framework::parseCommandLine(int argCount, char ** argArray)
{
AssignType assignChoice = Hierarchical;
RouteType routeChoice = HostNet;
m_partition.reset(new SquareRootPartition());
m_doRouting = false;
for (int i = 1; i < argCount; ++i)
{
string currentArg = argArray[i];
......@@ -180,7 +148,7 @@ void Framework::parseCommandLine(int argCount, char ** argArray)
}
else
{
parseArgument(currentArg, assignChoice, routeChoice);
parseArgument(currentArg, assignChoice);
}
}
switch (assignChoice)
......@@ -202,27 +170,10 @@ void Framework::parseCommandLine(int argCount, char ** argArray)
"Variable: assignChoice");
break;
}
switch (routeChoice)
{
case HostHost:
// m_route.reset(new HostRouter());
break;
case HostLan:
// m_route.reset(new LanRouter());
break;
case HostNet:
m_route.reset(new NetRouter());
break;
default:
throw ImpossibleConditionException("Framework::ParseCommandLine "
"Variable: routeChoice");
break;
}
}
void Framework::parseArgument(string const & arg,
Framework::AssignType & assignChoice,
Framework::RouteType & routeChoice)
Framework::AssignType & assignChoice)
{
bool done = false;
for (size_t j = 1; j < arg.size() && !done; ++j)
......@@ -292,24 +243,7 @@ void Framework::parseArgument(string const & arg,
case 'g':
assignChoice = Greedy;
break;
// use host-host routing
case 'h':
m_doRouting = true;
routeChoice = HostHost;
break;
// use host-lan routing
case 'l':
m_doRouting = true;
routeChoice = HostLan;
break;
// use host-net routing
case 'n':
m_doRouting = true;
routeChoice = HostNet;
break;
// time ip assignment and routing
case '!':
m_doRouting = false;
break;
default:
throw InvalidArgumentException(arg);
......
......@@ -13,7 +13,6 @@
#define FRAMEWORK_H_IP_ASSIGN_2
class Assigner;
class Router;
class Partition;
class Framework
......@@ -33,14 +32,8 @@ public:
// Assign IP addresses.
void ipAssign(void);
// Assign routes.
void route(void);
// Print IP addresses.
void printIP(ostream & output) const;
// Print routes.
void printRoute(ostream & output) const;
private:
// These constants are used to store the module options before the
// modules themselves are created according to the specification.
......@@ -52,31 +45,15 @@ private:
{
Fixed, SquareRoot, Search, RatioCut
};
enum RouteType
{
HostHost, HostLan, HostNet
};
private:
// The actual gruntwork of parsing the arguments
void parseCommandLine(int argCount, char ** argArray);
void parseArgument(std::string const & arg, AssignType & assignChoice,
RouteType & routeChoice);
void parseArgument(std::string const & arg, AssignType & assignChoice);
private:
// The selector for which IP assignment strategy to use
std::auto_ptr<Assigner> m_assign;
// The selector for which routing strategy to use
std::auto_ptr<Router> m_route;
// The selector for which partitioning strategy to use
std::auto_ptr<Partition> m_partition;
bool m_doRouting;
};
#endif
......@@ -13,29 +13,26 @@ ROUTECALC_PATH = \"$(INSTALL_LIBEXECDIR)/rcalc\"
include $(OBJDIR)/Makeconf
CXXFLAGS += -O3 -I/usr/local/include/metis \
-DROUTECALC=$(ROUTECALC_PATH)
CXXFLAGS += -O3 -I/usr/local/include/metis
LDFLAGS += -L/usr/local/lib
LIBEXEC_STUFF = ipassign rcalc
LIBEXEC_STUFF = ipassign
BIN_STUFF = difference add-x inet2graph brite2graph top2graph routestat
BIN_STUFF = difference add-x inet2graph brite2graph top2graph
IPASSIGN_OBJECTS = Assigner.o ConservativeAssigner.o Framework.o \
HierarchicalAssigner.o NetRouter.o Router.o bitmath.o \
HierarchicalAssigner.o bitmath.o \
coprocess.o ipassign.o
# LanRouter.o HostRouter.o
ROUTECALC_OBJECTS = routecalc.o
BIN_OBJECTS = $(addsuffix .o, $(BIN_STUFF))
HEADERS = Assigner.h ConservativeAssigner.h Exception.h \
FixedPartition.h Framework.h GraphConverter.h \
HierarchicalAssigner.h NetRouter.h \
PTree.h Partition.h Router.h SearchPartition.h \
HierarchicalAssigner.h \
PTree.h Partition.h SearchPartition.h \
SquareRootPartition.h bitmath.h coprocess.h lib.h
#
......@@ -58,16 +55,11 @@ bin-install: $(addprefix $(INSTALL_BINDIR)/, $(BIN_STUFF))
ipassign: $(IPASSIGN_OBJECTS) $(HEADERS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(IPASSIGN_OBJECTS) -lm -lmetis -o ipassign
rcalc: $(ROUTECALC_OBJECTS) $(HEADERS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(ROUTECALC_OBJECTS) -lm -o rcalc
$(BIN_STUFF): $(BIN_OBJECTS) $(HEADERS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) $< -o $@ -lm -lmetis
$(IPASSIGN_OBJECTS): $(HEADERS)
$(ROUTECALC_OBJECTS): $(HEADERS)
$(BIN_OBJECTS): $(HEADERS)
post-install:
......
// HostRouter.cc
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2003 University of Utah and the Flux Group.
* All rights reserved.
*/
#include "lib.h"
#include "Exception.h"
#include "HostRouter.h"
#include "Assigner.h"
#include "bitmath.h"
#include "coprocess.h"
using namespace std;
HostRouter::HostRouter()
{
}
HostRouter::~HostRouter()
{
}
auto_ptr<Router> HostRouter::clone(void) const
{
// return auto_ptr<Router>(new HostRouter(*this));
return auto_ptr<Router>(NULL);
}
void HostRouter::calculateRoutes(void)
{
if (hosts.size() != 0 && lans.size() != 0)
{
FileWrapper file(coprocess(ROUTECALC).release());
m_tableList.clear();
m_tableList.resize(hosts.size());
for (size_t i = 0; i < hosts.size(); ++i)
{
if (isValidNode(i))
{
m_tableList[i].resize(hosts.size());
for (size_t j = 0; j < hosts[i].size(); ++j)
{
size_t lan = hosts[i][j];
for (size_t k = 0; k < lans[lan].hosts.size(); ++k)
{
size_t node = lans[lan].hosts[k];
if (i != node)
{
write(file, 'i', i, node,
static_cast<float>(lans[lan].weight));
}
}
}
}
}
write(file, 'C');
int readCount = 0;
int source = 0;
int dest = 0;
int firstHop = 0;
int distance = 0;
readCount = read(file, source, dest, firstHop, distance);
while (readCount == 4)
{
if (isValidNode(source))
{
m_tableList[source][dest] = firstHop;
}
readCount = read(file, source, dest, firstHop, distance);
}
}
}
void HostRouter::print(ostream & output) const
{
// Preprocessing. Figure out which IP addresses to use for all
// adjascent interfaces. We have the first hop in terms of hosts,
// and this structure will provide a link from the host to the interface
// IP address.
// This maps adjascent nodes to IP addresses.
map<size_t, IPAddress> nodeToIP;
output << "%%" << endl;
for (size_t i = 0; i < m_tableList.size(); ++i)
{
if (m_tableList[i].size() != 0)
{
findAdjascentInterfaces(i, nodeToIP);
printTable(output, i, nodeToIP);
}
}
}
void HostRouter::findAdjascentInterfaces(size_t node,
map<size_t, IPAddress> & nodeToIP) const
{
nodeToIP.clear();
// in every LAN that we're connected to
vector<size_t>::const_iterator lanPos = hosts[node].begin();
for (; lanPos != hosts[node].end(); ++lanPos)
{
// in every node that is in one of those LANs
vector<size_t> const & firstHopList = hosts[*lanPos];
vector<size_t>::const_iterator pos = firstHopList.begin();
for (; pos != firstHopList.end(); ++pos)
{
// Note that we'll be repeatedly overwriting an IPAddress for
// the current node. But that is ok since the current node is
// never used as a firstHop.
// If this becomes an issue, put a conditional here.
nodeToIP[*pos] = lans[*lanPos].partition->getPrefix() + *pos + 1;
}
}
}
void HostRouter::printTable(ostream & output, size_t node,
map<size_t, IPAddress> & nodeToIP) const
{
size_t lanCount = lans.size();
// Print the routing table itself
output << "Routing table for node: " << node << endl;
for (size_t destLan = 0; destLan < lanCount; ++destLan)
{
for (size_t destNodeIndex = 0;
destNodeIndex < lans[destLan].hosts.size();
++destNodeIndex)
{
size_t destNode = lans[destLan].hosts[destNodeIndex];
// if the destination LAN is not connected to the current node.
if (find(hosts[node].begin(),
hosts[node].end(), destLan)
== hosts[node].end())
{
output << "Destination: "
<< ipToString(lans[destLan].partition->getPrefix()
+ destNodeIndex + 1)
<< "/32" // host routing means no subnets
<< " FirstHop: "
<< ipToString(
nodeToIP[m_tableList[node][destNode]])
<< endl;
}
}
}
// Use '%%' to divide routing tables from another.
output << "%%" << endl;
}
// HostRouter.h
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2003 University of Utah and the Flux Group.
* All rights reserved.
*/
// This module sets up individual routes from every host to every interface.
// Because of this, the routes are guaranteed to the the shortest path.
// Unfortunately, this also means that the routing tables are going to be
// huge and the speed will be glacial.
#ifndef HOST_ROUTER_H_IP_ASSIGN_2
#define HOST_ROUTER_H_IP_ASSIGN_2
#include "Router.h"
class HostRouter : public Router
{
public:
HostRouter();
virtual ~HostRouter();
virtual void visitBranch(ptree::Branch &)
{
}
virtual void visitLeaf(ptree::Leaf &)
{
}
virtual std::auto_ptr<Router> clone(void) const;
virtual void calculateRoutes(void);
virtual void print(std::ostream & output) const;
virtual std::auto_ptr<ptree::Node> & getTree(void)
{
return tree;
}
virtual std::vector<ptree::LeafLan> & getLans(void)
{
return lans;
}
virtual void setHosts(Assigner::NodeLookup & source)
{
hosts = source;
}
private:
// pre-processing for print. Each host has adjascent interfaces.
// The first hop information in m_tableList provides hops in terms of
// nodes. But the first hop info we are to output is in terms of the
// IP addresses of adjascent interfaces.
// This function calculates those IP addresses.
void findAdjascentInterfaces(size_t node,
map<size_t, IPAddress> & nodeToIP) const;
// Print out the actual table for a particular node.
void printTable(ostream & output, size_t node,
map<size_t, IPAddress> & nodeToIP) const;
private:
// For each node, which is the first node on the shortest path to it?
typedef std::vector< size_t > RouteTable;
// A routing table for every node. The first index is which node's routing
// table. The second index is the destination. The result is the next
// hop.
std::vector<RouteTable> m_tableList;
std::auto_ptr<ptree::Node> tree;
std::vector<ptree::LeafLan> lans;
Assigner::NodeLookup hosts;
};
#endif
// LanRouter.cc
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2003 University of Utah and the Flux Group.
* All rights reserved.
*/
#include "lib.h"
#include "bitmath.h"
#include "LanRouter.h"
#include "coprocess.h"
using namespace std;
LanRouter::LanRouter()
{
}
LanRouter::~LanRouter()
{
}
auto_ptr<Router> LanRouter::clone(void) const
{
return auto_ptr<Router>(new LanRouter(*this));
}
void LanRouter::calculateRoutes(void)
{
size_t i = 0;
size_t j = 0;
size_t k = 0;
Assigner::LevelLookup & lanToNode = m_levelMakeup[0];
Assigner::NodeLookup & nodeToLan = m_nodeToLevel[0];
size_t lanCount = lanToNode.size();
size_t nodeCount = nodeToLan.size();
// setup the routing table.
routingTable.clear();
routingTable.resize(nodeCount);
// Create a vector of maps which yields a node for each pair of LANs which
// are adjascent. This node is one of the nodes which connects them.
vector< map<size_t,size_t> > lanConnectionList;
lanConnectionList.resize(lanCount);
for (i = 0; i < nodeCount; ++i)
{
// Each node connects every pair of LANs it touches together with
// each other.
connectLans(nodeToLan[i], i, lanConnectionList);
}
// vector< firstHop, weight >
vector< vector< pair<size_t, int> > > lanShortestPaths;
lanShortestPaths.resize(lanCount);
// calculate lan shortest paths
{
FileWrapper file(coprocess(ROUTECALC).release());
for (i = 0; i < lanCount; ++i)
{
lanShortestPaths[i].resize(lanCount);
for (j = 0; j < lanToNode[i].size(); ++j)
{
size_t node = lanToNode[i][j];
for (k = 0; k < nodeToLan[node].size(); ++k)
{
size_t lan = nodeToLan[node][k];
if (i != lan)
{
write(file, 'i', i, lan, m_lanWeights[lan]);
}
}
}
}
write(file, 'C');
int readCount = 0;
int source = 0;
int dest = 0;
int firstHop = 0;
int distance = 0;
readCount = read(file, source, dest, firstHop, distance);
while (readCount == 4)
{
lanShortestPaths[source][dest] = make_pair(firstHop, distance);
readCount = read(file, source, dest, firstHop, distance);
}
}
// For every lan, run Dijkstra's algorithm.
for (i = 0; i < lanCount; ++i)
{
calculateRoutesFrom(i, lanConnectionList, lanToNode, nodeToLan,
lanShortestPaths[i]);
}
// Now that we know the best paths between LANs, go through every node
for (i = 0; i < nodeCount; ++i)
{
if (isValidNode(i))
{
vector<size_t> & currentNode = nodeToLan[i];
// set up the routing table
routingTable[i].resize(lanCount);
for (j = 0; j < lanCount; ++j)
{
// and determine which node is the first on the path to that
// LAN.
routingTable[i][j] = chooseLan(i, j, nodeToLan[i],
lanConnectionList,
lanShortestPaths);
}