/* * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
// All methods of EmulatedNetworkOutgoingStatsBuilder have to be used on a // single thread. It may be created on another thread. class EmulatedNetworkOutgoingStatsBuilder { public: explicit EmulatedNetworkOutgoingStatsBuilder(
EmulatedNetworkStatsGatheringMode stats_gathering_mode);
// All methods of EmulatedNetworkIncomingStatsBuilder have to be used on a // single thread. It may be created on another thread. class EmulatedNetworkIncomingStatsBuilder { public: explicit EmulatedNetworkIncomingStatsBuilder(
EmulatedNetworkStatsGatheringMode stats_gathering_mode);
// All methods of EmulatedNetworkStatsBuilder have to be used on a single // thread. It may be created on another thread. class EmulatedNetworkStatsBuilder { public: explicit EmulatedNetworkStatsBuilder(
EmulatedNetworkStatsGatheringMode stats_gathering_mode); explicit EmulatedNetworkStatsBuilder(
rtc::IPAddress local_ip,
EmulatedNetworkStatsGatheringMode stats_gathering_mode);
// All methods of EmulatedNetworkNodeStatsBuilder have to be used on a // single thread. It may be created on another thread. class EmulatedNetworkNodeStatsBuilder { public: explicit EmulatedNetworkNodeStatsBuilder(
EmulatedNetworkStatsGatheringMode stats_gathering_mode);
void AddPacketTransportTime(TimeDelta time, size_t packet_size);
// Represents a component responsible for routing packets based on their IP // address. All possible routes have to be set explicitly before packet for // desired destination will be seen for the first time. If route is unknown // the packet will be silently dropped. class NetworkRouterNode : public EmulatedNetworkReceiverInterface { public: explicit NetworkRouterNode(absl::Nonnull<TaskQueueBase*> task_queue);
void OnPacketReceived(EmulatedIpPacket packet) override; void SetReceiver(const rtc::IPAddress& dest_ip,
EmulatedNetworkReceiverInterface* receiver); void RemoveReceiver(const rtc::IPAddress& dest_ip); // Sets a default receive that will be used for all incoming packets for which // there is no specific receiver binded to their destination port. void SetDefaultReceiver(EmulatedNetworkReceiverInterface* receiver); void RemoveDefaultReceiver(); void SetWatcher(std::function<void(const EmulatedIpPacket&)> watcher); void SetFilter(std::function<bool(const EmulatedIpPacket&)> filter);
// Represents node in the emulated network. Nodes can be connected with each // other to form different networks with different behavior. The behavior of // the node itself is determined by a concrete implementation of // NetworkBehaviorInterface that is provided on construction. class EmulatedNetworkNode : public EmulatedNetworkReceiverInterface { public: // Creates node based on `network_behavior`. The specified `packet_overhead` // is added to the size of each packet in the information provided to // `network_behavior`. // `task_queue` is used to process packets and to forward the packets when // they are ready.
EmulatedNetworkNode(
Clock* clock,
absl::Nonnull<TaskQueueBase*> task_queue,
std::unique_ptr<NetworkBehaviorInterface> network_behavior,
EmulatedNetworkStatsGatheringMode stats_gathering_mode, bool fake_dtls_handshake_sizes);
~EmulatedNetworkNode() override;
// Creates a route for the given receiver_ip over all the given nodes to the // given receiver. staticvoid CreateRoute(const rtc::IPAddress& receiver_ip,
std::vector<EmulatedNetworkNode*> nodes,
EmulatedNetworkReceiverInterface* receiver); staticvoid ClearRoute(const rtc::IPAddress& receiver_ip,
std::vector<EmulatedNetworkNode*> nodes);
// Represents single network interface on the device. // It will be used as sender from socket side to send data to the network and // will act as packet receiver from emulated network side to receive packets // from other EmulatedNetworkNodes. class EmulatedEndpointImpl : public EmulatedEndpoint { public: struct Options {
Options(uint64_t id, const rtc::IPAddress& ip, const EmulatedEndpointConfig& config,
EmulatedNetworkStatsGatheringMode stats_gathering_mode);
// TODO(titovartem) check if we can remove id.
uint64_t id; // Endpoint local IP address.
rtc::IPAddress ip;
EmulatedNetworkStatsGatheringMode stats_gathering_mode;
rtc::AdapterType type; // Allow endpoint to send packets specifying source IP address different to // the current endpoint IP address. If false endpoint will crash if attempt // to send such packet will be done. bool allow_send_packet_with_different_source_ip; // Allow endpoint to receive packet with destination IP address different to // the current endpoint IP address. If false endpoint will crash if such // packet will arrive. bool allow_receive_packets_with_different_dest_ip; // Name of the endpoint used for logging purposes.
std::string log_name;
};
// This object is immutable and so thread safe. class EndpointsContainer { public:
EndpointsContainer(const std::vector<EmulatedEndpointImpl*>& endpoints,
EmulatedNetworkStatsGatheringMode stats_gathering_mode);
EmulatedEndpointImpl* LookupByLocalAddress( const rtc::IPAddress& local_ip) const; bool HasEndpoint(EmulatedEndpointImpl* endpoint) const; // Returns list of networks for enabled endpoints. Caller takes ownership of // returned rtc::Network objects.
std::vector<std::unique_ptr<rtc::Network>> GetEnabledNetworks() const;
std::vector<EmulatedEndpoint*> GetEndpoints() const;
EmulatedNetworkStats GetStats() const;
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.1Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.