SOLA
Loading...
Searching...
No Matches
natter_application.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_APPLICATION_H_
18#define DAISI_NATTER_NS3_NATTER_APPLICATION_H_
19
20#include "natter/natter.h"
21#include "natter/natter_minhcast.h"
22#include "natter_logger_ns3.h"
23#include "natter_mode.h"
24#include "ns3/application.h"
25#include "ns3/ipv4-address.h"
26#include "ns3/packet.h"
27#include "ns3/ptr.h"
28#include "ns3/simulator.h"
29#include "ns3/socket.h"
30#include "ns3/uinteger.h"
31
32namespace daisi::natter_ns3 {
33
36class NatterApplication : public ns3::Application {
37public:
38 static ns3::TypeId GetTypeId();
39 NatterApplication() = default;
40
41 void setMode(NatterMode mode);
42
43 void setLevelNumber(std::pair<uint32_t, uint32_t> level_number);
44 std::pair<uint32_t, uint32_t> getLevelNumber() const { return level_number_; }
45
46 // Natter functions wrapper
47 void addPeer(const std::string &topic, const natter::minhcast::NatterMinhcast::NodeInfo &info);
48 void removePeer(const std::string &topic, const std::string &uuid);
49
50 solanet::UUID getUUID() const;
51
52 void publish(const std::string &topic, const std::string &msg);
53 void subscribeTopic(const std::string &topic,
54 const natter::minhcast::NatterMinhcast::NodeInfo &info);
55 void unsubscribeTopic(const std::string &topic);
56
57 natter::NetworkInfoIPv4 getNetworkInfo() const;
58
59private:
60 void StartApplication() final;
61
62 void logSelfToDB(std::pair<uint32_t, uint32_t> level_number);
63
64 std::unique_ptr<natter::minhcast::NatterMinhcast> natter_minhcast_;
65
66 std::shared_ptr<natter::logging::NatterLoggerNs3> logger_;
67
68 ns3::Ptr<ns3::Socket> socket_;
69
70 std::pair<uint32_t, uint32_t> level_number_;
71
72 NatterMode mode_ = NatterMode::kNone;
73};
74} // namespace daisi::natter_ns3
75#endif
Wrapper to run natter as a ns-3 application. Only MINHCAST is supported at the moment!
Definition natter_application.h:36
Definition network_info_ipv4.h:14