2022-05-06 16:49:46 +00:00
|
|
|
/* Copyright (c) 2017 - 2022 LiteSpeed Technologies Inc. See LICENSE. */
|
2017-09-22 21:00:03 +00:00
|
|
|
/*
|
|
|
|
* lsquic_conn_public.h -- Connection's "public interface"
|
|
|
|
*
|
|
|
|
* This structure is used to bundle things in connection that stream
|
|
|
|
* needs access to into a single object. This way, the space per
|
|
|
|
* stream object is one pointer instead of four or five.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LSQUIC_CONN_PUBLIC_H
|
|
|
|
#define LSQUIC_CONN_PUBLIC_H 1
|
|
|
|
|
|
|
|
struct lsquic_conn;
|
|
|
|
struct lsquic_engine_public;
|
|
|
|
struct lsquic_mm;
|
Latest changes
- [API Change] Sendfile-like functionality is gone. The stream no
longer opens files and deals with file descriptors. (Among other
things, this makes the code more portable.) Three writing functions
are provided:
lsquic_stream_write
lsquic_stream_writev
lsquic_stream_writef (NEW)
lsquic_stream_writef() is given an abstract reader that has function
pointers for size() and read() functions which the user can implement.
This is the most flexible way. lsquic_stream_write() and
lsquic_stream_writev() are now both implemented as wrappers around
lsquic_stream_writef().
- [OPTIMIZATION] When writing to stream, be it within or without the
on_write() callback, place data directly into packet buffer,
bypassing auxiliary data structures. This reduces amount of memory
required, for the amount of data that can be written is limited
by the congestion window.
To support writes outside the on_write() callback, we keep N
outgoing packet buffers per connection which can be written to
by any stream. One half of these are reserved for the highest
priority stream(s), the other half for all other streams. This way,
low-priority streams cannot write instead of high-priority streams
and, on the other hand, low-priority streams get a chance to send
their packets out.
The algorithm is as follows:
- When user writes to stream outside of the callback:
- If this is the highest priority stream, place it onto the
reserved N/2 queue or fail.
(The actual size of this queue is dynamic -- MAX(N/2, CWND) --
rather than N/2, allowing high-priority streams to write as
much as can be sent.)
- If the stream is not the highest priority, try to place the
data onto the reserved N/2 queue or fail.
- When tick occurs *and* more packets can be scheduled:
- Transfer packets from the high N/2 queue to the scheduled
queue.
- If more scheduling is allowed:
- Call on_write callbacks for highest-priority streams,
placing resulting packets directly onto the scheduled queue.
- If more scheduling is allowed:
- Transfer packets from the low N/2 queue to the scheduled
queue.
- If more scheduling is allowed:
- Call on_write callbacks for non-highest-priority streams,
placing resulting packets directly onto the scheduled queue
The number N is currently 20, but it could be varied based on
resource usage.
- If stream is created due to incoming headers, make headers readable
from on_new.
- Outgoing packets are no longer marked non-writeable to prevent placing
more than one STREAM frame from the same stream into a single packet.
This property is maintained via code flow and an explicit check.
Packets for stream data are allocated using a special function.
- STREAM frame elision is cheaper, as we only perform it if a reset
stream has outgoing packets referencing it.
- lsquic_packet_out_t is smaller, as stream_rec elements are now
inside a union.
2017-10-31 13:35:58 +00:00
|
|
|
struct lsquic_hash;
|
2017-09-22 21:00:03 +00:00
|
|
|
struct headers_stream;
|
|
|
|
struct lsquic_send_ctl;
|
2019-01-16 20:13:59 +00:00
|
|
|
#if LSQUIC_CONN_STATS
|
|
|
|
struct conn_stats;
|
|
|
|
#endif
|
2019-09-11 15:27:58 +00:00
|
|
|
struct qpack_enc_hdl;
|
|
|
|
struct qpack_dec_hdl;
|
|
|
|
struct network_path;
|
2017-09-22 21:00:03 +00:00
|
|
|
|
|
|
|
struct lsquic_conn_public {
|
Latest changes
- [API Change] Sendfile-like functionality is gone. The stream no
longer opens files and deals with file descriptors. (Among other
things, this makes the code more portable.) Three writing functions
are provided:
lsquic_stream_write
lsquic_stream_writev
lsquic_stream_writef (NEW)
lsquic_stream_writef() is given an abstract reader that has function
pointers for size() and read() functions which the user can implement.
This is the most flexible way. lsquic_stream_write() and
lsquic_stream_writev() are now both implemented as wrappers around
lsquic_stream_writef().
- [OPTIMIZATION] When writing to stream, be it within or without the
on_write() callback, place data directly into packet buffer,
bypassing auxiliary data structures. This reduces amount of memory
required, for the amount of data that can be written is limited
by the congestion window.
To support writes outside the on_write() callback, we keep N
outgoing packet buffers per connection which can be written to
by any stream. One half of these are reserved for the highest
priority stream(s), the other half for all other streams. This way,
low-priority streams cannot write instead of high-priority streams
and, on the other hand, low-priority streams get a chance to send
their packets out.
The algorithm is as follows:
- When user writes to stream outside of the callback:
- If this is the highest priority stream, place it onto the
reserved N/2 queue or fail.
(The actual size of this queue is dynamic -- MAX(N/2, CWND) --
rather than N/2, allowing high-priority streams to write as
much as can be sent.)
- If the stream is not the highest priority, try to place the
data onto the reserved N/2 queue or fail.
- When tick occurs *and* more packets can be scheduled:
- Transfer packets from the high N/2 queue to the scheduled
queue.
- If more scheduling is allowed:
- Call on_write callbacks for highest-priority streams,
placing resulting packets directly onto the scheduled queue.
- If more scheduling is allowed:
- Transfer packets from the low N/2 queue to the scheduled
queue.
- If more scheduling is allowed:
- Call on_write callbacks for non-highest-priority streams,
placing resulting packets directly onto the scheduled queue
The number N is currently 20, but it could be varied based on
resource usage.
- If stream is created due to incoming headers, make headers readable
from on_new.
- Outgoing packets are no longer marked non-writeable to prevent placing
more than one STREAM frame from the same stream into a single packet.
This property is maintained via code flow and an explicit check.
Packets for stream data are allocated using a special function.
- STREAM frame elision is cheaper, as we only perform it if a reset
stream has outgoing packets referencing it.
- lsquic_packet_out_t is smaller, as stream_rec elements are now
inside a union.
2017-10-31 13:35:58 +00:00
|
|
|
struct lsquic_streams_tailq sending_streams, /* Send RST_STREAM, BLOCKED, and WUF frames */
|
|
|
|
read_streams,
|
|
|
|
write_streams, /* Send STREAM frames */
|
2017-09-22 21:00:03 +00:00
|
|
|
service_streams;
|
Latest changes
- [API Change] Sendfile-like functionality is gone. The stream no
longer opens files and deals with file descriptors. (Among other
things, this makes the code more portable.) Three writing functions
are provided:
lsquic_stream_write
lsquic_stream_writev
lsquic_stream_writef (NEW)
lsquic_stream_writef() is given an abstract reader that has function
pointers for size() and read() functions which the user can implement.
This is the most flexible way. lsquic_stream_write() and
lsquic_stream_writev() are now both implemented as wrappers around
lsquic_stream_writef().
- [OPTIMIZATION] When writing to stream, be it within or without the
on_write() callback, place data directly into packet buffer,
bypassing auxiliary data structures. This reduces amount of memory
required, for the amount of data that can be written is limited
by the congestion window.
To support writes outside the on_write() callback, we keep N
outgoing packet buffers per connection which can be written to
by any stream. One half of these are reserved for the highest
priority stream(s), the other half for all other streams. This way,
low-priority streams cannot write instead of high-priority streams
and, on the other hand, low-priority streams get a chance to send
their packets out.
The algorithm is as follows:
- When user writes to stream outside of the callback:
- If this is the highest priority stream, place it onto the
reserved N/2 queue or fail.
(The actual size of this queue is dynamic -- MAX(N/2, CWND) --
rather than N/2, allowing high-priority streams to write as
much as can be sent.)
- If the stream is not the highest priority, try to place the
data onto the reserved N/2 queue or fail.
- When tick occurs *and* more packets can be scheduled:
- Transfer packets from the high N/2 queue to the scheduled
queue.
- If more scheduling is allowed:
- Call on_write callbacks for highest-priority streams,
placing resulting packets directly onto the scheduled queue.
- If more scheduling is allowed:
- Transfer packets from the low N/2 queue to the scheduled
queue.
- If more scheduling is allowed:
- Call on_write callbacks for non-highest-priority streams,
placing resulting packets directly onto the scheduled queue
The number N is currently 20, but it could be varied based on
resource usage.
- If stream is created due to incoming headers, make headers readable
from on_new.
- Outgoing packets are no longer marked non-writeable to prevent placing
more than one STREAM frame from the same stream into a single packet.
This property is maintained via code flow and an explicit check.
Packets for stream data are allocated using a special function.
- STREAM frame elision is cheaper, as we only perform it if a reset
stream has outgoing packets referencing it.
- lsquic_packet_out_t is smaller, as stream_rec elements are now
inside a union.
2017-10-31 13:35:58 +00:00
|
|
|
struct lsquic_hash *all_streams;
|
2017-09-22 21:00:03 +00:00
|
|
|
struct lsquic_cfcw cfcw;
|
|
|
|
struct lsquic_conn_cap conn_cap;
|
|
|
|
struct lsquic_rtt_stats rtt_stats;
|
|
|
|
struct lsquic_engine_public *enpub;
|
|
|
|
struct malo *packet_out_malo;
|
|
|
|
struct lsquic_conn *lconn;
|
|
|
|
struct lsquic_mm *mm;
|
2019-09-11 15:27:58 +00:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
struct headers_stream *hs;
|
|
|
|
} gquic;
|
|
|
|
struct {
|
|
|
|
struct qpack_enc_hdl *qeh;
|
|
|
|
struct qpack_dec_hdl *qdh;
|
2020-10-07 13:41:26 +00:00
|
|
|
struct hcso_writer *hcso;
|
2019-09-11 15:27:58 +00:00
|
|
|
struct lsquic_hash *promises;
|
|
|
|
} ietf;
|
|
|
|
} u;
|
|
|
|
enum {
|
|
|
|
CP_STREAM_UNBLOCKED = 1 << 0, /* Set when a stream becomes unblocked */
|
|
|
|
} cp_flags;
|
2017-09-22 21:00:03 +00:00
|
|
|
struct lsquic_send_ctl *send_ctl;
|
2019-01-16 20:13:59 +00:00
|
|
|
#if LSQUIC_CONN_STATS
|
|
|
|
struct conn_stats *conn_stats;
|
|
|
|
#endif
|
2019-09-11 15:27:58 +00:00
|
|
|
const struct network_path *path;
|
2019-11-15 14:02:07 +00:00
|
|
|
#if LSQUIC_EXTRA_CHECKS
|
|
|
|
unsigned long stream_frame_bytes;
|
2020-06-09 15:55:56 +00:00
|
|
|
unsigned wtp_level; /* wtp: Write To Packets */
|
2019-11-15 14:02:07 +00:00
|
|
|
#endif
|
2020-05-06 13:35:33 +00:00
|
|
|
/* "unsigned" is wide enough: these values are only used for amplification
|
|
|
|
* limit before initial path is validated.
|
|
|
|
*/
|
|
|
|
unsigned bytes_in; /* successfully processed */
|
|
|
|
unsigned bytes_out;
|
2020-06-09 15:55:56 +00:00
|
|
|
/* Used for no-progress timeout */
|
|
|
|
lsquic_time_t last_tick, last_prog;
|
2020-11-18 14:05:15 +00:00
|
|
|
unsigned max_peer_ack_usec;
|
2021-06-02 04:39:15 +00:00
|
|
|
uint8_t n_special_streams;
|
2017-09-22 21:00:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|