Esempio n. 1
0
ChooseServerDialog::ChooseServerDialog(QStringList * serverNames) {

  setWindowTitle("Choose Your Server");
  setModal(true);

  QVBoxLayout* box = new QVBoxLayout(this);
  box->setMargin(50);
  box->setSpacing(25);

  serverList = new QListWidget(this);
  serverList->setSelectionMode(QAbstractItemView::SingleSelection);
  serverList->clear();
  serverList->insertItems(0, (*serverNames));

  label = new QLabel("Please choose the server from which you want to download the plugin", this);
  QPalette pal;
  pal.setColor(label->foregroundRole(), Qt::blue);
  label->setAutoFillBackground(true);
  label->setPalette(pal);
  QFont font;
  font.setBold(true);
  font.setPixelSize(12);
  label->setFont(font);
  cancel = new QPushButton("Cancel",this);
  ok = new QPushButton("Ok",this);

  connect(cancel,SIGNAL(clicked()),this,SLOT(cancelSelection()));
  connect(ok,SIGNAL(clicked()),this,SLOT(selectServer()));

  QHBoxLayout *boxButtons = new QHBoxLayout(this);
  boxButtons->addWidget(ok);
  boxButtons->addWidget(cancel);
  box->addWidget(label);
  box->addWidget(serverList);

  box->addLayout(boxButtons);

  setLayout(box);
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
  int tcpsock = 0;
  int udpsock = 0;
  struct sockaddr_in from;
  double capacityup = 0, capacitydown = 0;
  double measupcap = 0, measdowncap = 0;
  unsigned int tbresult = 0, tbmindepth = 0, tbmaxdepth = 0, tbabortflag = 0;
  double tbrate = 0, truecapup = 0, truecapdown = 0;
  double sleepRes = 1;
  char filename[256], tracefile[256];
  int fileid = -1;
  struct in_addr sin_addr;
  struct timeval tv;
  FILE *fp;
  extern double TB_RATE_AVG_INTERVAL;

  TB_RATE_AVG_INTERVAL = 0.3;

  memset(tracefile, 0, 256);
  CHKRET(prober_config_load(argc, argv, tracefile, &fileid));

  sleepRes = prober_sleep_resolution();

  if (serverip) {
    tcpsock = connect2server(serverip, fileid);
  } else {
    tcpsock = selectServer(fileid);
    if(tcpsock <= 0) printf("Server busy. Please try again later.\n");
  }
  CHKRET(tcpsock);

  memset(&from, 0, sizeof(from));
  from.sin_family      = PF_INET;
  //from.sin_port        = htons(SERV_PORT_UDP);
  from.sin_port        = htons(serv_port);
  from.sin_addr.s_addr = serverip;

  gettimeofday(&tv, NULL);
  sin_addr.s_addr = serverip;
  memset(filename, 0, 256);
  sprintf(filename, "/tmp/udp_%s.log", inet_ntoa(sin_addr));
  fp = fopen(filename, "a+w");
  fprintf(fp, "sleep time resolution: %.2f ms.\n", sleepRes*1000);

  //udpsock = udpclient(serverip, SERV_PORT_UDP);
  udpsock = udpclient(serverip, serv_port);
  CHKRET(udpsock);
  sin_addr.s_addr = serverip;
  fprintf(fp, "Connected to server %s.\n", inet_ntoa(sin_addr));

  fprintf(fp, "\nEstimating capacity:\n");
  capacityup = estimateCapacity(tcpsock, udpsock, &from);
  CHKRET(capacityup);
  CHKRET(sendCapEst(tcpsock));
  fprintf(fp, "Upstream: %d Kbps.\n", (int)capacityup);
  capacitydown = capacityEstimation(tcpsock, udpsock, &from, fp);
  CHKRET(capacitydown);
  //printf("Downstream: %d Kbps.\n", (int)capacitydown);

  // send to test log
  printf("%s, %d, %.2f, %.2f\n",inet_ntoa(sin_addr), (int)tv.tv_sec, capacityup, capacitydown);
  fprintf(fp, "LOG: %s, %s, %d, %.2f, %.2f\n", filename, inet_ntoa(sin_addr), (int)tv.tv_sec, capacityup, capacitydown);
  // finished logging

  close(udpsock);
  close(tcpsock);

  //printf("\nFor more information, visit: http://www.cc.gatech.edu/~partha/diffprobe\n");
  fprintf(fp, "\nDONE\n");
  fclose(fp);

  unlink(filename);
  return(0);
}
Esempio n. 3
0
int main(int argc, char *argv[])
{
  int tcpsock = 0;
  int udpsock = 0;
  struct sockaddr_in from;
  double capacityup = 0, capacitydown = 0;
  double measupcap = 0, measdowncap = 0;
  unsigned int tbresult = 0, tbmindepth = 0, tbmaxdepth = 0, tbabortflag = 0;
  double tbrate = 0, truecapup = 0, truecapdown = 0;
  double sleepRes = 1;
  char filename[256], tracefile[256];
  int fileid = -1;
  struct in_addr sin_addr;
  struct timeval tv;
  FILE *fp;
  extern double TB_RATE_AVG_INTERVAL;

  TB_RATE_AVG_INTERVAL = 0.3;

  printf("DiffProbe release. January 2012.\n");
  printf("Shaper Detection Module.\n\n");

  memset(tracefile, 0, 256);
  CHKRET(prober_config_load(argc, argv, tracefile, &fileid));

  sleepRes = prober_sleep_resolution();

  //tcpsock = connect2server(serverip, fileid);
  tcpsock = selectServer(fileid);
  if(tcpsock <= 0) printf("Server busy. Please try again later.\n");
  CHKRET(tcpsock);

  memset(&from, 0, sizeof(from));
  from.sin_family      = PF_INET;
  from.sin_port        = htons(SERV_PORT_UDP);
  from.sin_addr.s_addr = serverip;

  gettimeofday(&tv, NULL);
  sin_addr.s_addr = serverip;
  memset(filename, 0, 256);
  sprintf(filename, "%s_%d.txt", inet_ntoa(sin_addr), (int)tv.tv_sec);
  fp = fopen(filename, "w");
  fprintf(fp, "sleep time resolution: %.2f ms.\n", sleepRes*1000);

  udpsock = udpclient(serverip, SERV_PORT_UDP);
  CHKRET(udpsock);
  sin_addr.s_addr = serverip;
  printf("Connected to server %s.\n", inet_ntoa(sin_addr));

  printf("\nEstimating capacity:\n");
  capacityup = estimateCapacity(tcpsock, udpsock, &from);
  CHKRET(capacityup);
  CHKRET(sendCapEst(tcpsock));
  capacitydown = capacityEstimation(tcpsock, udpsock, &from, fp);
  CHKRET(capacitydown);

  mflowSender(tcpsock, udpsock, &from,
	(capacityup > 200000) ? 195000 : capacityup, sleepRes, &measupcap, 0);
  mflowReceiver(tcpsock, udpsock, &measdowncap, fp, 0);
  //XXX: the meas code needs trains and lower cpu
  //following two lines for 802.11a/b/g/n links
  if(capacityup < 80000) capacityup = measupcap;
  if(capacitydown < 80000) capacitydown = measdowncap;
  if(capacityup > 200000)
  {
	  printf("Upstream: greater than 200 Mbps.\n");
	  capacityup = 195000;
  }
  else
  {
	  printf("Upstream: %d Kbps.\n", (int)capacityup);
//	  capacityup *= 0.95; //reduce loss-based aborts
  }
  truecapup = capacityup;
  if(capacitydown > 200000)
  {
	  printf("Downstream: greater than 200 Mbps.\n");
	  capacitydown = 195000;
  }
  else
  {
	  printf("Downstream: %d Kbps.\n", (int)capacitydown);
//	  capacitydown *= 0.95; //reduce loss-based aborts
  }
  truecapdown = capacitydown;

  printf("\nThe measurement will last for about %.1f minutes. Please wait.\n",
	0.5*ceil(2*(
	(2 * (60)  // probing + low-rate
	+ (40560 + 3.5 * capacitydown * (60) ) * 8 / (1000*capacityup))/60)));  // to upload file 

  printf("\nChecking for traffic shapers:\n\n");
  mflowSender(tcpsock, udpsock, &from, -1, sleepRes, NULL, 1);
  CHKRET(tbdetectSender(tcpsock, udpsock, &from, capacityup, sleepRes, 
		  &tbresult, &tbmindepth, &tbmaxdepth, &tbrate, &tbabortflag, fp));
  if(tbresult == 1) truecapup = tbrate;
  printShaperResult(tbresult, tbmindepth, tbmaxdepth, tbrate, tbabortflag, 0, stdout);

  mflowReceiver(tcpsock, udpsock, NULL, fp, 1);
  CHKRET(tbdetectReceiver(tcpsock, udpsock, capacitydown, sleepRes,
		  &tbresult, &tbmindepth, &tbmaxdepth, &tbrate, &tbabortflag, fp));
  if(tbresult == 1) truecapdown = tbrate;
  fclose(fp);
  sendData(tcpsock, filename);
  printShaperResult(tbresult, tbmindepth, tbmaxdepth, tbrate, tbabortflag, 1, stdout);

  close(udpsock);
  close(tcpsock);
  unlink(filename);

  printf("\nFor more information, visit: http://www.cc.gatech.edu/~partha/diffprobe\n");

  return(0);
}