Hi,

 > I’m not very familiar with the coding language and am not sure how to
 > code this beyond

I tried create a source image.
Please refer to the following.

e.g.)
$ git diff
diff --git a/ryu/app/simple_switch_13.py b/ryu/app/simple_switch_13.py
index 3e7c598..f0fd59b 100644
--- a/ryu/app/simple_switch_13.py
+++ b/ryu/app/simple_switch_13.py
@@ -14,11 +14,14 @@
  # limitations under the License.

  from ryu.base import app_manager
+from datetime import datetime
  from ryu.controller import ofp_event
  from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER
  from ryu.controller.handler import set_ev_cls
  from ryu.ofproto import ofproto_v1_3
  from ryu.lib.packet import packet
+from ryu.lib.packet import tcp
+from ryu.lib.packet import ipv4
  from ryu.lib.packet import ethernet
  from ryu.lib.packet import ether_types

@@ -88,6 +91,26 @@ class SimpleSwitch13(app_manager.RyuApp):
          dpid = datapath.id
          self.mac_to_port.setdefault(dpid, {})

+        pkt_ip = pkt.get_protocol(ipv4.ipv4)
+
+        src =  None
+        ts_val = None
+        ts_ecr = None
+        if pkt_ip:
+            src = pkt_ip.src
+
+        pkt_tcp = pkt.get_protocol(tcp.tcp)
+
+        if pkt_tcp and pkt_tcp.option is not None:
+            for op in pkt_tcp.option:
+                if op.kind == tcp.TCP_OPTION_KIND_TIMESTAMPS:
+                    ts_val = op.ts_val
+                    ts_ecr = op.ts_ecr
+
+        now = datetime.now().strftime('%Y/%m/%d %H:%M:%S')
+
+        self.logger.info("#### %s src:%s ts_val:%s ts_ecr:%s",
+                         now, src, ts_val, ts_ecr)
          self.logger.info("packet in %s %s %s %s", dpid, src, dst, in_port)

          # learn a mac address to avoid FLOOD next time.



The following is the output image

   #### 2016/07/20 10:48:05 src:10.0.0.1 ts_val:1394015 ts_ecr:0



On 2016年07月14日 03:41, Bryan Martin wrote:
> Good afternoon everyone,
>
> I am trying to monitor all TCP traffic in a network from the controller.
> What I want is to be able to collect  all TCP traffic on my network to
> include time of collection, source IP, and source TCP timestamp.
>
> I’m not very familiar with the coding language and am not sure how to
> code this beyond
>
> pkt_tcp = pkt.get_protocol(tcp.tcp)
>
>         if pkt_tcp:
>
> Any help would be greatly appreciated.  Thank you!
>
>
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity planning
> reports.http://sdm.link/zohodev2dev
>
>
>
> _______________________________________________
> Ryu-devel mailing list
> Ryu-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to