Example #1
0
        /// <summary>
        /// Implements a function to be used in the Count Frame conversation processor.
        /// </summary>
        /// <param name="flowKey"></param>
        /// <param name="frames"></param>
        /// <returns></returns>
        private (string key, int frames, int octets, int ip, int tcp, int udp) CountFrames(FlowKey flowKey, System.Collections.Generic.IEnumerable <Memory <byte> > frames)
        {
            (int octets, int ip, int tcp, int udp) GetFrameSize(Memory <byte> memory)
            {
                var meta   = default(FrameMetadata);
                var bytes  = FrameMetadata.FromBytes(memory.Span, ref meta);
                var packet = PacketDotNet.Packet.ParsePacket((PacketDotNet.LinkLayers)meta.LinkLayer, bytes.ToArray());

                return(meta.OriginalLength,
                       packet.Extract <PacketDotNet.InternetPacket>() != null ? 1 : 0,
                       packet.Extract <PacketDotNet.TcpPacket>() != null ? 1 : 0,
                       packet.Extract <PacketDotNet.UdpPacket>() != null ? 1 : 0
                       );
            }

            var framesList = frames.ToList();

            // intentionally it is computed in this inefficient way to test
            // the implementated iteration over the input collection
            return(flowKey.ToString(), framesList.Count,
                   framesList.Sum(x => GetFrameSize(x).octets),
                   framesList.Sum(x => GetFrameSize(x).ip),
                   framesList.Sum(x => GetFrameSize(x).tcp),
                   framesList.Sum(x => GetFrameSize(x).udp)
                   );
        }
Example #2
0
 public bool Add(FlowKey flowkey)
 {
     lock (m_syncObject)
     {
         if (m_itemCount < m_blockCapacity)
         {
             m_filter.Add(flowkey.ToString());
             m_itemCount++;
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Example #3
0
        internal static string GetStream(this FlowKey key, string suffix)
        {
            var prefix = key.Type.IsSingleInstance ? key.ToString() : $"{key.Type}|{key.Id}";

            return($"{prefix}-{suffix}");
        }
Example #4
0
 public void SetFlowKey(FlowKey flowKey)
 {
     m_conversationModel.ConversationKey = flowKey.ToString();
 }
Example #5
0
 public override string ToString() =>
 Checkpoint.IsNone ? Key.ToString() : $"{Key}@{Checkpoint.ToInt64()}";
Example #6
0
 public override string ToString()
 {
     return(FlowKey.ToString());
 }
Example #7
0
 public bool Contains(FlowKey flowkey)
 {
     return(m_filter.Contains(flowkey.ToString()));
 }