Commit e5640be4 authored by Brickner_cp's avatar Brickner_cp

--no commit message

--no commit message
parent 7346c0b6
...@@ -32,5 +32,5 @@ using System.Runtime.InteropServices; ...@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("0.1.0.*")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("0.1.0.*")]
...@@ -10,11 +10,31 @@ namespace PcapDotNet { namespace Core ...@@ -10,11 +10,31 @@ namespace PcapDotNet { namespace Core
public ref class LivePacketCommunicator : PacketCommunicator public ref class LivePacketCommunicator : PacketCommunicator
{ {
public: public:
/// <summary>
/// Statistics on current capture.
/// The values represent packet statistics from the start of the run to the time of the call.
/// </summary>
/// <exception cref="System::InvalidOperationException">Thrown if there is an error or the underlying packet capture doesn't support packet statistics.</exception>
virtual property PacketTotalStatistics^ TotalStatistics virtual property PacketTotalStatistics^ TotalStatistics
{ {
PacketTotalStatistics^ get() override; PacketTotalStatistics^ get() override;
} }
/// <summary>
/// Send a buffer of packets to the network.
/// This function transmits the content of a queue to the wire.
/// <seealso cref="SendPacket"/>
/// <seealso cref="PacketSendBuffer"/>
/// </summary>
/// <param name="sendBuffer">Contains the packets to send.</param>
/// <param name="isSync">Determines if the send operation must be synchronized: if it is true, the packets are sent respecting the timestamps, otherwise they are sent as fast as possible.</param>
/// <exception cref="System::InvalidOperationException">An error occurred during the send. The error can be caused by a driver/adapter problem or by an inconsistent/bogus send buffer..</exception>
/// <remarks>
/// <list type="bullet">
/// <item>Using this function is more efficient than issuing a series of SendPacket(), because the packets are buffered in the kernel driver, so the number of context switches is reduced. Therefore, expect a better throughput when using Transmit().</item>
/// <item>When isSync is true, the packets are synchronized in the kernel with a high precision timestamp. This requires a non-negligible amount of CPU, but allows normally to send the packets with a precision of some microseconds (depending on the accuracy of the performance counter of the machine). Such a precision cannot be reached sending the packets with SendPacket().</item>
/// </list>
/// </remarks>
virtual void Transmit(PacketSendBuffer^ sendBuffer, bool isSync) override; virtual void Transmit(PacketSendBuffer^ sendBuffer, bool isSync) override;
internal: internal:
......
...@@ -8,12 +8,12 @@ PacketTotalStatistics^ OfflinePacketCommunicator::TotalStatistics::get() ...@@ -8,12 +8,12 @@ PacketTotalStatistics^ OfflinePacketCommunicator::TotalStatistics::get()
throw gcnew InvalidOperationException("Can't get TotalStatistics for offline devices"); throw gcnew InvalidOperationException("Can't get TotalStatistics for offline devices");
} }
OfflinePacketCommunicator::OfflinePacketCommunicator(const char* source, int snapshotLength, PacketDeviceOpenAttributes attributes, int readTimeout, pcap_rmtauth* auth) void OfflinePacketCommunicator::Transmit(PacketSendBuffer^ sendBuffer, bool isSync)
: PacketCommunicator(source, snapshotLength, attributes, readTimeout, auth, nullptr)
{ {
throw gcnew InvalidOperationException("Can't transmit queue to an offline device");
} }
void OfflinePacketCommunicator::Transmit(PacketSendBuffer^ sendBuffer, bool isSync) OfflinePacketCommunicator::OfflinePacketCommunicator(const char* source, int snapshotLength, PacketDeviceOpenAttributes attributes, int readTimeout, pcap_rmtauth* auth)
: PacketCommunicator(source, snapshotLength, attributes, readTimeout, auth, nullptr)
{ {
throw gcnew InvalidOperationException("Can't transmit queue to an offline device");
} }
...@@ -8,11 +8,19 @@ namespace PcapDotNet { namespace Core ...@@ -8,11 +8,19 @@ namespace PcapDotNet { namespace Core
public ref class OfflinePacketCommunicator : PacketCommunicator public ref class OfflinePacketCommunicator : PacketCommunicator
{ {
public: public:
/// <summary>
/// TotalStatistics is not supported on offline captures.
/// </summary>
/// <exception cref="System::InvalidOperationException">Thrown always.</exception>
virtual property PacketTotalStatistics^ TotalStatistics virtual property PacketTotalStatistics^ TotalStatistics
{ {
PacketTotalStatistics^ get() override; PacketTotalStatistics^ get() override;
} }
/// <summary>
/// Transmit is not supported on offline captures.
/// </summary>
/// <exception cref="System::InvalidOperationException">Thrown always.</exception>
virtual void Transmit(PacketSendBuffer^ sendBuffer, bool isSync) override; virtual void Transmit(PacketSendBuffer^ sendBuffer, bool isSync) override;
internal: internal:
......
...@@ -76,7 +76,7 @@ namespace PcapDotNet { namespace Core ...@@ -76,7 +76,7 @@ namespace PcapDotNet { namespace Core
} }
/// <summary> /// <summary>
/// Return statistics on current capture. /// Statistics on current capture.
/// The values represent packet statistics from the start of the run to the time of the call. /// The values represent packet statistics from the start of the run to the time of the call.
/// Supported only on live captures, not on offline. No statistics are stored in offline, so no statistics are available when reading from an offline device. /// Supported only on live captures, not on offline. No statistics are stored in offline, so no statistics are available when reading from an offline device.
/// </summary> /// </summary>
...@@ -297,7 +297,7 @@ namespace PcapDotNet { namespace Core ...@@ -297,7 +297,7 @@ namespace PcapDotNet { namespace Core
/// </summary> /// </summary>
/// <param name="sendBuffer">Contains the packets to send.</param> /// <param name="sendBuffer">Contains the packets to send.</param>
/// <param name="isSync">Determines if the send operation must be synchronized: if it is true, the packets are sent respecting the timestamps, otherwise they are sent as fast as possible.</param> /// <param name="isSync">Determines if the send operation must be synchronized: if it is true, the packets are sent respecting the timestamps, otherwise they are sent as fast as possible.</param>
/// <exception cref="System::InvalidOperationException">An error occurred during the send. The error can be caused by a driver/adapter problem or by an inconsistent/bogus send buffer..</exception> /// <exception cref="System::InvalidOperationException">Trying to transmit to an offline device or an error occurred during the send. The error can be caused by a driver/adapter problem or by an inconsistent/bogus send buffer.</exception>
/// <remarks> /// <remarks>
/// <list type="bullet"> /// <list type="bullet">
/// <item>Using this function is more efficient than issuing a series of SendPacket(), because the packets are buffered in the kernel driver, so the number of context switches is reduced. Therefore, expect a better throughput when using Transmit().</item> /// <item>Using this function is more efficient than issuing a series of SendPacket(), because the packets are buffered in the kernel driver, so the number of context switches is reduced. Therefore, expect a better throughput when using Transmit().</item>
......
...@@ -2,11 +2,21 @@ ...@@ -2,11 +2,21 @@
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
/// <summary>
/// Working modes for packet communicator.
/// </summary>
public enum class PacketCommunicatorMode : int public enum class PacketCommunicatorMode : int
{ {
Capture = 0x0, // Capture working mode. /// <summary>Capture working mode.</summary>
Statistics = 0x1, // Statistical working mode. Capture = 0x0,
KernelMonitor = 0x2, // Kernel monitoring mode.
KernelDump = 0x10 // Kernel dump working mode. /// <summary>Statistical working mode.</summary>
Statistics = 0x1,
/// <summary>Kernel monitoring mode. </summary>
KernelMonitor = 0x2,
/// <summary>Kernel dump working mode.</summary>
KernelDump = 0x10
}; };
}} }}
\ No newline at end of file
...@@ -2,12 +2,24 @@ ...@@ -2,12 +2,24 @@
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
/// <summary>
/// The different return values when receiving from a packet communicator.
/// </summary>
public enum class PacketCommunicatorReceiveResult : int public enum class PacketCommunicatorReceiveResult : int
{ {
Ok, // if the packet has been read without problems /// <summary>The packets/statistics have been read without problems.</summary>
Timeout, // if the timeout set with Open() has elapsed. Ok,
Eof, // if EOF was reached reading from an offline capture
BreakLoop, // /// <summary>The timeout set with Open() has elapsed when trying to read packets.</summary>
Timeout,
/// <summary>EOF was reached reading from an offline capture.</summary>
Eof,
/// <summary>The loop has been broken by a call to Break() before all the requested packets could be read.</summary>
BreakLoop,
/// <summary>This return value should never be returned</summary>
None None
}; };
}} }}
\ No newline at end of file
...@@ -29,7 +29,7 @@ using namespace System::Security::Permissions; ...@@ -29,7 +29,7 @@ using namespace System::Security::Permissions;
// You can specify all the value or you can default the Revision and Build Numbers // You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly:AssemblyVersionAttribute("1.0.*")]; [assembly:AssemblyVersionAttribute("0.1.0.*")];
[assembly:ComVisible(false)]; [assembly:ComVisible(false)];
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
/// <summary>
/// This is the base sampling method class.
/// Every sampling method is defined by a method and an optional value, both for internal usage.
/// </summary>
public ref class SamplingMethod abstract public ref class SamplingMethod abstract
{ {
internal: internal:
......
...@@ -4,10 +4,25 @@ ...@@ -4,10 +4,25 @@
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
/// <summary>
/// This sampling method defines that we have to return 1 packet every given time-interval.
/// In other words, if the interval is set to 10 milliseconds, the first packet is returned to the caller; the next returned one will be the first packet that arrives when 10ms have elapsed.
/// </summary>
public ref class SamplingMethodFirstAfterInterval : SamplingMethod public ref class SamplingMethodFirstAfterInterval : SamplingMethod
{ {
public: public:
/// <summary>
/// Constructs by giving an interval in milliseconds.
/// </summary>
/// <param name="intervalInMs">The number of milliseconds to wait between packets sampled.</param>
/// <exception cref="System::ArgumentOutOfRangeException">The given number of milliseconds is negative.</exception>
SamplingMethodFirstAfterInterval(int intervalInMs); SamplingMethodFirstAfterInterval(int intervalInMs);
/// <summary>
/// Constructs by giving an interval as TimeSpan.
/// </summary>
/// <param name="interval">The time to wait between packets sampled.</param>
/// <exception cref="System::ArgumentOutOfRangeException">The interval is negative or larger than 2^31 milliseconds.</exception>
SamplingMethodFirstAfterInterval(System::TimeSpan interval); SamplingMethodFirstAfterInterval(System::TimeSpan interval);
internal: internal:
...@@ -16,6 +31,10 @@ namespace PcapDotNet { namespace Core ...@@ -16,6 +31,10 @@ namespace PcapDotNet { namespace Core
int get() override; int get() override;
} }
/// <summary>
/// Indicates the 'waiting time' in milliseconds before one packet got accepted.
/// In other words, if 'value = 10', the first packet is returned to the caller; the next returned one will be the first packet that arrives when 10ms have elapsed.
/// </summary>
virtual property int Value virtual property int Value
{ {
int get() override; int get() override;
......
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
/// <summary>
/// No sampling has to be done on the current capture.
/// In this case, no sampling algorithms are applied to the current capture.
/// </summary>
public ref class SamplingMethodNone : SamplingMethod public ref class SamplingMethodNone : SamplingMethod
{ {
internal: internal:
......
...@@ -4,9 +4,18 @@ ...@@ -4,9 +4,18 @@
namespace PcapDotNet { namespace Core namespace PcapDotNet { namespace Core
{ {
/// <summary>
/// Defines that only 1 out of count packets must be returned to the user.
/// In other words, if the count is set to 10, the first packet is returned to the caller, while the following 9 are discarded.
/// </summary>
public ref class SamplingMethodOneEveryCount : SamplingMethod public ref class SamplingMethodOneEveryCount : SamplingMethod
{ {
public: public:
/// <summary>
/// Constructs by giving a count.
/// </summary>
/// <param name="count">1 packet out of count packets will be sampled (for each sampled packet, count-1 will be discarded).</param>
/// <exception cref="System::ArgumentOutOfRangeException">The given count is non-positive.</exception>
SamplingMethodOneEveryCount(int count); SamplingMethodOneEveryCount(int count);
internal: internal:
...@@ -15,6 +24,10 @@ namespace PcapDotNet { namespace Core ...@@ -15,6 +24,10 @@ namespace PcapDotNet { namespace Core
int get() override; int get() override;
} }
/// <summary>
/// Indicates the number of packets (minus 1) that must be discarded before one packet got accepted.
/// In other words, if 'value = 10', the first packet is returned to the caller, while the following 9 are discarded.
/// </summary>
virtual property int Value virtual property int Value
{ {
int get() override; int get() override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment