Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Traceroute.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Frameworks_NetworkMonitor_Traceroute_h_
5#define _Stroika_Frameworks_NetworkMonitor_Traceroute_h_ 1
6
7#include "Stroika/Frameworks/StroikaPreComp.h"
8
9#include "Stroika/Foundation/Containers/Sequence.h"
11#include "Stroika/Foundation/IO/Network/InternetProtocol/ICMP.h"
12#include "Stroika/Foundation/IO/Network/InternetProtocol/IP.h"
15
16/**
17 *
18 * \note Code-Status: <a href="Code-Status.md#Beta">Beta</a>
19 *
20 */
21
23
24 using namespace Stroika::Foundation;
25
29 using Time::Duration;
30
31 /**
32 */
33 struct Options {
34 /**
35 */
36 static constexpr unsigned int kDefaultMaxHops = 64;
37
38 /**
39 */
40 optional<unsigned int> fMaxHops;
41
42 /**
43 */
44 static const inline Duration kDefaultTimeout{1.0s};
45
46 /**
47 * time after a single ping is sent before we treat the ping as having timed out
48 * (so not total time if multiple samples taken).
49 */
50 optional<Duration> fTimeout;
51
52 /*
53 * No standard for this, but just what this library does.
54 */
55 static constexpr size_t kDefaultPayloadSize = 32;
56
57 /**
58 * The range of supported payload (not including ICMP and IP packet headers)
59 *
60 * @see http://stackoverflow.com/questions/9449837/maximum-legal-size-of-icmp-echo-packet
61 *
62 * This does NOT include the IP header, nor the ICMP Header
63 */
64 static constexpr Traversal::Range<size_t> kAllowedICMPPayloadSizeRange{
65 0,
66 numeric_limits<uint16_t>::max () -
67 (sizeof (IO::Network::InternetProtocol::ICMP::V4::PacketHeader) + sizeof (IO::Network::InternetProtocol::IP::V4::PacketHeader)),
68 Traversal::Openness::eClosed, Traversal::Openness::eClosed};
69
70 /**
71 * \not including ICMP nor IP header overhead.
72 */
73 optional<size_t> fPacketPayloadSize;
74
75 /**
76 */
77 struct SampleInfo {
78 Duration fInterval;
79 unsigned int fSampleCount{};
80
81 /**
82 * @see Characters::ToString ();
83 */
84 nonvirtual Characters::String ToString () const;
85 };
86 /**
87 * Default to ONE sample, so we get immediate exception results.
88 */
89 optional<SampleInfo> fSampleInfo;
90
91 /**
92 * @see Characters::ToString ();
93 */
94 nonvirtual Characters::String ToString () const;
95 };
96
97 /**
98 */
99 struct Hop {
100 Duration fTime;
101 InternetAddress fAddress;
102
103 /**
104 * @see Characters::ToString ();
105 */
106 nonvirtual String ToString () const;
107 };
108
109 /**
110 */
111 Sequence<Hop> Run (const InternetAddress& addr, const Options& options = {});
112 void Run (const InternetAddress& addr, function<void (Hop)> perHopCallback, const Options& options = {});
113
114}
115
116/*
117 ********************************************************************************
118 ***************************** Implementation Details ***************************
119 ********************************************************************************
120 */
121#include "Traceroute.inl"
122
123#endif /*_Stroika_Frameworks_NetworkMonitor_Traceroute_h_*/
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
A generalization of a vector: a container whose elements are keyed by the natural numbers.
Definition Sequence.h:187
Duration is a chrono::duration<double> (=.
Definition Duration.h:96