Exemple #1
0
        public static void ListenWintUnsafeClass()
        {
            Console.WriteLine("----- Listening with Unsafe wrapper class and Rx query -----");

            // this is the approach used by TraceEvent
            // http://blogs.msdn.com/b/dotnet/archive/2013/08/15/announcing-traceevent-monitoring-and-diagnostics-for-the-cloud.aspx
            // - It works in this case and provides better performance
            // - In general means the user must think which data to copy as the first step in the query
            //   For example in query that joins begin and end event, we can't stop ETW from overwriting the buffer before matching end arrives

            var instance = new RecvV4();

            _raw = EtwObservable.FromSession(Baseline.SessionName);
            var timeSource = new TimeSource <EtwNativeEvent>(_raw, e => e.TimeStamp);

            var received = timeSource.Select(e =>
            {
                unsafe
                {
                    instance.userData = (byte *)e.UserData.ToPointer();
                }
                return(instance);
            });

            var x = from window in received.Window(TimeSpan.FromSeconds(1), timeSource.Scheduler)
                    from stats in
                    (from packet in window
                     group packet by packet.daddr into g
                     from total in g.Sum(p => p.size)
                     select new
            {
                address = new IPAddress(g.Key).ToString(),
                received = total
            })
                    .ToList()
                    select stats.OrderBy(s => s.address);

            _subscription = x.Subscribe(v =>
            {
                //Console.WriteLine("--- {0} ---", DateTime.Now);
                //foreach (var s in v)
                //    Console.WriteLine("{0, -15} {1,-10:n0} ", s.address, s.received);
                //Console.WriteLine();
            });
            timeSource.Connect();

            Console.ReadLine();
            _subscription.Dispose();
            timeSource.Dispose();
        }
Exemple #2
0
        public static void ListenWintUnsafeClass()
        {
            Console.WriteLine("----- Listening with Unsafe wrapper class and Rx query -----");

            // this is the approach used by TraceEvent
            // http://blogs.msdn.com/b/dotnet/archive/2013/08/15/announcing-traceevent-monitoring-and-diagnostics-for-the-cloud.aspx
            // - It works in this case and provides better performance
            // - In general means the user must think which data to copy as the first step in the query
            //   For example in query that joins begin and end event, we can't stop ETW from overwriting the buffer before matching end arrives

            var instance = new RecvV4();

            _raw = EtwObservable.FromSession(Baseline.SessionName);
            var timeSource = new TimeSource<EtwNativeEvent>(_raw, e => e.TimeStamp);

            var received = timeSource.Select(e =>
                {
                    unsafe
                    {
                        instance.userData = (byte*) e.UserData.ToPointer();
                    }
                    return instance;
                });

            var x = from window in received.Window(TimeSpan.FromSeconds(1), timeSource.Scheduler)
                    from stats in
                        (from packet in window
                         group packet by packet.daddr into g
                         from total in g.Sum(p => p.size)
                         select new
                         {
                             address = new IPAddress(g.Key).ToString(),
                             received = total
                         })
                            .ToList()
                    select stats.OrderBy(s => s.address);

            _subscription = x.Subscribe(v =>
            {
                //Console.WriteLine("--- {0} ---", DateTime.Now);
                //foreach (var s in v)
                //    Console.WriteLine("{0, -15} {1,-10:n0} ", s.address, s.received);
                //Console.WriteLine();
            });
            timeSource.Connect();

            Console.ReadLine();
            _subscription.Dispose();
            timeSource.Dispose();
        }
Exemple #3
0
        public static void ListenWintUnsafeClass()
        {
            Console.WriteLine("----- Listening with Unsafe wrapper class and Rx query -----");

            var instance = new RecvV4();

            _raw = EtwObservable.FromSession(Baseline.SessionName);
            var timeSource = new TimeSource <EtwNativeEvent>(_raw, e => e.TimeStamp);

            var received = timeSource.Select(e =>
            {
                unsafe
                {
                    instance.userData = (byte *)e.UserData.ToPointer();
                }
                return(instance);
            });

            var x = from window in received.Window(TimeSpan.FromSeconds(1), timeSource.Scheduler)
                    from stats in
                    (from packet in window
                     group packet by packet.daddr into g
                     from total in g.Sum(p => p.size)
                     select new
            {
                address = new IPAddress(g.Key).ToString(),
                received = total
            })
                    .ToList()
                    select stats.OrderBy(s => s.address);

            _subscription = x.Subscribe(v =>
            {
                //Console.WriteLine("--- {0} ---", DateTime.Now);
                //foreach (var s in v)
                //    Console.WriteLine("{0, -15} {1,-10:n0} ", s.address, s.received);
                //Console.WriteLine();
            });
            timeSource.Connect();

            Console.ReadLine();
            _subscription.Dispose();
            timeSource.Dispose();
        }
Exemple #4
0
Fichier : RxRaw.cs Projet : 40a/Tx
        public static void ListenWintUnsafeClass()
        {
            Console.WriteLine("----- Listening with Unsafe wrapper class and Rx query -----");

            var instance = new RecvV4();

            _raw = EtwObservable.FromSession(Baseline.SessionName);
            var timeSource = new TimeSource<EtwNativeEvent>(_raw, e => e.TimeStamp);

            var received = timeSource.Select(e =>
                {
                    unsafe
                    {
                        instance.userData = (byte*) e.UserData.ToPointer();
                    }
                    return instance;
                });

            var x = from window in received.Window(TimeSpan.FromSeconds(1), timeSource.Scheduler)
                    from stats in
                        (from packet in window
                         group packet by packet.daddr into g
                         from total in g.Sum(p => p.size)
                         select new
                         {
                             address = new IPAddress(g.Key).ToString(),
                             received = total
                         })
                            .ToList()
                    select stats.OrderBy(s => s.address);

            _subscription = x.Subscribe(v =>
            {
                //Console.WriteLine("--- {0} ---", DateTime.Now);
                //foreach (var s in v)
                //    Console.WriteLine("{0, -15} {1,-10:n0} ", s.address, s.received);
                //Console.WriteLine();
            });
            timeSource.Connect();

            Console.ReadLine();
            _subscription.Dispose();
            timeSource.Dispose();
        }