comparison src/event/ngx_event_quic_transport.c @ 8308:e10b4c61420f quic

Implemented retransmission and retransmit queue. All frames collected to packet are moved into a per-namespace send queue. QUIC connection has a timer which fires on the closest max_ack_delay time. The frame is deleted from the queue when a corresponding packet is acknowledged. The NGX_QUIC_MAX_RETRANSMISSION is a timeout that defines maximum length of retransmission of a frame.
author Vladimir Homutov <vl@nginx.com>
date Wed, 01 Apr 2020 17:06:26 +0300
parents dc7ac778aafe
children fdda518d10ba
comparison
equal deleted inserted replaced
8307:dc7ac778aafe 8308:e10b4c61420f
1078 return NGX_DECLINED; 1078 return NGX_DECLINED;
1079 } 1079 }
1080 1080
1081 1081
1082 ssize_t 1082 ssize_t
1083 ngx_quic_create_frame(u_char *p, u_char *end, ngx_quic_frame_t *f) 1083 ngx_quic_create_frame(u_char *p, ngx_quic_frame_t *f)
1084 { 1084 {
1085 // TODO: handle end arg 1085 /*
1086 * QUIC-recovery, section 2:
1087 *
1088 * Ack-eliciting Frames: All frames other than ACK, PADDING, and
1089 * CONNECTION_CLOSE are considered ack-eliciting.
1090 */
1091 f->need_ack = 1;
1086 1092
1087 switch (f->type) { 1093 switch (f->type) {
1088 case NGX_QUIC_FT_ACK: 1094 case NGX_QUIC_FT_ACK:
1095 f->need_ack = 0;
1089 return ngx_quic_create_ack(p, &f->u.ack); 1096 return ngx_quic_create_ack(p, &f->u.ack);
1090 1097
1091 case NGX_QUIC_FT_CRYPTO: 1098 case NGX_QUIC_FT_CRYPTO:
1092 return ngx_quic_create_crypto(p, &f->u.crypto); 1099 return ngx_quic_create_crypto(p, &f->u.crypto);
1093 1100
1103 case NGX_QUIC_FT_STREAM6: 1110 case NGX_QUIC_FT_STREAM6:
1104 case NGX_QUIC_FT_STREAM7: 1111 case NGX_QUIC_FT_STREAM7:
1105 return ngx_quic_create_stream(p, &f->u.stream); 1112 return ngx_quic_create_stream(p, &f->u.stream);
1106 1113
1107 case NGX_QUIC_FT_CONNECTION_CLOSE: 1114 case NGX_QUIC_FT_CONNECTION_CLOSE:
1115 f->need_ack = 0;
1108 return ngx_quic_create_close(p, &f->u.close); 1116 return ngx_quic_create_close(p, &f->u.close);
1109 1117
1110 case NGX_QUIC_FT_MAX_STREAMS: 1118 case NGX_QUIC_FT_MAX_STREAMS:
1111 return ngx_quic_create_max_streams(p, &f->u.max_streams); 1119 return ngx_quic_create_max_streams(p, &f->u.max_streams);
1112 1120
1128 1136
1129 /* minimal ACK packet */ 1137 /* minimal ACK packet */
1130 1138
1131 if (p == NULL) { 1139 if (p == NULL) {
1132 len = ngx_quic_varint_len(NGX_QUIC_FT_ACK); 1140 len = ngx_quic_varint_len(NGX_QUIC_FT_ACK);
1133 len += ngx_quic_varint_len(ack->pn); 1141 len += ngx_quic_varint_len(ack->largest);
1134 len += ngx_quic_varint_len(0); 1142 len += ngx_quic_varint_len(0);
1135 len += ngx_quic_varint_len(0); 1143 len += ngx_quic_varint_len(0);
1136 len += ngx_quic_varint_len(0); 1144 len += ngx_quic_varint_len(ack->first_range);
1137 1145
1138 return len; 1146 return len;
1139 } 1147 }
1140 1148
1141 start = p; 1149 start = p;
1142 1150
1143 ngx_quic_build_int(&p, NGX_QUIC_FT_ACK); 1151 ngx_quic_build_int(&p, NGX_QUIC_FT_ACK);
1144 ngx_quic_build_int(&p, ack->pn); 1152 ngx_quic_build_int(&p, ack->largest);
1145 ngx_quic_build_int(&p, 0); 1153 ngx_quic_build_int(&p, 0);
1146 ngx_quic_build_int(&p, 0); 1154 ngx_quic_build_int(&p, 0);
1147 ngx_quic_build_int(&p, 0); 1155 ngx_quic_build_int(&p, ack->first_range);
1148 1156
1149 return p - start; 1157 return p - start;
1150 } 1158 }
1151 1159
1152 1160