SOLA
Loading...
Searching...
No Matches
natter_manager.h
1// Copyright 2023 The SOLA authors
2//
3// This file is part of DAISI.
4//
5// DAISI is free software: you can redistribute it and/or modify it under the terms of the GNU
6// General Public License as published by the Free Software Foundation; version 2.
7//
8// DAISI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
9// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
10// Public License for more details.
11//
12// You should have received a copy of the GNU General Public License along with DAISI. If not, see
13// <https://www.gnu.org/licenses/>.
14//
15// SPDX-License-Identifier: GPL-2.0-only
16
17#ifndef DAISI_NATTER_NS3_NATTER_MANAGER_H_
18#define DAISI_NATTER_NS3_NATTER_MANAGER_H_
19
20#include <deque>
21
22#include "manager/core_network.h"
23#include "manager/manager.h"
24#include "natter_application.h"
25#include "natter_logger_ns3.h"
26#include "natter_scenariofile.h"
27#include "ns3/node-container.h"
28
29namespace daisi::natter_ns3 {
30
31class NatterManager : public Manager {
32public:
33 explicit NatterManager(const std::string &scenariofile_path);
34
35private:
36 void setupImpl() override;
37 GeneralScenariofile getGeneralScenariofile() const override { return scenariofile_; }
38 std::string getDatabaseFilename() const override;
39 std::string getAdditionalParameters() const override;
40
41 struct NodeInfo {
42 const uint16_t fanout;
43 const solanet::UUID own_uuid;
44 const std::string ip;
45 const uint16_t port;
46 const uint32_t own_level;
47 const uint32_t own_number;
48 const ns3::Ptr<NatterApplication> app;
49 const uint32_t container_index;
50 };
51
52 void scheduleEvents();
53 uint64_t getNumberOfNodes() const;
54
55 void scheduleEvent(const Join &step, ns3::Time &current_time);
56 void scheduleEvent(const Publish &step, ns3::Time &current_time);
57
58 void joinTopic(int number_nodes);
59 void publishRandom(uint32_t message_size);
60 void publish(uint32_t message_size, uint32_t publishing_node);
61
62 NodeInfo getNodeInfo(uint32_t index) const;
63
64 /*
65 * Add node info to node of other_id
66 */
67 void addPeer(uint32_t other_id, const NodeInfo &info);
68 void connectParent(const NodeInfo &info);
69 std::set<uint32_t> connectChildren(const NodeInfo &info);
70 std::set<uint32_t> connectNeighbors(const NodeInfo &info);
71 void connectAdjacents(const NodeInfo &info, const std::vector<uint32_t> &lin_proj);
72 void connectRoutingTableNeighborChildren(const NodeInfo &info, const std::set<uint32_t> &children,
73 const std::set<uint32_t> &neighbors);
74
75 void joinMinhton();
76 ns3::Ptr<NatterApplication> getApplication(uint32_t id) const;
77 void removeAllLinks(uint32_t id);
78 NatterScenariofile scenariofile_;
79
80 ns3::NodeContainer nodes_;
81
82 CoreNetwork core_network_;
83
84 const std::string topic_ = "TOPIC1";
85};
86
87} // namespace daisi::natter_ns3
88
89#endif
Network structure with one central L3 router, forming a star topology.
Definition core_network.h:34
Definition manager.h:26
Definition natter_manager.h:31
Definition general_scenariofile.h:28
Definition natter_scenariofile.h:28
Definition natter_scenariofile.h:54
Definition natter_scenariofile.h:37