Completely log simulations
This commit is contained in:
parent
cbbfe4360d
commit
8cc6b6dd69
12 changed files with 143 additions and 27 deletions
|
@ -1,28 +1,63 @@
|
||||||
protocol "babel" load "./libmmss_proto_babel.so" default;
|
protocol "babel" load "./libmmss_proto_babel.so" default;
|
||||||
|
|
||||||
network "net0" {
|
/* topology:
|
||||||
etx min 1.0 max 5.0 sine period 15 m;
|
|
||||||
}
|
|
||||||
|
|
||||||
network "net1" {
|
C - D
|
||||||
etx min 1.0 max 5.0 sine period 15 m phase 5 m;
|
/ \
|
||||||
}
|
A - B G - H
|
||||||
|
\ /
|
||||||
|
E - F
|
||||||
|
|
||||||
network "net2" {
|
*/
|
||||||
etx min 1.0 max 5.0 sine period 15 m phase 10 m;
|
|
||||||
}
|
|
||||||
|
|
||||||
node "node1" {
|
|
||||||
interface "mmss1.0" network "net0" address 00:00:00:00:00:00:00:10;
|
|
||||||
interface "mmss1.1" network "net1" address 00:00:00:00:00:00:00:11;
|
|
||||||
}
|
|
||||||
|
|
||||||
node "node2" {
|
network "net_A_B";
|
||||||
interface "mmss2.1" network "net1" address 00:00:00:00:00:00:00:21;
|
network "net_B_C";
|
||||||
interface "mmss2.2" network "net2" address 00:00:00:00:00:00:00:22;
|
network "net_B_E";
|
||||||
}
|
network "net_C_D" { etx min 1.0 max 5.0 sine period 20 m; }
|
||||||
|
network "net_D_G";
|
||||||
|
network "net_E_F" { etx min 1.0 max 5.0 sine period 20 m phase 10 m; }
|
||||||
|
network "net_F_G";
|
||||||
|
network "net_G_H";
|
||||||
|
|
||||||
node "node3" {
|
|
||||||
interface "mmss3.2" network "net2" address 00:00:00:00:00:00:00:32;
|
#network "net1" {
|
||||||
interface "mmss3.0" network "net0" address 00:00:00:00:00:00:00:30;
|
# etx min 1.0 max 5.0 sine period 15 m phase 5 m;
|
||||||
|
#}
|
||||||
|
|
||||||
|
#network "net2" {
|
||||||
|
# etx min 1.0 max 5.0 sine period 15 m phase 10 m;
|
||||||
|
#}
|
||||||
|
|
||||||
|
node "A" {
|
||||||
|
interface "mmss_A_B" network "net_A_B" address 00:00:00:00:00:00:01:02;
|
||||||
|
}
|
||||||
|
node "B" {
|
||||||
|
interface "mmss_B_A" network "net_A_B" address 00:00:00:00:00:00:02:01;
|
||||||
|
interface "mmss_B_C" network "net_B_C" address 00:00:00:00:00:00:02:03;
|
||||||
|
interface "mmss_B_E" network "net_B_E" address 00:00:00:00:00:00:02:05;
|
||||||
|
}
|
||||||
|
node "C" {
|
||||||
|
interface "mmss_C_B" network "net_B_C" address 00:00:00:00:00:00:03:02;
|
||||||
|
interface "mmss_C_D" network "net_C_D" address 00:00:00:00:00:00:03:04;
|
||||||
|
}
|
||||||
|
node "D" {
|
||||||
|
interface "mmss_D_C" network "net_C_D" address 00:00:00:00:00:00:04:03;
|
||||||
|
interface "mmss_D_G" network "net_D_G" address 00:00:00:00:00:00:04:07;
|
||||||
|
}
|
||||||
|
node "E" {
|
||||||
|
interface "mmss_E_B" network "net_B_E" address 00:00:00:00:00:00:05:02;
|
||||||
|
interface "mmss_E_F" network "net_E_F" address 00:00:00:00:00:00:05:06;
|
||||||
|
}
|
||||||
|
node "F" {
|
||||||
|
interface "mmss_F_E" network "net_E_F" address 00:00:00:00:00:00:06:05;
|
||||||
|
interface "mmss_F_G" network "net_F_G" address 00:00:00:00:00:00:06:07;
|
||||||
|
}
|
||||||
|
node "G" {
|
||||||
|
interface "mmss_G_D" network "net_D_G" address 00:00:00:00:00:00:07:04;
|
||||||
|
interface "mmss_G_F" network "net_F_G" address 00:00:00:00:00:00:07:06;
|
||||||
|
interface "mmss_G_H" network "net_G_H" address 00:00:00:00:00:00:07:08;
|
||||||
|
}
|
||||||
|
node "H" {
|
||||||
|
interface "mmss_H_G" network "net_G_H" address 00:00:00:00:00:00:08:07;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ add_executable(mmss
|
||||||
monitor_file.cpp
|
monitor_file.cpp
|
||||||
monitor_log.cpp
|
monitor_log.cpp
|
||||||
network.cpp
|
network.cpp
|
||||||
|
node.cpp
|
||||||
protocol.cpp
|
protocol.cpp
|
||||||
${BISON_mmss_config_parse_OUTPUTS}
|
${BISON_mmss_config_parse_OUTPUTS}
|
||||||
)
|
)
|
||||||
|
|
|
@ -63,6 +63,16 @@ public:
|
||||||
monitor->handle_init(node, node_id, len);
|
monitor->handle_init(node, node_id, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void network(network_t *net) {
|
||||||
|
for (auto monitor : monitors)
|
||||||
|
monitor->handle_network(net);
|
||||||
|
}
|
||||||
|
|
||||||
|
void node_iface(node_t *node, iface_t *iface) {
|
||||||
|
for (auto monitor : monitors)
|
||||||
|
monitor->handle_iface(node, iface);
|
||||||
|
}
|
||||||
|
|
||||||
void node_neigh(node_t *node, iface_t *iface, const gmrf_addr_t *addr, float rxcost, float txcost) {
|
void node_neigh(node_t *node, iface_t *iface, const gmrf_addr_t *addr, float rxcost, float txcost) {
|
||||||
for (auto monitor : monitors)
|
for (auto monitor : monitors)
|
||||||
monitor->handle_neigh(node, iface, addr, rxcost, txcost);
|
monitor->handle_neigh(node, iface, addr, rxcost, txcost);
|
||||||
|
|
|
@ -41,6 +41,9 @@ public:
|
||||||
|
|
||||||
virtual void handle_init(node_t *node, const uint8_t *node_id, size_t len) = 0;
|
virtual void handle_init(node_t *node, const uint8_t *node_id, size_t len) = 0;
|
||||||
|
|
||||||
|
virtual void handle_network(network_t *net) = 0;
|
||||||
|
virtual void handle_iface(node_t *node, iface_t *iface) = 0;
|
||||||
|
|
||||||
virtual void handle_neigh(node_t *node, iface_t *iface, const gmrf_addr_t *addr, float rxcost, float txcost) = 0;
|
virtual void handle_neigh(node_t *node, iface_t *iface, const gmrf_addr_t *addr, float rxcost, float txcost) = 0;
|
||||||
virtual void handle_neigh_lost(node_t *node, iface_t *iface, const gmrf_addr_t *addr) = 0;
|
virtual void handle_neigh_lost(node_t *node, iface_t *iface, const gmrf_addr_t *addr) = 0;
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,20 @@ void monitor_file_t::handle_init(node_t *node, const uint8_t *node_id, size_t le
|
||||||
std::fprintf(file, "\n");
|
std::fprintf(file, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void monitor_file_t::handle_network(network_t *net) {
|
||||||
|
std::fprintf(file, "%llu NETWORK %s\n", (unsigned long long)net->get_context()->now(), net->get_name().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void monitor_file_t::handle_iface(node_t *node, iface_t *iface) {
|
||||||
|
std::fprintf(file, "%llu IFACE %s %s %s ", (unsigned long long)node->get_context()->now(), node->get_name().c_str(), iface->get_name().c_str(), iface->get_network()->get_name().c_str());
|
||||||
|
|
||||||
|
const gmrf_addr_t *addr = iface->get_address();
|
||||||
|
for (size_t i = 0; i < GMRF_ADDR_LEN; i++)
|
||||||
|
std::fprintf(file, "%02x", addr->d[i]);
|
||||||
|
|
||||||
|
std::fprintf(file, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
void monitor_file_t::handle_neigh(node_t *node, iface_t *iface, const gmrf_addr_t *addr, float rxcost, float txcost) {
|
void monitor_file_t::handle_neigh(node_t *node, iface_t *iface, const gmrf_addr_t *addr, float rxcost, float txcost) {
|
||||||
std::fprintf(file, "%llu NEIGH %s %s ", (unsigned long long)node->get_context()->now(), node->get_name().c_str(), iface->get_name().c_str());
|
std::fprintf(file, "%llu NEIGH %s %s ", (unsigned long long)node->get_context()->now(), node->get_name().c_str(), iface->get_name().c_str());
|
||||||
for (size_t i = 0; i < GMRF_ADDR_LEN; i++)
|
for (size_t i = 0; i < GMRF_ADDR_LEN; i++)
|
||||||
|
|
|
@ -45,6 +45,9 @@ public:
|
||||||
|
|
||||||
virtual void handle_init(node_t *node, const uint8_t *node_id, size_t len);
|
virtual void handle_init(node_t *node, const uint8_t *node_id, size_t len);
|
||||||
|
|
||||||
|
virtual void handle_network(network_t *net);
|
||||||
|
virtual void handle_iface(node_t *node, iface_t *iface);
|
||||||
|
|
||||||
virtual void handle_neigh(node_t *node, iface_t *iface, const gmrf_addr_t *addr, float rxcost, float txcost);
|
virtual void handle_neigh(node_t *node, iface_t *iface, const gmrf_addr_t *addr, float rxcost, float txcost);
|
||||||
virtual void handle_neigh_lost(node_t *node, iface_t *iface, const gmrf_addr_t *addr);
|
virtual void handle_neigh_lost(node_t *node, iface_t *iface, const gmrf_addr_t *addr);
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,19 @@
|
||||||
namespace MMSS {
|
namespace MMSS {
|
||||||
|
|
||||||
void monitor_log_t::handle_log(node_t *node, int priority, const std::string &message) {
|
void monitor_log_t::handle_log(node_t *node, int priority, const std::string &message) {
|
||||||
node->get_context()->logf(priority, "%s: %s", node->get_name().c_str(), message.c_str());
|
if (priority < LOG_DEBUG)
|
||||||
|
node->get_context()->logf(priority, "%s: %s", node->get_name().c_str(), message.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void monitor_log_t::handle_init(node_t *node UNUSED, const uint8_t *node_id UNUSED, size_t len UNUSED) {
|
void monitor_log_t::handle_init(node_t *node UNUSED, const uint8_t *node_id UNUSED, size_t len UNUSED) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void monitor_log_t::handle_network(network_t *net UNUSED) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void monitor_log_t::handle_iface(node_t *node UNUSED, iface_t *iface UNUSED) {
|
||||||
|
}
|
||||||
|
|
||||||
void monitor_log_t::handle_neigh(node_t *node UNUSED, iface_t *iface UNUSED, const gmrf_addr_t *addr UNUSED, float rxcost UNUSED, float txcost UNUSED) {
|
void monitor_log_t::handle_neigh(node_t *node UNUSED, iface_t *iface UNUSED, const gmrf_addr_t *addr UNUSED, float rxcost UNUSED, float txcost UNUSED) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,9 @@ public:
|
||||||
|
|
||||||
virtual void handle_init(node_t *node, const uint8_t *node_id, size_t len);
|
virtual void handle_init(node_t *node, const uint8_t *node_id, size_t len);
|
||||||
|
|
||||||
|
virtual void handle_network(network_t *net);
|
||||||
|
virtual void handle_iface(node_t *node, iface_t *iface);
|
||||||
|
|
||||||
virtual void handle_neigh(node_t *node, iface_t *iface, const gmrf_addr_t *addr, float rxcost, float txcost);
|
virtual void handle_neigh(node_t *node, iface_t *iface, const gmrf_addr_t *addr, float rxcost, float txcost);
|
||||||
virtual void handle_neigh_lost(node_t *node, iface_t *iface, const gmrf_addr_t *addr);
|
virtual void handle_neigh_lost(node_t *node, iface_t *iface, const gmrf_addr_t *addr);
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,11 @@
|
||||||
|
|
||||||
namespace MMSS {
|
namespace MMSS {
|
||||||
|
|
||||||
|
network_t::network_t(context_t *mmss0, const std::string &name0, unsigned rand_seed0)
|
||||||
|
: mmss(mmss0), name(name0), mtu(1500), rand_seed(rand_seed0), etx_min(1), etx_max(1) {
|
||||||
|
mmss->network(this);
|
||||||
|
}
|
||||||
|
|
||||||
float network_t::get_etx() const {
|
float network_t::get_etx() const {
|
||||||
if (etx_min == etx_max)
|
if (etx_min == etx_max)
|
||||||
return etx_min;
|
return etx_min;
|
||||||
|
|
|
@ -57,8 +57,7 @@ private:
|
||||||
void enqueue(const void *data, size_t len, const iface_t *src_iface, const std::shared_ptr<iface_t> &dest_iface);
|
void enqueue(const void *data, size_t len, const iface_t *src_iface, const std::shared_ptr<iface_t> &dest_iface);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
network_t(context_t *mmss0, const std::string &name0, unsigned rand_seed0)
|
network_t(context_t *mmss0, const std::string &name0, unsigned rand_seed0);
|
||||||
: mmss(mmss0), name(name0), mtu(1500), rand_seed(rand_seed0), etx_min(1), etx_max(1) {}
|
|
||||||
|
|
||||||
void set_packet_loss(float etx) {
|
void set_packet_loss(float etx) {
|
||||||
etx_min = etx_max = etx;
|
etx_min = etx_max = etx;
|
||||||
|
|
39
mmss/node.cpp
Normal file
39
mmss/node.cpp
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "node.hpp"
|
||||||
|
#include "context.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace MMSS {
|
||||||
|
|
||||||
|
gmrf_iface_state_t * node_t::add_iface(const std::shared_ptr<iface_t> &iface) {
|
||||||
|
interfaces.insert(iface);
|
||||||
|
mmss->node_iface(this, iface.get());
|
||||||
|
return proto->add_iface(gmrf_ctx, iface.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -59,10 +59,7 @@ public:
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
gmrf_iface_state_t* add_iface(const std::shared_ptr<iface_t> &iface) {
|
gmrf_iface_state_t* add_iface(const std::shared_ptr<iface_t> &iface);
|
||||||
interfaces.insert(iface);
|
|
||||||
return proto->add_iface(gmrf_ctx, iface.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
context_t* get_context() const {
|
context_t* get_context() const {
|
||||||
return mmss;
|
return mmss;
|
||||||
|
|
Reference in a new issue