Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pcap-Net
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Pcap-Net
Commits
889a9ec6
Commit
889a9ec6
authored
Mar 11, 2010
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved SetSamplingMethodFirstAfterIntervalTest test
parent
1d6bf681
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
LivePacketDeviceTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/LivePacketDeviceTests.cs
+6
-6
RandomPacketsExtensions.cs
...c/PcapDotNet.Packets.TestUtils/RandomPacketsExtensions.cs
+5
-0
No files found.
PcapDotNet/src/PcapDotNet.Core.Test/LivePacketDeviceTests.cs
View file @
889a9ec6
...
...
@@ -528,21 +528,21 @@ namespace PcapDotNet.Core.Test
[
TestMethod
]
public
void
SetSamplingMethodFirstAfterIntervalTest
()
{
Thread
.
Sleep
(
TimeSpan
.
FromSeconds
(
2
)
);
Random
random
=
new
Random
(
);
const
string
SourceMac
=
"11:22:33:44:55:66"
;
const
string
DestinationMac
=
"77:88:99:AA:BB:CC"
;
MacAddress
sourceMac
=
random
.
NextMacAddress
()
;
MacAddress
destinationMac
=
random
.
NextMacAddress
()
;
using
(
PacketCommunicator
communicator
=
OpenLiveDevice
())
{
communicator
.
SetFilter
(
"ether src "
+
SourceMac
+
" and ether dst "
+
D
estinationMac
);
communicator
.
SetFilter
(
"ether src "
+
sourceMac
+
" and ether dst "
+
d
estinationMac
);
communicator
.
SetSamplingMethod
(
new
SamplingMethodFirstAfterInterval
(
TimeSpan
.
FromSeconds
(
1
)));
Packet
expectedPacket
=
_random
.
NextEthernetPacket
(
60
,
SourceMac
,
D
estinationMac
);
Packet
expectedPacket
=
_random
.
NextEthernetPacket
(
60
,
sourceMac
,
d
estinationMac
);
communicator
.
SendPacket
(
expectedPacket
);
Thread
.
Sleep
(
TimeSpan
.
FromSeconds
(
0.75
));
for
(
int
i
=
0
;
i
!=
10
;
++
i
)
{
expectedPacket
=
_random
.
NextEthernetPacket
(
60
*
(
i
+
2
),
SourceMac
,
D
estinationMac
);
expectedPacket
=
_random
.
NextEthernetPacket
(
60
*
(
i
+
2
),
sourceMac
,
d
estinationMac
);
communicator
.
SendPacket
(
expectedPacket
);
Thread
.
Sleep
(
TimeSpan
.
FromSeconds
(
0.5
));
}
...
...
PcapDotNet/src/PcapDotNet.Packets.TestUtils/RandomPacketsExtensions.cs
View file @
889a9ec6
...
...
@@ -91,6 +91,11 @@ namespace PcapDotNet.Packets.TestUtils
return
random
.
NextEthernetPacket
(
packetSize
,
timestamp
,
new
MacAddress
(
ethernetSource
),
new
MacAddress
(
ethernetDestination
));
}
public
static
Packet
NextEthernetPacket
(
this
Random
random
,
int
packetSize
,
MacAddress
ethernetSource
,
MacAddress
ethernetDestination
)
{
return
random
.
NextEthernetPacket
(
packetSize
,
DateTime
.
Now
,
ethernetSource
,
ethernetDestination
);
}
public
static
Packet
NextEthernetPacket
(
this
Random
random
,
int
packetSize
,
string
ethernetSource
,
string
ethernetDestination
)
{
return
random
.
NextEthernetPacket
(
packetSize
,
DateTime
.
Now
,
ethernetSource
,
ethernetDestination
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment