// 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(
Clock& clock,
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(
Clock& clock,
EmulatedNetworkStatsGatheringMode stats_gathering_mode); explicit EmulatedNetworkStatsBuilder(
Clock& clock,
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(
Clock& clock,
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(TaskQueueBase* absl_nonnull task_queue);
void OnPacketReceived(EmulatedIpPacket packet) override; void SetReceiver(const IPAddress& dest_ip,
EmulatedNetworkReceiverInterface* receiver); void RemoveReceiver(const 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,
TaskQueueBase* absl_nonnull 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 IPAddress& receiver_ip,
std::vector<EmulatedNetworkNode*> nodes,
EmulatedNetworkReceiverInterface* receiver); staticvoid ClearRoute(const 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 IPAddress& ip, const EmulatedEndpointConfig& config,
EmulatedNetworkStatsGatheringMode stats_gathering_mode);
// TODO(titovartem) check if we can remove id.
uint64_t id; // Endpoint local IP address.
IPAddress ip;
EmulatedNetworkStatsGatheringMode stats_gathering_mode;
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(Clock* clock, const std::vector<EmulatedEndpointImpl*>& endpoints,
EmulatedNetworkStatsGatheringMode stats_gathering_mode);
EmulatedEndpointImpl* LookupByLocalAddress(const IPAddress& local_ip) const; bool HasEndpoint(EmulatedEndpointImpl* endpoint) const; // Returns list of networks for enabled endpoints. Caller takes ownership of // returned webrtc::Network objects.
std::vector<std::unique_ptr<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.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.