std::string sfn = tmpdir+"team.jpg";
const char* filename = sfn.c_str();
+ char servstr[256];
+ struct hostent *h = gethostbyname("mughal.tribler.org");
+ if (h == NULL)
+ {
+ print_error("cannot nslookup");
+ return 1;
+ }
+ else
+ {
+ struct in_addr addr;
+ addr.s_addr = *(u_long *) h->h_addr_list[0];
+ sprintf(servstr,"%s:%d", inet_ntoa(addr), 10000);
+ }
+
+ printf("Server %s\n",servstr);
- Address tracker("130.161.211.198:10000"),
+ Address tracker(servstr),
bindaddr((uint32_t)INADDR_ANY,10000);
if (0>p2tp::Listen(bindaddr)) {
print_error("cannot bind");
*
*/
#include "p2tp.h"
-
+#ifdef _MSC_VER
+ // To avoid complaints about std::max. Appears to work in VS2008
+ #undef min
+ #undef max
+#endif
using namespace p2tp;
}
-KeepAliveController::KeepAliveController(SendController* prev, tint delay) :
+KeepAliveController::KeepAliveController(SendController* prev, tint delay) :
SendController(prev), delay_(delay) {
ch_->dev_avg_ = TINT_SEC; // without constant active measurement, rtt is unreliable
delay_=ch_->rtt_avg_;
bool KeepAliveController::MaySendData() {
return true;
}
-
+
void KeepAliveController::OnDataSent(bin64_t b) {
if (b==bin64_t::ALL || b==bin64_t::NONE) {
Swap(new SlowStartController(this));
}
}
-
+
void KeepAliveController::OnDataRecvd(bin64_t b) {
if (b!=bin64_t::NONE && b!=bin64_t::ALL) { // channel is alive
delay_ = ch_->rtt_avg_;
Schedule(NOW); // schedule an ACK; TODO: aggregate
}
}
-
+
void KeepAliveController::OnAckRcvd(bin64_t ackd) {
// probably to something sent by CwndControllers before this one got installed
}
-
+
CwndController::CwndController(SendController* orig, int cwnd) :
-SendController(orig), cwnd_(cwnd), last_change_(0) {
+SendController(orig), cwnd_(cwnd), last_change_(0) {
}
bool CwndController::MaySendData() {
return ch_->data_out_.empty() ||
(ch_->data_out_.size() < cwnd_ && NOW-ch_->last_send_data_time_ >= spacing);
}
-
+
void CwndController::OnDataSent(bin64_t b) {
if ( (b==bin64_t::ALL || b==bin64_t::NONE) && MaySendData() ) { // no more data (no hints?)
Schedule(NOW); // send ACK; todo: aggregate ACKs
}
}
-
+
void CwndController::OnAckRcvd(bin64_t ackd) {
if (ackd==bin64_t::NONE) {
dprintf("%s #%i sendctrl loss detected\n",tintstr(),ch_->id);
} else {
if (cwnd_<1)
cwnd_ *= 2;
- else
+ else
cwnd_ += 1.0/cwnd_;
dprintf("%s #%i sendctrl cwnd to %f\n",tintstr(),ch_->id,cwnd_);
}
Schedule(NOW);
Swap(new AIMDController(this,cwnd_));
}
- } else
+ } else
cwnd_ /= 2;
}
-
+