I am retrieving flow statistics using a _flow_stats_reply_handler as demonstrated in the Ryu Traffic Monitor example.
I print using the following:
file.write("\n{},{},{},{},{},{},{},{},{}"
                   .format(ev.msg.datapath.id,
                           stat.match['in_port'], stat.match['eth_src'], stat.match['eth_dst'],
                           stat.instructions[0].actions[0].port,
                           stat.packet_count, stat.byte_count,
                           stat.duration_sec, stat.duration_nsec))
Note the stat.packet_count.
How could I change this to count TCP packets?  I understand there is an ip_proto field and a tcp_flags field but I don't know how to code the match/count.
Edit: I have further investigated this and added a flow match to my request flow stats function:
def _request_stats(self, datapath):
    self.logger.debug('send stats request: %016x', datapath.id)
    ofp = datapath.ofproto
    parser = datapath.ofproto_parser
    cookie = cookie_mask = 0
    match = parser.OFPMatch(eth_type=0x0800)
    req = parser.OFPFlowStatsRequest(datapath, 0, ofp.OFPTT_ALL, ofp.OFPP_ANY, ofp.OFPG_ANY,
                                     cookie, cookie_mask, match)
    datapath.send_msg(req)
This unfortunately still doesn't work, any ideas as to why not would be greatly appreciated.