Thanks for your kindness.


"You only need to include an item in nox.json if you care about the order in which it is dispatched to components."

->  sorry but can you explain more easily ?


I am also trying to get aggregate reply. so I re-write networkstate/linkload.cc as below

I know I have to register_event and post event. but I don't know how to use post event exactly.

so, please give me some tips ?


Thanks,


#include " include/aggregate-stats-in.hh"

.....

void linkload::configureu(const Configuration* c)

 {                    ......

register_event(Aggregate_stats_in_event::static_get_name());

  }

.....

.....

void linkload::send_stat_req(const datapathid& dpid, uint16_t port)

  {

    size_t size = sizeof(ofp_stats_request)+sizeof(ofp_aggregate_stats_request);

    of_raw.reset(new uint8_t[size]);


    of_stats_request osr(openflow_pack::header(OFPT_STATS_REQUEST, size),

                         OFPST_AGRREGATE, 0);

   

   of_aggregate_stats_request oasr;

   oasr.match.wildcards = 0xffffffff;

   oasr.table_id = 0xff;

   oasr.out_port = OFPP_NONE;


    osr.pack((ofp_stats_request*) openflow_pack::get_pointer(of_raw));

    oasr.pack((ofp_aggregate_stats_request*) openflow_pack::get_pointer(of_raw, sizeof(ofp_stats_request)));


    send_openflow_command(dpi->second.datapath_id, of_raw, false);


/*post event

     I don't know exactly how to use post exactly*/

    size_t rsize = sizeof(ofp_stats_reply)+sizeof(ofp_aggregate_stats_reply);

    of_raw.reset(new uint8_t[rsize]);

    of_stats_reply srep(openflow_pack::header(OFPT_STATS_REPLY, rsize), OFPST_AGGREGATE, 0x0001);

    post(new Aggregate_stats_in_event(dpi->second.datapath_id, srep,..... ));



--------- ---------
: Murphy McCauley <jam...@nau.edu>
޴» : Min-Hyup KANG <kang-min-h...@hanmail.net>
: "NOX-dev" <nox-dev@noxrepo.org>
¥: 2011 7 11 , 11 04 12 +0900
: Re: [nox-dev] send_stat_req
Glad to hear you got it working.

As for aggregate stats replies, use Aggregate_stats_in_event.  This is in the file include/aggregate-stats-in.hh with the rest of the events.

As you notice, it isn't in nox.json, but that is okay.  You only need to include an item in nox.json if you care about the order in which it is dispatched to components.

-- Murphy

On Jul 10, 2011, at 6:10 PM, Min-Hyup KANG wrote:

Hi,

Thank you for your response.

yes, What I add the code to the end of send_stats_req() "of_ports psrep"  is to monitor for port status through the reply of switch using C++ without python.

so I added some code to monitor as below. It seems to receive reply from switch.
and I have a another question. If I send "ofp_aggregate_stats_request", What should I use event ? should I make new event ? 
I think there isn't aggregate_stats event in src/etc/nox.json. 

Disposition linkload::handle_port_stats(const Event& e)
  {
    const Port_stats_in_event& psie = assert_cast<const Port_stats_in_event&>(e);

    vector<Port_stats>::const_iterator i = psie.ports.begin();

    while (i != psie.ports.end())
    {

      std::cout<<"rx_packets= "<<i->rx_packets<<std::endl;
      std::cout<<"rx_bytes= "<<i->rx_bytes<<std::endl;
      std::cout<<"tx_bytes= "<<i->tx_bytes<<std::endl;
........
........

00488|openflow-event|DBG:received stats reply from 00232033dbce
rx_packets= 612
rx_bytes= 44878
tx_bytes= 34546
rx_packets= 866




--------- ---------
: Murphy McCauley <jam...@nau.edu>
޴» : "Min-Hyup KANG" <kang-min-h...@hanmail.net>
 : "NOX-dev" <nox-dev@noxrepo.org>
¥: 2011 7 08 ݿ, 18 59 59 +0900
: Re: [nox-dev] send_stat_req
So most of what you posted is just the code from send_stat_req().  At the end, you have some new code starting with "of_port_stats psrep;".  Did you simply add that code to the end of send_stat_req()?  If so, it's not going to work.  The request is sent by send_openflow_command(), but the answer does not come back immediately.  psrep will not be filled in.  Instead, you need to wait for an event to be fired when you receive the response from the switch.  In linkload, this happens in the handle_port_stats() method, which iterates over Port_stats structures (basically the same as ofp_port_stats structures from the packing library).  Your code belongs somewhere in the loop in that function.

Hope that helps.

-- Murphy

On Jul 7, 2011, at 11:37 PM, Min-Hyup KANG wrote:

Hi all,

I am currently trying to get any statistics of running switch.
and I am re-writing some networkstate/linkload.cc as blow, but I think their value is "0" 
I need your help and any suggestion would help me.

Thanks,

void linkload::send_stat_req(const datapathid& dpid, uint16_t port)
  {
    size_t size = sizeof(ofp_stats_request)+sizeof(ofp_port_stats_request);
    of_raw.reset(new uint8_t[size]);

    of_stats_request osr(openflow_pack::header(OFPT_STATS_REQUEST, size),
                         OFPST_PORT, 0);
    of_port_stats_request opsr;
    opsr.port_no = OFPP_NONE;

    osr.pack((ofp_stats_request*) openflow_pack::get_pointer(of_raw));
    opsr.pack((ofp_port_stats_request*) openflow_pack::get_pointer(of_raw, sizeof(ofp_stats_request)));
    /*send request message*/
    send_openflow_command(dpi->second.datapath_id, of_raw, false);

    

    of_port_stats psrep;

    std::cout<<"RX_packets = "<<psrep.rx_packets<<std::endl;
    std::cout<<"RX_bytes = "<<psrep.rx_bytes<<std::endl;
    std::cout<<"TX_bytes = "<<psrep.tx_bytes<<std::endl;

./nox_core -i ptcp:6633 -v simplerouting linkload=interval=10
....
....
00096|linkload|DBG:Send probe to 123456abcdef
RX_packets = 0
RX_bytes = 0
TX_bytes = 0





Best Regards, 
Min-Hyup KANG
 

  _______________________________________________
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev







Best Regards, 
Min-Hyup KANG
 

 







Best Regards,
Min-Hyup KANG


_______________________________________________
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev

Reply via email to