From 982aeee231396688fade022778cfb743cf185e89 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 4 Mar 2011 18:08:17 -0800 Subject: usrp2: tweak the mtu discovery logic --- host/lib/usrp/usrp2/usrp2_impl.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'host/lib') diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index 164253f96..f7154b0fc 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -171,9 +171,9 @@ static mtu_result_t determine_mtu(const std::string &addr){ size_t min_recv_mtu = sizeof(usrp2_ctrl_data_t), max_recv_mtu = sizeof(buffer); size_t min_send_mtu = sizeof(usrp2_ctrl_data_t), max_send_mtu = sizeof(buffer); - while (min_recv_mtu + 4 < max_recv_mtu){ + while (min_recv_mtu < max_recv_mtu){ - mtu.recv_mtu = (max_recv_mtu + min_recv_mtu)/2 & ~(4-1); + mtu.recv_mtu = (max_recv_mtu/2 + min_recv_mtu/2 + 3) & ~3; //std::cout << "recv_mtu " << mtu.recv_mtu << std::endl; ctrl_data->id = htonl(USRP2_CTRL_ID_HOLLER_AT_ME_BRO); @@ -184,13 +184,13 @@ static mtu_result_t determine_mtu(const std::string &addr){ size_t len = udp_sock->recv(boost::asio::buffer(buffer), echo_timeout); if (len >= mtu.recv_mtu) min_recv_mtu = mtu.recv_mtu; - else max_recv_mtu = mtu.recv_mtu; + else max_recv_mtu = mtu.recv_mtu - 4; } - while (min_send_mtu + 4 < max_send_mtu){ + while (min_send_mtu < max_send_mtu){ - mtu.send_mtu = (max_send_mtu + min_send_mtu)/2 & ~(4-1); + mtu.send_mtu = (max_send_mtu/2 + min_send_mtu/2 + 3) & ~3; //std::cout << "send_mtu " << mtu.send_mtu << std::endl; ctrl_data->id = htonl(USRP2_CTRL_ID_HOLLER_AT_ME_BRO); @@ -202,7 +202,7 @@ static mtu_result_t determine_mtu(const std::string &addr){ if (len >= sizeof(usrp2_ctrl_data_t)) len = ntohl(ctrl_data->data.echo_args.len); if (len >= mtu.send_mtu) min_send_mtu = mtu.send_mtu; - else max_send_mtu = mtu.send_mtu; + else max_send_mtu = mtu.send_mtu - 4; } return mtu; -- cgit v1.2.3