Browse files

lan plugin config option for transmitting duplicate packets

  • Loading branch information...
1 parent c0d064f commit eaffd192a80cf73caf793d0da749709b03405b84 @RJ committed Jul 18, 2009
Showing with 23 additions and 11 deletions.
  1. +7 −2 resolvers/lan/README.txt
  2. +16 −9 resolvers/lan/lan.cpp
View
9 resolvers/lan/README.txt
@@ -2,13 +2,15 @@ The LAN plugin broadcasts searches using UDP multicast.
Results are streamed over HTTP using the address the UDP result came from.
It should just automatically work on home/small office networks.
--
-By default you don't need anything in the config file for this plugin, however:
+By default you don't need anything in the config file for this plugin, however
+the following options are valid if you need any of them:
"lan" :
{
"listenip" : "your.lan.ip.address",
"listenport" : 8888,
- "endpoints" : ["239.255.0.1", "10.1.2.3", "192.168.1.1"]
+ "endpoints" : ["239.255.0.1", "10.1.2.3", "192.168.1.1"],
+ "numcopies" : 3
}
* If you change the "listenport", it'll only work with others on the same port.
@@ -23,3 +25,6 @@ By default you don't need anything in the config file for this plugin, however:
machine you can reach on the LAN, despite multicast not working.
* to change endpoint ports too: "endpoints" : [ ["10.1.2.3",1234], [..] ]
+
+* for lossy networks, set copies to more than 1, so your UDP packets stand a
+ better chance of being received. default is 1.
View
25 resolvers/lan/lan.cpp
@@ -219,15 +219,22 @@ lan::async_send(boost::asio::ip::udp::endpoint * remote_endpoint,
//cout << "UDPsend[" << remote_endpoint.address()
// << ":" << remote_endpoint.port() << "]"
// << "(" << message << ")" << endl;
- char * buf = (char*)malloc(message.length());
- memcpy(buf, message.data(), message.length());
- socket_->async_send_to(
- boost::asio::buffer(buf,message.length()),
- *remote_endpoint,
- boost::bind(&lan::handle_send, this,
- boost::asio::placeholders::error,
- boost::asio::placeholders::bytes_transferred,
- buf));
+
+ // you can set numcopies to 2 or 3 for lossy networks:
+ int copies = m_pap->get<int>("plugins.lan.numcopies", 1);
+ if(copies<1) copies=1;
+ for(int j = 0; j<copies; j++)
+ {
+ char * buf = (char*)malloc(message.length());
+ memcpy(buf, message.data(), message.length());
+ socket_->async_send_to(
+ boost::asio::buffer(buf,message.length()),
+ *remote_endpoint,
+ boost::bind(&lan::handle_send, this,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ buf));
+ }
}
void lan::handle_send( const boost::system::error_code& error,

0 comments on commit eaffd19

Please sign in to comment.