Skip to content

Commit 1813264

Browse files
committed
Use the ACK module to send the challenge ACK
1 parent 1bd6270 commit 1813264

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

src/tcp/flow.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ module Log = (val Logs.src_log src : Logs.LOG)
2323
module Make(Ip: Tcpip.Ip.S)(Time:Mirage_time.S)(Clock:Mirage_clock.MCLOCK)(Random:Mirage_random.S) =
2424
struct
2525

26-
module RXS = Segment.Rx(Time)
27-
module TXS = Segment.Tx(Time)(Clock)
2826
module ACK = Ack.Immediate
27+
module RXS = Segment.Rx(Time)(ACK)
28+
module TXS = Segment.Tx(Time)(Clock)
2929
module UTX = User_buffer.Tx(Time)(Clock)
3030
module WIRE = Wire.Make(Ip)
3131
module STATE = State.Make(Time)
@@ -358,11 +358,11 @@ struct
358358
let txq, _tx_t =
359359
TXS.create ~xmit:(Tx.xmit_pcb t.ip id) ~wnd ~state ~rx_ack ~tx_ack ~tx_wnd_update
360360
in
361-
(* The user application transmit buffer *)
362-
let utx = UTX.create ~wnd ~txq ~max_size:16384l in
363-
let rxq = RXS.create ~rx_data ~send_ack ~wnd ~state ~tx_ack in
364361
(* Set up ACK module *)
365362
let ack = ACK.t ~send_ack ~last:(Sequence.succ rx_isn) in
363+
(* The user application transmit buffer *)
364+
let utx = UTX.create ~wnd ~txq ~max_size:16384l in
365+
let rxq = RXS.create ~rx_data ~ack ~wnd ~state ~tx_ack in
366366
(* Set up the keepalive state if requested *)
367367
let keepalive = match keepalive with
368368
| None -> None

src/tcp/segment.ml

+5-7
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ let rec reset_seq segs =
5555
It also looks for control messages and dispatches them to
5656
the Rtx queue to ack messages or close channels.
5757
*)
58-
module Rx(Time:Mirage_time.S) = struct
58+
module Rx(Time:Mirage_time.S)(ACK: Ack.M) = struct
5959
open Tcp_packet
6060
module StateTick = State.Make(Time)
6161

@@ -84,15 +84,15 @@ module Rx(Time:Mirage_time.S) = struct
8484
type t = {
8585
mutable segs: S.t;
8686
rx_data: (Cstruct.t list option * Sequence.t option) Lwt_mvar.t; (* User receive channel *)
87-
send_ack: Sequence.t Lwt_mvar.t;
87+
ack: ACK.t;
8888
tx_ack: (Sequence.t * int) Lwt_mvar.t; (* Acks of our transmitted segs *)
8989
wnd: Window.t;
9090
state: State.t;
9191
}
9292

93-
let create ~rx_data ~send_ack ~wnd ~state ~tx_ack =
93+
let create ~rx_data ~ack ~wnd ~state ~tx_ack =
9494
let segs = S.empty in
95-
{ segs; rx_data; send_ack; tx_ack; wnd; state }
95+
{ segs; rx_data; ack; tx_ack; wnd; state }
9696

9797
let pp fmt t =
9898
let pp_v fmt seg =
@@ -136,9 +136,7 @@ module Rx(Time:Mirage_time.S) = struct
136136

137137
let send_challenge_ack q =
138138
(* TODO: rfc5961 ACK Throttling *)
139-
if Lwt_mvar.is_empty q.send_ack
140-
then Lwt_mvar.put q.send_ack Sequence.zero
141-
else Lwt.return_unit
139+
ACK.pushack q.ack Sequence.zero
142140

143141
(* Given an input segment, the window information, and a receive
144142
queue, update the window, extract any ready segments into the

src/tcp/segment.mli

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
the Rtx queue to ack messages or close channels.
2525
*)
2626

27-
module Rx (T:Mirage_time.S) : sig
27+
module Rx (T:Mirage_time.S)(ACK:Ack.M) : sig
2828

2929
type segment = { header: Tcp_packet.t; payload: Cstruct.t }
3030
(** Individual received TCP segment *)
@@ -38,7 +38,7 @@ module Rx (T:Mirage_time.S) : sig
3838

3939
val create:
4040
rx_data:(Cstruct.t list option * Sequence.t option) Lwt_mvar.t ->
41-
send_ack:Sequence.t Lwt_mvar.t ->
41+
ack:ACK.t ->
4242
wnd:Window.t ->
4343
state:State.t ->
4444
tx_ack:(Sequence.t * int) Lwt_mvar.t ->

0 commit comments

Comments
 (0)