SOLA
Loading...
Searching...
No Matches
minhton_scenariofile.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_MINHTON_NS3_MINHTON_SCENARIOFILE_H_
18#define DAISI_MINHTON_NS3_MINHTON_SCENARIOFILE_H_
19
20#include <string>
21#include <variant>
22
23#include "manager/general_scenariofile.h"
24#include "minhton/utils/algorithm_types_container.h"
25#include "minhton/utils/timeout_lengths_container.h"
26#include "peer_discovery_attributes.h"
27#include "peer_discovery_requests.h"
28#include "scenario_steps.h"
29
30namespace daisi::minhton_ns3 {
31
32struct Timeouts {
33 // From minhton::TimeoutLengthsContainer
34 // Intentionally not reusing the struct to avoid
35 // forgetting about adding new members to this parser method
36 uint64_t bootstrap_response;
37 uint64_t join_response;
38 uint64_t join_accept_ack_response;
39 uint64_t replacement_offer_response;
40 uint64_t replacement_ack_response;
41 uint64_t dsn_aggregation;
42 uint64_t inquiry_aggregation;
43
44 void parse(const YAML::Node &node);
45
49 cont.bootstrap_response = bootstrap_response;
50 cont.join_response = join_response;
51 cont.join_accept_ack_response = join_accept_ack_response;
52 cont.replacement_offer_response = replacement_offer_response;
53 cont.replacement_ack_response = replacement_ack_response;
54 cont.dsn_aggregation = dsn_aggregation;
55 cont.inquiry_aggregation = inquiry_aggregation;
56 return cont;
57 }
58};
59
60struct Algorithms {
61 std::string join;
62 std::string leave;
63 std::string search_exact;
64 std::string response;
65 std::string bootstrap;
66
67 void parse(const YAML::Node &node);
68
72
73 std::unordered_map<std::string, minhton::JoinAlgorithms> string_to_join_algorithms_type{
74 {"minhton", minhton::JoinAlgorithms::kJoinMinhton},
75 };
76
77 std::unordered_map<std::string, minhton::LeaveAlgorithms> string_to_leave_algorithms_type{
78 {"minhton", minhton::LeaveAlgorithms::kLeaveMinhton},
79 };
80
81 std::unordered_map<std::string, minhton::SearchExactAlgorithms>
82 string_to_search_exact_algorithms_type{
83 {"minhton", minhton::SearchExactAlgorithms::kSearchExactMinhton},
84 };
85
86 std::unordered_map<std::string, minhton::ResponseAlgorithms> string_to_response_algorithms_type{
87 {"general", minhton::ResponseAlgorithms::kResponseGeneral},
88 };
89
90 std::unordered_map<std::string, minhton::BootstrapAlgorithms>
91 string_to_bootstrap_algorithms_type{
92 {"general", minhton::BootstrapAlgorithms::kBootstrapGeneral},
93 };
94
95 cont.bootstrap = string_to_bootstrap_algorithms_type.at(bootstrap);
96 cont.join = string_to_join_algorithms_type.at(join);
97 cont.leave = string_to_leave_algorithms_type.at(leave);
98 cont.search_exact = string_to_search_exact_algorithms_type.at(search_exact);
99 cont.response = string_to_response_algorithms_type.at(response);
100
101 return cont;
102 }
103};
104
106 std::vector<PeerDiscoveryAttribute> attributes;
107 Requests requests;
108
109 void parse(const YAML::Node &node);
110};
111
115 step;
116
117 void parse(const YAML::Node &node);
118};
119
121 explicit MinhtonScenariofile(const std::string &path_to_file);
122
123 uint16_t fanout;
124 Timeouts timeouts;
125 Algorithms algorithms;
126 std::optional<PeerDiscoveryEnvironment> peer_discovery_environment;
127 std::vector<MinhtonScenarioSequenceStep> scenario_sequence;
128};
129} // namespace daisi::minhton_ns3
130#endif
Definition general_scenariofile.h:28
Definition minhton_scenariofile.h:60
minhton::AlgorithmTypesContainer convert() const
Convert this struct to a AlgorithmTypesContainer.
Definition minhton_scenariofile.h:70
Definition scenario_steps.h:125
Definition scenario_steps.h:109
Definition scenario_steps.h:161
Definition scenario_steps.h:45
Definition scenario_steps.h:29
Definition scenario_steps.h:75
Definition scenario_steps.h:59
Definition minhton_scenariofile.h:112
Definition minhton_scenariofile.h:120
Definition scenario_steps.h:137
Definition minhton_scenariofile.h:105
Definition scenario_steps.h:195
Definition peer_discovery_requests.h:103
Definition scenario_steps.h:101
Definition scenario_steps.h:89
Definition scenario_steps.h:187
Definition scenario_steps.h:179
Definition minhton_scenariofile.h:32
minhton::TimeoutLengthsContainer convert() const
Convert this struct to a TimeoutLengthsContainer.
Definition minhton_scenariofile.h:47
Definition scenario_steps.h:153
Definition algorithm_types_container.h:14
Definition timeout_lengths_container.h:14