Exemplo n.º 1
0
void crofchantest::handle_established(rofl::crofchan &chan,
                                      rofl::crofconn &conn,
                                      uint8_t ofp_version) {

  rofl::AcquireReadWriteLock lock(tlock);
  LOG(INFO) << std::endl;
  LOG(INFO) << "TEST: crofchantest::handle_established() -chan-, "
            << "num_of_accepts = " << num_of_accepts << ", "
            << "num_of_conns = " << num_of_conns << ", "
            << "channel1.size() = " << channel1->size() << ", "
            << "channel2.size() = " << channel2->size() << ", "
            << "conn.get_auxid() = " << (int)conn.get_auxid().get_id()
            << std::endl;

  CPPUNIT_ASSERT(conn.is_established());

  if (testname == std::string("test_congestion")) {

    /* we need a large queue size to force a loopback socket into congestion */
    if (channel1 == &chan) {
      conn.set_txqueue_max_size(65536);
    }

    if (conn.get_auxid() == rofl::cauxid(0)) {
      rofl::cthread::thread(thread_num)
          .add_timer(this, TIMER_ID_START_SENDING_PACKET_INS,
                     rofl::ctimespec().expire_in(1));
    }
  }
}
Exemplo n.º 2
0
void
crofconntest::handle_recv(
		rofl::crofconn& conn, rofl::openflow::cofmsg* pmsg)
{
	CPPUNIT_ASSERT(pmsg != nullptr);

	//std::cerr << "crofconntest::handle_recv() " << std::endl << *pmsg;

	dpid = 0xc1c2c3c4c5c6c7c8;
	auxid = 0xd1;
	n_buffers = 0xe1e2e3e4;
	n_tables = 0xff;



	switch (pmsg->get_type()) {
	case rofl::openflow::OFPT_FEATURES_REQUEST: {
		rofl::openflow::cofmsg_features_reply* msg =
				new rofl::openflow::cofmsg_features_reply(
						pmsg->get_version(),
						pmsg->get_xid(),
						dpid,
						n_buffers,
						n_tables,
						auxid);
		conn.send_message(msg);
	} break;
	case rofl::openflow::OFPT_PACKET_IN: {
		srv_pkts_rcvd++;
		//std::cerr << "RECV(Packet-In): s:" << srv_pkts_rcvd << "(" << cli_pkts_sent << "), ";
		if (srv_pkts_sent < num_of_packets) {
			send_packet_out(conn.get_version());
		}

	} break;
	case rofl::openflow::OFPT_PACKET_OUT: {
		cli_pkts_rcvd++;
		//std::cerr << "RECV(Packet-Out): c:" << cli_pkts_rcvd << "(" << srv_pkts_sent << "), ";
		if (cli_pkts_sent < num_of_packets) {
			send_packet_in(conn.get_version());
		}

	} break;
	default: {
		CPPUNIT_ASSERT(false);
	};
	}

	delete pmsg;
}
Exemplo n.º 3
0
void crofchantest::handle_established(rofl::crofconn &conn,
                                      uint8_t ofp_version) {
  {
    rofl::AcquireReadWriteLock lock(plock);
    pending_conns.erase(&conn);
    LOG(INFO) << "crofchantest::handle_established() pending_conns: "
              << pending_conns.size() << std::endl;
  }
  rofl::AcquireReadWriteLock lock(tlock);
  channel2->add_conn(&conn);

  LOG(INFO) << "TEST: crofchantest::handle_established() server via -conn-, "
            << "conn.get_auxid() = " << (int)conn.get_auxid().get_id()
            << std::endl;

  CPPUNIT_ASSERT(conn.is_established());

  num_of_ctl_established++;
  LOG(INFO) << "num_of_ctl_established = " << num_of_ctl_established
            << std::endl;
}
Exemplo n.º 4
0
void crofchantest::handle_recv(rofl::crofchan &chan, rofl::crofconn &conn,
                               rofl::openflow::cofmsg *pmsg) {
  rofl::AcquireReadWriteLock lock(tlock);
  switch (pmsg->get_type()) {
  case rofl::openflow13::OFPT_FEATURES_REQUEST: {

    LOG(INFO) << "crofchantest::handle_recv() message: " << std::endl
              << *pmsg << "sending FEATURES-REPLY auxid: "
              << (int)conn.get_auxid().get_id() << std::endl;

    rofl::openflow::cofmsg_features_reply *msg =
        new rofl::openflow::cofmsg_features_reply(rofl::openflow13::OFP_VERSION,
                                                  pmsg->get_xid(), dpid);
    msg->set_auxid(conn.get_auxid().get_id());

    conn.send_message(msg);

  } break;
  case rofl::openflow13::OFPT_PACKET_IN: {
    std::cerr << "r";
    num_of_pkts_rcvd++;
    if ((num_of_pkts_sent == num_of_pkts_rcvd) &&
        (max_congestion_rounds <= 0)) {
      LOG(INFO) << "TEST: received all packets, initiating test shutdown "
                << std::endl;
      LOG(INFO) << "sent: " << num_of_pkts_sent << std::endl;
      LOG(INFO) << "rcvd: " << num_of_pkts_rcvd << std::endl;
      keep_running = false;
    }
  } break;
  case rofl::openflow13::OFPT_PACKET_OUT: {

  } break;
  default: {};
  }

  delete pmsg;
}