Struct valley_free::Topology [−][src]
Expand description
Definition of Topology
Fields
ases_map: HashMap<u32, As>
Hashmap of ASes: ASN (u32) to As
Implementations
Build the Topology using CAIDA AS-relationship datafile.
This function takes an reader that implements BufRead trait, read lines from the reader, and parse the input.
The CAIDA’s AS-relationship data is formatted as follows:
# A FEW LINES OF COMMENT
# A FEW LINES OF COMMENT
# A FEW LINES OF COMMENT
1|7470|0
1|9931|-1
1|11537|0
1|25418|0
2|35000|0
2|263686|0
...
The data format is:
<provider-as>|<customer-as>|-1
<peer-as>|<peer-as>|0
Recursively calculate path propagation results.
Recursion breaking conditions:
- loop detected;
- previously propagated from the AS;
- all connected ASes have been called
Propagation logic:
- if the current path is propagated from a customer, then it can propagate to all of its’ customers, providers, and peers
- if the current path is propagated from a provider or a peer, it can only propagate to its customers (thus achiving valley-free)
Full example: to explore all paths toward AS123, call
use std::{fs::File, io::BufReader, collections::HashSet};
use valley_free::*;
use bzip2::read::BzDecoder;
let mut topo = Topology::new();
let file = match File::open("20161101.as-rel.txt.bz2") {
Ok(f) => f,
Err(_) => panic!("cannot open file"),
};
let reader = BufReader::new(BzDecoder::new(&file));
let res = topo.build_topology(reader);
let mut all_paths = vec![];
let mut seen = HashSet::new();
topo.propagate_paths(&mut all_paths, 15169, Direction::UP, vec![], &mut seen);
dbg!(all_paths.len());
Arguments:
Trait Implementations
type Dict = PyClassDummySlot
type Dict = PyClassDummySlot
Specify this class has #[pyclass(dict)]
or not.
type WeakRef = PyClassDummySlot
type WeakRef = PyClassDummySlot
Specify this class has #[pyclass(weakref)]
or not.
type BaseNativeType = PyAny
type BaseNativeType = PyAny
The closest native ancestor. This is PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
. Read more
#[pyclass(subclass)]
#[pyclass(extends=…)]
type ThreadChecker = ThreadCheckerStub<Topology>
type ThreadChecker = ThreadCheckerStub<Topology>
This handles following two situations: Read more
type AsRefTarget = PyCell<Self>
type AsRefTarget = PyCell<Self>
Utility type to make Py::as_ref work.
PyTypeObject instance for this type.
Checks if object
is an instance of this type or a subclass of this type.
Checks if object
is an instance of this type.