Problem : I am using kcp, after sending few packets ikcp_send fails. data is not getting transmitted
sending 10bytes of data + 24 bytes kcp header = 34 bytes
`// flash remain
size = (int)(ptr - buffer);
if (size > 0) {
ikcp_output(kcp, buffer, size);
}`
In the above code while data is sent correctly size is always 34 bytes. after some time no data is send size is 0.
so no ikcp_output happening.
`int needsend = 0;
if (segment->xmit == 0) {
needsend = 1;
segment->xmit++;
segment->rto = kcp->rx_rto;
segment->resendts = current + segment->rto + rtomin;
}`
- in correct case when data is getting send ,needsend is set to 1 in above condition.
- in Error case needsend is always 0.
-> kcp create :auto *ptr = ikcp_create(unique_id, reinterpret_cast<void *>(user_pointer)); ptr->output = callback_handler; ikcp_nodelay(ptr, 1, 10, 2, 1); // Turbo mode
-> using ikcp_sendint sent = ikcp_send(kcp_ptr, payload_buffer, payload_len); // kcp_ptr from ikcp_create call above ikcp_flush(kcp_ptr); ikcp_update(kcp_ptr, 10);
1条答案
按热度按时间628mspwn1#
Hi,
Findings on above issue:
After ikcp_send. and once we receive data in ikcp_recv we dont want kcp to sent ACK back to sender. but as ACK is not
sent , packets are re-sent, this causing buffer of KCP to cross limit of 1400.
so we forcibly changes application code to delete un acknowlege segment so that sender dont need to re transmit pkt.
ikcp_parse_una(ikcpcb *kcp, IUINT32 una); ikcp_shrink_buf(kcp);
hence packets are getting transmitted correctly.
Let me know if any side-effect using this way.