-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a scenario that checks what packets get sent (if any) after clos…
…ing the connection, fixes #15
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package scenarii | ||
|
||
import ( | ||
qt "github.com/QUIC-Tracker/quic-tracker" | ||
"time" | ||
) | ||
|
||
const ( | ||
CCS_TLSHandshakeFailed = 1 | ||
CCS_NoPacketsReceived = 2 | ||
CSS_APacketWasReceived = 3 | ||
) | ||
|
||
type ClosedConnectionScenario struct { | ||
AbstractScenario | ||
} | ||
|
||
func NewClosedConnectionScenario() *ClosedConnectionScenario { | ||
return &ClosedConnectionScenario{AbstractScenario{name: "closed_connection", version: 1}} | ||
} | ||
func (s *ClosedConnectionScenario) Run(conn *qt.Connection, trace *qt.Trace, preferredPath string, debug bool) { | ||
connAgents := s.CompleteHandshake(conn, trace, CCS_TLSHandshakeFailed) | ||
if connAgents == nil { | ||
return | ||
} | ||
<-time.NewTimer(time.Duration(2 * conn.SmoothedRTT) * time.Microsecond).C | ||
conn.CloseConnection(false, 0, "") | ||
<-time.NewTimer(time.Duration(8 * conn.SmoothedRTT) * time.Microsecond).C | ||
|
||
incomingPackets := conn.IncomingPackets.RegisterNewChan(1000) | ||
|
||
for i := 0; i < 3; i++ { | ||
ping := qt.PingFrame(0) | ||
conn.FrameQueue.Submit(qt.QueuedFrame{&ping, qt.EncryptionLevel1RTT}) | ||
<-time.NewTimer(time.Duration(3 * conn.SmoothedRTT) * time.Microsecond).C | ||
} | ||
|
||
trace.ErrorCode = CCS_NoPacketsReceived | ||
for { | ||
select { | ||
case <-incomingPackets: | ||
trace.ErrorCode = CSS_APacketWasReceived | ||
case <-conn.ConnectionClosed: | ||
return | ||
case <-s.Timeout(): | ||
return | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters