39 #include <sys/types.h>
52 using namespace dtn::data;
58 const int UDPConvergenceLayer::DEFAULT_PORT = 4556;
61 : _net(net), _port(port), m_maxmsgsize(mtu),
_running(false)
82 std::stringstream service;
84 service <<
"port=" << _port <<
";";
96 bool announced =
false;
103 std::list<ibrcommon::vaddress> list = _net.getAddresses();
108 for (std::list<ibrcommon::vaddress>::const_iterator addr_it = list.begin(); addr_it != list.end(); ++addr_it)
117 sa_family_t f = addr.
family();
118 if ((f != AF_INET) && (f != AF_INET6))
continue;
120 std::stringstream service;
122 service <<
"ip=" << addr.
address() <<
";port=" << _port <<
";";
138 std::stringstream service;
139 service <<
"port=" << _port <<
";";
147 if (uri_list.empty())
158 std::string address =
"0.0.0.0";
159 unsigned int port = 0;
162 uri.
decode(address, port);
183 if (size > m_maxmsgsize)
193 const size_t fragment_size = m_maxmsgsize - header;
194 const size_t fragment_count = (psize / fragment_size) + (((psize % fragment_size) > 0) ? 1 : 0);
199 for (
size_t i = 0; i < fragment_count; ++i)
203 std::stringstream ss;
206 serializer << fragment;
207 std::string data = ss.str();
215 std::stringstream ss;
218 serializer << bundle;
219 std::string data = ss.str();
248 for (ibrcommon::socketset::iterator iter = socks.begin(); iter != socks.end(); ++iter) {
252 sock.
sendto(data.c_str(), data.length(), 0, addr);
255 addStats(
"out", data.length());
269 std::vector<char> data(m_maxmsgsize);
275 _vsocket.select(&readfds, NULL, NULL, NULL);
277 if (readfds.size() > 0) {
281 size_t len = sock->
recvfrom(&data[0], m_maxmsgsize, 0, fromaddr);
284 addStats(
"int", len);
286 std::stringstream ss; ss <<
"udp://" << fromaddr.
toString();
293 ss.write(&data[0], len);
311 std::stringstream ss; ss << _port;
326 for (ibrcommon::socketset::iterator iter = socks.begin(); iter != socks.end(); ++iter) {
341 for (ibrcommon::socketset::iterator iter = socks.begin(); iter != socks.end(); ++iter) {
360 std::list<ibrcommon::vaddress> addrs = _net.
getAddresses();
363 std::stringstream ss; ss << _port;
365 for (std::list<ibrcommon::vaddress>::iterator iter = addrs.begin(); iter != addrs.end(); ++iter) {
413 receive(bundle, sender);
420 }
catch (
const std::exception &ex) {
435 return "UDPConvergenceLayer";