Commit Graph

5 Commits

Author SHA1 Message Date
Zeling Feng 2a888a106d Give TCP flags a dedicated type
- Implement Stringer for it so that we can improve error messages.
- Use TCPFlags through the code base. There used to be a mixed usage of byte,
  uint8 and int as TCP flags.

PiperOrigin-RevId: 361940150
2021-03-09 18:00:03 -08:00
Zeling Feng d4951e05a0 [1/3] Support isolated containers for parallel packetimpact tests
Summary of the approach: the test runner will set up a few DUTs according to
a flag and pass all the test networks to the testbench. The testbench will only
reside in a single container. The testbench will put all the test networks into
a buffered channel which served as a semaphore and now the user can freely use
t.Parallel() in (sub)tests and the true parallelism will be determined by how
many DUTs are configured. Creating DUTs on demand is not supported yet, the
test author should determine the number of DUTs to be used statically.

Specifically in this change:
- Don't export any global variables about the test network in testbench.
- Sniffer only binds on the local interface because it will be possible to have
  multiple interfaces to multiple DUTs in a single testbench container.
- Migrate existing tests to stop using global variables.

PiperOrigin-RevId: 343965962
2020-11-23 18:13:07 -08:00
Jay Zhuang cf7141fb43 Ask for *testing.T instead of storing it
Storing *testing.T on test helper structs is problematic when
subtests are used, because it is possible for nested tests to call
Fatal on parent test, which incorrect terminates the parent test.

For example

  func TestOuter(t *testing.T) {
    dut := NewDUT(t)

    t.Run("first test", func(t *testing.T) {
      dut.FallibleCall()
    })

    t.Run("second test", func(t *testing.T) {
      dut.FallibleCall()
    }
  }

In the example above, assuming `FallibleCall` calls `t.Fatal` on the
`t` it holds, if `dut.FallibleCall` fails in "first test", it will
call `Fatal` on the parent `t`, quitting `TestOuter`. This is not a
behavior we want.

PiperOrigin-RevId: 323350241
2020-07-27 06:39:06 -07:00
Mithun Iyer f766366091 Handle TCP segment split cases as per MSS.
- Always split segments larger than MSS.
  Currently, we base the segment split decision as a function of the
  send congestion window and MSS, which could be greater than the MSS
  advertised by remote.
- While splitting segments, ensure the PSH flag is reset when there
  are segments that are queued to be sent.
- With TCP_CORK, hold up segments up until MSS. Fix a bug in computing
  available send space before attempting to coalesce segments.

Fixes #2832

PiperOrigin-RevId: 314802928
2020-06-05 11:28:24 -07:00
Zeling Feng 5f3eeb4728 Test that we have PAWS mechanism
If there is a Timestamps option in the arriving segment and SEG.TSval
< TS.Recent and if TS.Recent is valid, then treat the arriving segment
as not acceptable: Send an acknowledgement in reply as specified in
RFC-793 page 69 and drop the segment.

https://tools.ietf.org/html/rfc1323#page-19

PiperOrigin-RevId: 312590678
2020-05-20 17:53:35 -07:00