Created
November 12, 2013 15:56
-
-
Save thehajime/7433327 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HG changeset patch | |
# User Hajime Tazaki <[email protected]> | |
# Date 1384271550 -32400 | |
# Wed Nov 13 00:52:30 2013 +0900 | |
# Node ID 68675e7a5435221dd75161dc1dc2bef5afe652eb | |
# Parent 1681415790d726051281c65f7f1f0ebe7d53174f | |
update with experimental caida-topology-reader. | |
caida-asrel-topology-reader.patch | |
https://gist.github.com/thehajime/7433221 | |
diff -r 1681415790d7 -r 68675e7a5435 example/caida-5node.txt | |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
+++ b/example/caida-5node.txt Wed Nov 13 00:52:30 2013 +0900 | |
@@ -0,0 +1,5 @@ | |
+1 2 -1 | |
+1 3 -1 | |
+2 4 -1 | |
+3 5 -1 | |
+2 3 0 | |
diff -r 1681415790d7 -r 68675e7a5435 example/dce-quagga-bgpd-caida.cc | |
--- a/example/dce-quagga-bgpd-caida.cc Sat Aug 31 01:01:37 2013 +0900 | |
+++ b/example/dce-quagga-bgpd-caida.cc Wed Nov 13 00:52:30 2013 +0900 | |
@@ -80,6 +80,7 @@ | |
cmd.AddValue ("stopTime", "Time to stop(seconds)", stopTime); | |
cmd.Parse (argc,argv); | |
+ LogComponentEnable ("DceQuaggaBgpdCaida", LOG_LEVEL_ALL); | |
SetRlimit (); | |
// | |
@@ -91,7 +92,8 @@ | |
NodeContainer nodes; | |
std::string format ("Caida"); | |
- std::string input ("./example/asrel-as2500.txt"); | |
+ std::string input ("./myscripts/ns-3-dce-quagga/example/asrel-as2500.txt"); | |
+ input = "./myscripts/ns-3-dce-quagga/example/caida-5node.txt"; | |
topoHelp.SetFileName (input); | |
topoHelp.SetFileType (format); | |
@@ -131,12 +133,15 @@ | |
} | |
DceManagerHelper processManager; | |
- processManager.SetLoader ("ns3::DlmLoaderFactory"); | |
- processManager.SetTaskManagerAttribute ("FiberManagerType", | |
- EnumValue (0)); | |
processManager.SetNetworkStack ("ns3::LinuxSocketFdFactory", | |
"Library", StringValue ("liblinux.so")); | |
processManager.Install (nodes); | |
+ LinuxStackHelper stack; | |
+ stack.Install (nodes); | |
+ Ipv4AddressHelper address; | |
+ address.SetBase ("10.0.0.0", "255.255.255.0"); | |
+ Ipv4InterfaceContainer interfaces; | |
+ | |
QuaggaHelper quagga; | |
quagga.EnableBgp (nodes); | |
@@ -145,10 +150,12 @@ | |
for (int i = 0; i < totlinks; i++) | |
{ | |
ndc[i] = p2p.Install (nc[i]); | |
+ // assgin ip addresses | |
+ interfaces = address.Assign (ndc[i]); | |
std::string link_base; | |
std::stringstream str; | |
- str << "10." << (i / 256) << "." << (i % 256) << "."; | |
+ str << "10." << (i / 256) << "." << (i % 256) << ""; | |
link_base = str.str (); | |
// IP address configuration | |
AddAddress (nc[i].Get (0), Seconds (0.1), ndc[i].Get (0)->GetIfIndex (), (link_base + ".1/24").c_str ()); | |
@@ -159,8 +166,17 @@ | |
quagga.BgpAddNeighbor (nc[i].Get (0), link_base + ".2", quagga.GetAsn (nc[i].Get (1))); | |
quagga.BgpAddNeighbor (nc[i].Get (1), link_base + ".1", quagga.GetAsn (nc[i].Get (0))); | |
+ | |
+ // peer link | |
+ iter = inFile->LinksBegin (); | |
+ std::advance (iter, i); | |
+ if (iter->GetAttribute ("Relationship") == "0") | |
+ { | |
+ NS_LOG_DEBUG ("linkattr " << iter->GetAttribute ("Relationship")); | |
+ quagga.BgpAddPeerLink (nc[i].Get (0), link_base + ".2"); | |
+ quagga.BgpAddPeerLink (nc[i].Get (1), link_base + ".1"); | |
+ } | |
quagga.Install (nc[i]); | |
- | |
} | |
diff -r 1681415790d7 -r 68675e7a5435 helper/quagga-helper.cc | |
--- a/helper/quagga-helper.cc Sat Aug 31 01:01:37 2013 +0900 | |
+++ b/helper/quagga-helper.cc Wed Nov 13 00:52:30 2013 +0900 | |
@@ -194,6 +194,7 @@ | |
uint32_t asn; | |
std::string router_id; | |
std::vector<std::string> *neighbors; | |
+ std::vector<std::string> *peer_links; | |
std::map<std::string, uint32_t> *neighbor_asn; | |
std::vector<std::string> *networks; | |
bool isDefaultOriginate; | |
@@ -205,6 +206,7 @@ | |
neighbors = new std::vector<std::string> (); | |
neighbor_asn = new std::map<std::string, uint32_t> (); | |
networks = new std::vector<std::string> (); | |
+ peer_links = new std::vector<std::string> (); | |
isDefaultOriginate = false; | |
} | |
~BgpConfig () | |
@@ -212,6 +214,7 @@ | |
delete neighbors; | |
delete neighbor_asn; | |
delete networks; | |
+ delete peer_links; | |
} | |
static TypeId | |
GetTypeId (void) | |
@@ -248,6 +251,10 @@ | |
neighbors->push_back (n); | |
neighbor_asn->insert (std::map<std::string, uint32_t>::value_type (n, asn)); | |
} | |
+ void AddPeerLink (std::string n) | |
+ { | |
+ peer_links->push_back (n); | |
+ } | |
void addNetwork (std::string n) | |
{ | |
networks->push_back (n); | |
@@ -303,6 +310,17 @@ | |
{ | |
os << " neighbor " << *it << " default-originate" << std::endl; | |
} | |
+ | |
+ // route-map for peer-neighbor | |
+ for (std::vector<std::string>::iterator it2 = peer_links->begin (); it2 != peer_links->end (); it2++) | |
+ { | |
+ if (*it == *it2) | |
+ { | |
+ os << " neighbor " << *it << " route-map MAP-" << router_id << "-" | |
+ << *it << " out" << std::endl; | |
+ } | |
+ } | |
+ | |
} | |
for (std::vector<std::string>::iterator it = networks->begin (); it != networks->end (); it++) | |
{ | |
@@ -333,6 +351,19 @@ | |
} | |
os << " redistribute connected" << std::endl; | |
os << " exit-address-family" << std::endl; | |
+ | |
+ // access-list and route-map for peer-link filter-out | |
+ for (std::vector<std::string>::iterator it = networks->begin (); it != networks->end (); it++) | |
+ { | |
+ os << "access-list ALIST-" << router_id << " permit " << *it << std::endl; | |
+ } | |
+ for (std::vector<std::string>::iterator it = peer_links->begin (); it != peer_links->end (); it++) | |
+ { | |
+ os << "route-map MAP-" << router_id << "-" << *it << " permit 5" << std::endl; | |
+ os << " match ip address ALIST-" << router_id << std::endl; | |
+ os << "!" << std::endl; | |
+ } | |
+ | |
os << "!" << std::endl; | |
} | |
}; | |
@@ -740,6 +771,20 @@ | |
return; | |
} | |
+void | |
+QuaggaHelper::BgpAddPeerLink (Ptr<Node> node, std::string neighbor) | |
+{ | |
+ Ptr<BgpConfig> bgp_conf = node->GetObject<BgpConfig> (); | |
+ if (!bgp_conf) | |
+ { | |
+ bgp_conf = CreateObject<BgpConfig> (); | |
+ bgp_conf->SetAsn (node->GetId ()); | |
+ node->AggregateObject (bgp_conf); | |
+ } | |
+ bgp_conf->AddPeerLink (neighbor); | |
+ return; | |
+} | |
+ | |
// OSPF6 | |
void | |
QuaggaHelper::EnableOspf6 (NodeContainer nodes, const char *ifname) | |
diff -r 1681415790d7 -r 68675e7a5435 helper/quagga-helper.h | |
--- a/helper/quagga-helper.h Sat Aug 31 01:01:37 2013 +0900 | |
+++ b/helper/quagga-helper.h Wed Nov 13 00:52:30 2013 +0900 | |
@@ -154,6 +154,14 @@ | |
void BgpAddNeighbor (Ptr<Node> node, std::string neighbor, uint32_t asn); | |
/** | |
+ * \brief Configure the neighbor as peer link to filter-out the update route | |
+ * only with node's origin route (via neighbor A.B.C.D route-map MAP out command). | |
+ * | |
+ * \param neighbor The string of the experssion of a remote neighbor (IPv4/v6 address). | |
+ */ | |
+ void BgpAddPeerLink (Ptr<Node> node, std::string neighbor); | |
+ | |
+ /** | |
* \brief Enable the ospf6d daemon (OSPFv3) to the nodes. | |
* | |
* \param nodes The node(s) to enable OSPFv3 (quagga ospf6d). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment