Introduce EmulatedRoute
Introduce a handle for route created with network emulation layer, that can be used to remove it in future properly. Bug: webrtc:10138 Change-Id: I9fb847caeee24333bafb328727711af005b09224 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/127283 Reviewed-by: Sebastian Jansson <srte@webrtc.org> Commit-Queue: Artem Titov <titovartem@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27074}
This commit is contained in:
parent
a268b69037
commit
fc6ab00a39
@ -174,6 +174,19 @@ class EmulatedEndpoint : public EmulatedNetworkReceiverInterface {
|
||||
absl::optional<uint64_t> connected_endpoint_id_;
|
||||
};
|
||||
|
||||
class EmulatedRoute {
|
||||
public:
|
||||
EmulatedRoute(EmulatedEndpoint* from,
|
||||
std::vector<EmulatedNetworkNode*> via_nodes,
|
||||
EmulatedEndpoint* to)
|
||||
: from(from), via_nodes(std::move(via_nodes)), to(to), active(true) {}
|
||||
|
||||
EmulatedEndpoint* from;
|
||||
std::vector<EmulatedNetworkNode*> via_nodes;
|
||||
EmulatedEndpoint* to;
|
||||
bool active;
|
||||
};
|
||||
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
|
||||
@ -96,7 +96,7 @@ EmulatedEndpoint* NetworkEmulationManager::CreateEndpoint(
|
||||
return out;
|
||||
}
|
||||
|
||||
void NetworkEmulationManager::CreateRoute(
|
||||
EmulatedRoute* NetworkEmulationManager::CreateRoute(
|
||||
EmulatedEndpoint* from,
|
||||
std::vector<EmulatedNetworkNode*> via_nodes,
|
||||
EmulatedEndpoint* to) {
|
||||
@ -112,21 +112,28 @@ void NetworkEmulationManager::CreateRoute(
|
||||
}
|
||||
cur_node->SetReceiver(to->GetId(), to);
|
||||
from->SetConnectedEndpointId(to->GetId());
|
||||
|
||||
std::unique_ptr<EmulatedRoute> route =
|
||||
absl::make_unique<EmulatedRoute>(from, std::move(via_nodes), to);
|
||||
EmulatedRoute* out = route.get();
|
||||
routes_.push_back(std::move(route));
|
||||
return out;
|
||||
}
|
||||
|
||||
void NetworkEmulationManager::ClearRoute(
|
||||
EmulatedEndpoint* from,
|
||||
std::vector<EmulatedNetworkNode*> via_nodes,
|
||||
EmulatedEndpoint* to) {
|
||||
void NetworkEmulationManager::ClearRoute(EmulatedRoute* route) {
|
||||
RTC_CHECK(route->active) << "Route already cleared";
|
||||
|
||||
// Remove receiver from intermediate nodes.
|
||||
for (auto* node : via_nodes) {
|
||||
node->RemoveReceiver(to->GetId());
|
||||
for (auto* node : route->via_nodes) {
|
||||
node->RemoveReceiver(route->to->GetId());
|
||||
}
|
||||
// Detach endpoint from current send node.
|
||||
if (from->GetSendNode()) {
|
||||
from->GetSendNode()->RemoveReceiver(to->GetId());
|
||||
from->SetSendNode(nullptr);
|
||||
if (route->from->GetSendNode()) {
|
||||
route->from->GetSendNode()->RemoveReceiver(route->to->GetId());
|
||||
route->from->SetSendNode(nullptr);
|
||||
}
|
||||
|
||||
route->active = false;
|
||||
}
|
||||
|
||||
TrafficRoute* NetworkEmulationManager::CreateTrafficRoute(
|
||||
|
||||
@ -57,12 +57,10 @@ class NetworkEmulationManager {
|
||||
|
||||
EmulatedEndpoint* CreateEndpoint(EmulatedEndpointConfig config);
|
||||
|
||||
void CreateRoute(EmulatedEndpoint* from,
|
||||
std::vector<EmulatedNetworkNode*> via_nodes,
|
||||
EmulatedEndpoint* to);
|
||||
void ClearRoute(EmulatedEndpoint* from,
|
||||
std::vector<EmulatedNetworkNode*> via_nodes,
|
||||
EmulatedEndpoint* to);
|
||||
EmulatedRoute* CreateRoute(EmulatedEndpoint* from,
|
||||
std::vector<EmulatedNetworkNode*> via_nodes,
|
||||
EmulatedEndpoint* to);
|
||||
void ClearRoute(EmulatedRoute* route);
|
||||
|
||||
TrafficRoute* CreateTrafficRoute(std::vector<EmulatedNetworkNode*> via_nodes);
|
||||
RandomWalkCrossTraffic* CreateRandomWalkCrossTraffic(
|
||||
@ -92,6 +90,7 @@ class NetworkEmulationManager {
|
||||
// All objects can be added to the manager only when it is idle.
|
||||
std::vector<std::unique_ptr<EmulatedEndpoint>> endpoints_;
|
||||
std::vector<std::unique_ptr<EmulatedNetworkNode>> network_nodes_;
|
||||
std::vector<std::unique_ptr<EmulatedRoute>> routes_;
|
||||
std::vector<std::unique_ptr<TrafficRoute>> traffic_routes_;
|
||||
std::vector<std::unique_ptr<RandomWalkCrossTraffic>> random_cross_traffics_;
|
||||
std::vector<std::unique_ptr<PulsedPeaksCrossTraffic>> pulsed_cross_traffics_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user