summaryrefslogtreecommitdiffstats
path: root/mmss/network.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'mmss/network.hpp')
-rw-r--r--mmss/network.hpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/mmss/network.hpp b/mmss/network.hpp
index 323879c..8ae72f3 100644
--- a/mmss/network.hpp
+++ b/mmss/network.hpp
@@ -36,20 +36,49 @@ namespace MMSS {
class network_t : public nocopy_t {
private:
+ context_t *mmss;
+
std::string name;
size_t mtu;
+ unsigned rand_seed;
+
+ // packet loss
+ float etx_min;
+ float etx_max;
+ float period;
+ float phase;
+
std::unordered_set<std::shared_ptr<iface_t>> interfaces;
+ float get_etx() const;
+
+ bool drop_packet();
void enqueue(const void *data, size_t len, const iface_t *src_iface, const std::shared_ptr<iface_t> &dest_iface);
public:
- network_t(const std::string &name0) : name(name0), mtu(1500) {}
+ 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) {
+ etx_min = etx_max = etx;
+ }
+
+ void set_packet_loss(float etx_min0, float etx_max0, float period0, float phase0) {
+ etx_min = etx_min0;
+ etx_max = etx_max0;
+ period = period0;
+ phase = phase0;
+ }
void add_iface(const std::shared_ptr<iface_t> &iface) {
interfaces.insert(iface);
}
+ context_t* get_context() const {
+ return mmss;
+ }
+
const std::string& get_name() const {
return name;
}