summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/lib/transport/udp_zero_copy_asio.cpp12
-rw-r--r--host/lib/usrp/usrp2/io_impl.cpp9
2 files changed, 9 insertions, 12 deletions
diff --git a/host/lib/transport/udp_zero_copy_asio.cpp b/host/lib/transport/udp_zero_copy_asio.cpp
index 3e0e80bd8..7e643abad 100644
--- a/host/lib/transport/udp_zero_copy_asio.cpp
+++ b/host/lib/transport/udp_zero_copy_asio.cpp
@@ -110,9 +110,6 @@ private:
size_t get_recv_buff_size(void);
void set_recv_buff_size(size_t);
-
- static const size_t _mtu = 1500; //FIXME we have no idea
- static const size_t _hdrs = (2 + 14 + 20 + 8); //size of headers (pad, eth, ip, udp)
};
udp_zero_copy_impl::udp_zero_copy_impl(const std::string &addr, const std::string &port){
@@ -146,8 +143,6 @@ udp_zero_copy_impl::~udp_zero_copy_impl(void){
}
managed_recv_buffer::sptr udp_zero_copy_impl::get_recv_buff(void){
- boost::uint32_t *buff_mem = new boost::uint32_t[_mtu/sizeof(boost::uint32_t)];
-
//implement timeout through polling and sleeping
size_t available = 0;
boost::asio::deadline_timer timer(_socket->get_io_service());
@@ -157,8 +152,9 @@ managed_recv_buffer::sptr udp_zero_copy_impl::get_recv_buff(void){
}
//receive only if data is available
+ boost::uint32_t *buff_mem = new boost::uint32_t[available/sizeof(boost::uint32_t)];
if (available){
- available = _socket->receive(boost::asio::buffer(buff_mem, _mtu));
+ available = _socket->receive(boost::asio::buffer(buff_mem, available));
}
//create a new managed buffer to house the data
@@ -168,9 +164,9 @@ managed_recv_buffer::sptr udp_zero_copy_impl::get_recv_buff(void){
}
managed_send_buffer::sptr udp_zero_copy_impl::get_send_buff(void){
- boost::uint32_t *buff_mem = new boost::uint32_t[_mtu/sizeof(boost::uint32_t)];
+ boost::uint32_t *buff_mem = new boost::uint32_t[2000/sizeof(boost::uint32_t)];
return managed_send_buffer::sptr(
- new managed_send_buffer_impl(boost::asio::buffer(buff_mem, _mtu-_hdrs), _socket)
+ new managed_send_buffer_impl(boost::asio::buffer(buff_mem, 2000), _socket)
);
}
diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp
index 19a1ecf0f..62aca49ee 100644
--- a/host/lib/usrp/usrp2/io_impl.cpp
+++ b/host/lib/usrp/usrp2/io_impl.cpp
@@ -104,10 +104,11 @@ size_t usrp2_impl::send(
transport::managed_send_buffer::sptr send_buff = _data_transport->get_send_buff();
boost::uint32_t *tx_mem = send_buff->cast<boost::uint32_t *>();
- size_t num_samps = std::min(
- asio::buffer_size(buff),
- send_buff->size()-vrt::max_header_words32*sizeof(boost::uint32_t)
- )/io_type.size;
+ size_t num_samps = std::min(std::min(
+ asio::buffer_size(buff)/io_type.size,
+ size_t(_max_tx_samples_per_packet)),
+ send_buff->size()/io_type.size
+ );
//kill the end of burst flag if this is a fragment
if (asio::buffer_size(buff)/io_type.size < num_samps)