コード例 #1
0
ファイル: TweetReader.cpp プロジェクト: cnplab/blockmon
            /**
            * @brief Configures the block: defines the input file.
            * @param n The configuration parameters
            */
            virtual void _configure(const xml_node& n)
            {
                xml_node source = n.child("source");
                xml_node gates_node = n.child("gates");
                if( (!source)  || (!gates_node) )
                    throw std::runtime_error("TweetReader: missing parameter");
                std::string gates_s = gates_node.attribute("number").value();
                std::string type = source.attribute("type").value();
                std::string ip = source.attribute("ip").value();
                file_name = source.attribute("name").value();
                if(!type.length() || !file_name.length() || !gates_s.length())
                    throw std::runtime_error("TweetReader: missing attribute");
                if(type.compare("offline") != 0)
                    throw std::runtime_error("TweetReader: invalid type parameter");

                num_gates = atoi(gates_s.c_str());

                file.open(file_name);
                if(!file.is_open()) {
                    throw std::runtime_error("TweetReader: cannot open source file");
                }

                // Create and register the output gates
                m_outgate_ids = new int[num_gates];
                for(int i=0; i<num_gates; i++){
                    std::string ogate = outgate_basename + boost::lexical_cast<std::string>(i);
                    m_outgate_ids[i] = register_output_gate(ogate.c_str());
                }
            }
コード例 #2
0
ファイル: ComboPktSource.cpp プロジェクト: cnplab/blockmon
 /**
  * @brief Constructor
  * @param name         The name of the ComboPktSource block instance
  * @param invocation   Invocation type of the block (Indirect, Direct, Async)
  */
 ComboPktSource(const std::string &name, invocation_type invocation)
     :ComboSource(name),              //ignore options
     m_gate_id(register_output_gate("out_pkt"))
 {
     if (invocation != invocation_type::Async) {
         blocklog("ComboPktSource must be Async, ignoring configuration", log_warning);
     }
 }
コード例 #3
0
		 /*
		  * constructor
		  */
		 TstatAnalyzer(const std::string &name, invocation_type invocation) :
			 Block(name, invocation),
			 m_in_gate(register_input_gate("in_pkt")),
			 m_out_gate(register_output_gate("out_pkt")),
             m_msg_recv(0),
             m_msg_sent(0)
		 {
		 }
コード例 #4
0
ファイル: AppendTag.cpp プロジェクト: cnplab/blockmon
 /*
  * constructor
  */
 AppendTag(const std::string &name, invocation_type invocation)
 : Block(name, invocation),
 m_tag_type(undef),
 m_tag_name(),
 m_ingate_id(register_input_gate("in_pkt")),
 m_outgate_id(register_output_gate("out_pkt")),
 m_handle(TAG_INVALID),
 m_generator()
 {
 }
コード例 #5
0
ファイル: PFQSource.cpp プロジェクト: Aeronbroker/blockmon
        /**
         * @brief Constructor
         * @param name         The name of the source block
         * @param invocation   Invocation type of the block (Indirect, Direct, Async)
         */
        PFQSource(const std::string &name, invocation_type invocation)
        : Block(name, invocation_type::Async)
        , m_gate_id(register_output_gate("source_out"))
#if defined(USE_SIMPLE_PACKET) || defined(USE_SLICED_PACKET)
        , m_allocator()
#else
        , m_mem_block(new MemoryBatch(4096*4))
#endif
        , m_pfq()
        , m_device()
        {
            if (invocation != invocation_type::Async) {
                blocklog("PFQSource must be Async, ignoring configuration", log_warning);
            }
        }
コード例 #6
0
ファイル: RRDemux.cpp プロジェクト: Aeronbroker/blockmon
    void RRDemux::_configure(const pugi::xml_node& n)
    {
        // XML configuration
		// Gates
       pugi::xml_node gates_node = n.child("gates");
        if (gates_node)
        {
		    if (gates_node.attribute("number"))
		        m_outgates_number = std::atoi(std::string(gates_node.attribute("number").value()).c_str());
		}
        // Register the gates
		char output_name[7 + (int) ceil(log10(m_outgates_number))];
		for (int i = 0; i < m_outgates_number; i++) {
			sprintf(output_name, "output%d", i + 1);
			register_output_gate(output_name);
		}
    }
コード例 #7
0
 /*
  * constructor
  */
 FlowFilter(const std::string &name, invocation_type invocation) :
 Block(name, invocation),
 m_in_gate(register_input_gate("in_flow")),
 m_out_gate(register_output_gate("out_flow")),
 m_ip_src_address(0),
 m_ip_src_mask(0),
 m_ip_src_mode(0),
 m_ip_dst_address(0),
 m_ip_dst_mask(0),
 m_ip_dst_mode(0),
 m_layer4_proto(0),
 m_layer4_mode(0),
 m_src_port(0),
 m_src_port_mode(0),
 m_dst_port(0),
 m_dst_port_mode(0)
 {
 }
コード例 #8
0
   /**
    * @brief Constructor
    * @param name         The name of the packet counter block
    * @param invocation   Invocation type of the block (Indirect, Direct, Async)
    */
   PassthroughPacketCounter(const std::string &name, invocation_type invocation)
   : Block(name, invocation),
   m_pkt_cnt(0),
   m_byte_cnt(0),
   m_pkt_rate(0),
   m_byte_rate(0),
   m_reset(0),
   m_pkt_cnt_prev(0),
   m_byte_cnt_prev(0),
   m_last_t(std::chrono::system_clock::now()),
   m_timer(true),
 m_ingate_id(register_input_gate("in_pkt")),
 m_outgate_id(register_output_gate("out_pkt"))
   {
       register_variable("byterate",make_rd_var(no_mutex_t(), m_byte_rate));
       register_variable("pktrate",make_rd_var(no_mutex_t(), m_pkt_rate));
       register_variable("pktcnt",make_rd_var(no_mutex_t(), m_pkt_cnt));
       register_variable("bytecnt",make_rd_var(no_mutex_t(), m_byte_cnt));
       register_variable("reset",make_wr_var(no_mutex_t(), m_reset));
   }