Struct valley_free::Topology[][src]

pub struct Topology {
    pub ases_map: HashMap<u32, As>,
}
Expand description

Definition of Topology

Fields

ases_map: HashMap<u32, As>

Hashmap of ASes: ASN (u32) to As

Implementations

Constructor of the Topology struct

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:

  1. loop detected;
  2. previously propagated from the AS;
  3. all connected ASes have been called

Propagation logic:

  1. if the current path is propagated from a customer, then it can propagate to all of its’ customers, providers, and peers
  2. 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:

  • all_paths: a muttable Vector of Paths passed in to store explored paths
  • asn: the current ASN that will propagate paths
  • dir: the Direction of the propagation
  • path: the path so far(not including the current AS)
  • seen: a HashSet of ASes that it has explored already

Trait Implementations

Extracts Self from the source PyObject.

Performs the conversion.

Specify this class has #[pyclass(dict)] or not.

Specify this class has #[pyclass(weakref)] or not.

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict. Read more

Class doc string

#[pyclass(gc)]

#[pyclass(subclass)]

#[pyclass(extends=…)]

Layout

Base class

This handles following two situations: Read more

Utility type to make Py::as_ref work.

Class name.

Module name, if any.

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.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Arguments for exception

Returns the safe abstraction over the type object.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.