version 0.0.1
This commit is contained in:
37
test/Attacker/Attacker_test.cpp
Normal file
37
test/Attacker/Attacker_test.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#include <rte_cycles.h>
|
||||
|
||||
TEST_CASE("tsc timer", "[]") {
|
||||
// count and print seconds since test started
|
||||
// stop at 30 seconds
|
||||
// const std::string clear(100, '\n');
|
||||
const uint64_t MAX_SECONDS = 30;
|
||||
uint64_t cycles_old = 0;
|
||||
uint64_t cycles = 0;
|
||||
uint64_t hz = rte_get_tsc_hz();
|
||||
uint64_t seconds = 0;
|
||||
uint64_t delta_t = 0;
|
||||
|
||||
// print initial message
|
||||
std::cout << "cycles : " << cycles << "\t"
|
||||
<< "hz : " << hz << "\t"
|
||||
<< "seconds : " << seconds << "\t" << std::endl;
|
||||
|
||||
while (seconds < MAX_SECONDS) {
|
||||
cycles_old = cycles;
|
||||
cycles = rte_get_tsc_cycles();
|
||||
hz = rte_get_tsc_hz();
|
||||
|
||||
// calculate
|
||||
delta_t = uint64_t(1 / hz * (cycles - cycles_old));
|
||||
seconds += delta_t;
|
||||
|
||||
// print
|
||||
// std::cout << clear;
|
||||
std::cout << "cycles : " << cycles << "\t"
|
||||
<< "hz : " << hz << "\t"
|
||||
<< "seconds : " << seconds << "\t" << std::endl;
|
||||
}
|
||||
}
|
||||
1
test/Attacker/meson.build
Normal file
1
test/Attacker/meson.build
Normal file
@@ -0,0 +1 @@
|
||||
Attacker_sources = ['test/Attacker/Attacker_test.cpp']
|
||||
16
test/Attacker/namespace-alice.sh
Normal file
16
test/Attacker/namespace-alice.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
# create network namespace aegisns
|
||||
ip netns add AEGISNS
|
||||
# assing interface enp4s0f0 to aegisns
|
||||
ip link set enp5s0f0 netns AEGISNS
|
||||
# assing ip to interface
|
||||
ip netns exec AEGISNS ip add add dev enp5s0f0 10.0.0.1/24
|
||||
# bring the link up
|
||||
ip netns exec AEGISNS ip link set dev enp5s0f0 up
|
||||
# add the standard route for the interface
|
||||
ip netns exec AEGISNS route add default gw 10.0.0.2 enp5s0f0
|
||||
# show wether the project has been successful
|
||||
ip netns exec AEGISNS ifconfig
|
||||
ip netns exec AEGISNS route
|
||||
|
||||
|
||||
|
||||
14
test/Attacker/namespace-bob.sh
Executable file
14
test/Attacker/namespace-bob.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
# create network namespace aegisns
|
||||
ip netns add AEGISNS
|
||||
# assing interface enp4s0f0 to aegisns
|
||||
ip link set enp4s0f0 netns AEGISNS
|
||||
# assing ip to interface
|
||||
ip netns exec AEGISNS ip add add dev enp4s0f0 10.0.0.2/24
|
||||
# bring the link up
|
||||
ip netns exec AEGISNS ip link set dev enp4s0f0 up
|
||||
# add the standard route for the interface
|
||||
ip netns exec AEGISNS route add default gw 10.0.0.1 enp4s0f0
|
||||
# show wether the project has been successful
|
||||
ip netns exec AEGISNS ifconfig
|
||||
ip netns exec AEGISNS route
|
||||
|
||||
Reference in New Issue
Block a user