Reduce VPN control packet latency
This commit is contained in:
@@ -241,6 +241,51 @@ func TestFabricPacketInboxDropsEmptyPackets(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFabricPacketInboxPrioritizesGatewayTCPControlPackets(t *testing.T) {
|
||||
inbox := NewFabricPacketInbox(4)
|
||||
normal := testIPv4TCPPacket([4]byte{185, 16, 148, 89}, [4]byte{10, 77, 0, 2}, 443, 56000)
|
||||
priority := testIPv4TCPPacket([4]byte{192, 168, 200, 95}, [4]byte{10, 77, 0, 2}, 3389, 57032)
|
||||
priority[33] = 0x12
|
||||
|
||||
if err := inbox.DeliverLocalPacketBatch("vpn-1", FabricDirectionGatewayToClient, [][]byte{normal}); err != nil {
|
||||
t.Fatalf("deliver normal gateway packet: %v", err)
|
||||
}
|
||||
if err := inbox.DeliverLocalPacketBatch("vpn-1", FabricDirectionGatewayToClient, [][]byte{priority}); err != nil {
|
||||
t.Fatalf("deliver priority gateway packet: %v", err)
|
||||
}
|
||||
|
||||
packets, err := inbox.Receive(context.Background(), "vpn-1", FabricDirectionGatewayToClient, time.Second)
|
||||
if err != nil {
|
||||
t.Fatalf("receive gateway packet: %v", err)
|
||||
}
|
||||
if len(packets) != 1 || string(packets[0]) != string(priority) {
|
||||
t.Fatalf("first packets = %#v, want priority tcp control packet", packets)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFabricPacketInboxWaitsBrieflyForGatewayTCPControlPackets(t *testing.T) {
|
||||
inbox := NewFabricPacketInbox(4)
|
||||
normal := testIPv4TCPPacket([4]byte{185, 16, 148, 89}, [4]byte{10, 77, 0, 2}, 443, 56000)
|
||||
priority := testIPv4TCPPacket([4]byte{192, 168, 200, 95}, [4]byte{10, 77, 0, 2}, 3389, 57032)
|
||||
priority[33] = 0x12
|
||||
|
||||
if err := inbox.DeliverLocalPacketBatch("vpn-1", FabricDirectionGatewayToClient, [][]byte{normal}); err != nil {
|
||||
t.Fatalf("deliver normal gateway packet: %v", err)
|
||||
}
|
||||
go func() {
|
||||
time.Sleep(time.Millisecond)
|
||||
_ = inbox.DeliverLocalPacketBatch("vpn-1", FabricDirectionGatewayToClient, [][]byte{priority})
|
||||
}()
|
||||
|
||||
packets, err := inbox.Receive(context.Background(), "vpn-1", FabricDirectionGatewayToClient, time.Second)
|
||||
if err != nil {
|
||||
t.Fatalf("receive gateway packet: %v", err)
|
||||
}
|
||||
if len(packets) != 1 || string(packets[0]) != string(priority) {
|
||||
t.Fatalf("first packets = %#v, want delayed priority tcp control packet", packets)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocalPacketTransportUsesFabricInboxDirections(t *testing.T) {
|
||||
inbox := NewFabricPacketInbox(4)
|
||||
transport := &LocalPacketTransport{Inbox: inbox, VPNConnectionID: "vpn-1"}
|
||||
|
||||
Reference in New Issue
Block a user