Esempio n. 1
0
        protected IEnumerable <Frame> GetFramesFromPcapAndDefragment(String pcapFileName)
        {
            var ipv4DefragmentationEngine =
                new Ipv4DefragmentationEngine(this._services.GetService <ILoggerFactory>().CreateLogger <Ipv4DefragmentationEngine>());
            var frames = new List <Frame>();

            foreach (var(packet, timestampTicks) in this.GetPacketsFromPcap(pcapFileName))
            {
                Frame frame;
                if (!(packet.PayloadPacket is IPPacket ipPacket))
                {
                    continue;
                }

                if (ipPacket is IPv4Packet ipv4Packet && Ipv4Helpers.Ipv4PacketIsFragmented(ipv4Packet))
                {
                    var(isDefragmentationSuccessful, defragmentedIpv4Packet, fragments) =
                        ipv4DefragmentationEngine.TryDefragmentFragments(FrameFactory.CreateFromIpPacket(ipv4Packet, timestampTicks));
                    if (!isDefragmentationSuccessful)
                    {
                        continue;
                    }

                    frame = FrameFactory.CreateFromDefragmentedIpPacket(defragmentedIpv4Packet, fragments);
                }
Esempio n. 2
0
        protected IEnumerable <Frame> GetFramesFromPcapAndDefragment(Uri pcapUri)
        {
            var ipv4DefragmentationEngine =
                new Ipv4DefragmentationEngine(this._services.GetService <ILoggerFactory>().CreateLogger <Ipv4DefragmentationEngine>());
            var frames     = new List <Frame>();
            var pcapLoader = this._services.GetService <IPcapLoader>();

            using (pcapLoader)
            {
                RawCapture rawCapture;
                pcapLoader.Open(pcapUri);
                while ((rawCapture = pcapLoader.GetNextPacket()) != null)
                {
                    Frame frame;
                    var   parsedPacket = Packet.ParsePacket(pcapLoader.LinkType, rawCapture.Data);
                    if (!(parsedPacket.PayloadPacket is IPPacket ipPacket))
                    {
                        continue;
                        ;
                    }

                    if (ipPacket is IPv4Packet ipv4Packet && Ipv4Helpers.Ipv4PacketIsFragmented(ipv4Packet))
                    {
                        var(isDefragmentationSuccessful, firstTimeStamp, defragmentedIpv4Packet) =
                            ipv4DefragmentationEngine.TryDefragmentFragments(
                                FrameFactory.CreateFromIpPacket(ipv4Packet, rawCapture.Timeval.Date.Ticks));
                        if (!isDefragmentationSuccessful)
                        {
                            continue;
                        }

                        frame = FrameFactory.CreateFromIpPacket(defragmentedIpv4Packet, firstTimeStamp);
                    }
Esempio n. 3
0
        private void OnStartProcessingRequest(CaptureProcessingRequest request)
        {
            this.Contractor            = this.Sender;
            this.SelfLoadBalancerActor = this.Self;
            this.CaptureInfo           = request.CaptureInfo;

            this.DistributionSw = new Stopwatch();
            this.TotalSw        = new Stopwatch();
            this.IPIpv4DefragmentationEngine =
                new Ipv4DefragmentationEngine(new AkkaLoggingAdapter <Ipv4DefragmentationEngine>(Context.GetLogger()));
            this.ReassemblerMessageProxy = new AskableReassemblerEntityMessageProxy(this.SelfLoadBalancerActor, this.ClusterProxy);

            this.Become(this.ProcessingCaptureBehaviour);
            this.TryStartProcessingAsync().PipeTo(this.Self);
        }
Esempio n. 4
0
        public CaptureTrackingActor(CaptureInfo captureInfo,
                                    IActorRef contractor,
                                    IL3ConversationTrackingActorFactory l3ConversationTrackingActorFactory,
                                    IL7ConversationStorageActorFactory l7ConversationStorageActorFactory)
        {
            this._captureInfo = captureInfo;
            this._contractor  = contractor;
            this._l3ConversationTrackingActorFactory = l3ConversationTrackingActorFactory;
            this._l7ConversationStorageActorFactory  = l7ConversationStorageActorFactory;
            this._ipv4DefragmentationEngine          =
                new Ipv4DefragmentationEngine(new AkkaLoggingAdapter <Ipv4DefragmentationEngine>(this._logger));

            this._logger.Info($"Started for {captureInfo.Uri.AbsoluteUri}");
            this._l7ConversationStorageActor = this.CreateL7ConversationStorageActor();

            this.Become(this.AnalysisBehavior);
        }
Esempio n. 5
0
        public CaptureTrackingActor(ICaptureInfo captureInfo,
                                    IActorRef contractor,
                                    IL3ConversationTrackingActorFactory l3ConversationTrackingActorFactory,
                                    IL7ConversationStorageActorFactory l7ConversationStorageActorFactory,
                                    IApplicationProtocolExportActorFactory applicationProtocolExportActorFactory)
        {
            this._logger.Debug($"Started for {captureInfo.Uri.AbsoluteUri}");

            this._captureInfo = captureInfo;
            this._contractor  = contractor;
            this._l3ConversationTrackingActorFactory = l3ConversationTrackingActorFactory;
            this._ipv4DefragmentationEngine          =
                new Ipv4DefragmentationEngine(new AkkaLoggingAdapter <Ipv4DefragmentationEngine>(this._logger));

            this._l7ConversationHandlerActors = this.CreateL7ConversationHandlerActors(l7ConversationStorageActorFactory, applicationProtocolExportActorFactory);

            this.Become(this.AnalysisBehavior);
        }
Esempio n. 6
0
        private IEnumerable <Frame> GetFramesFromPcap(Uri pcapUri)
        {
            var ipv4DefragmentationEngine = new Ipv4DefragmentationEngine(this._loggerFactory.CreateLogger <Ipv4DefragmentationEngine>());

            foreach (var(packet, timestampTicks) in this.GetPacketsFromPcap(pcapUri))
            {
                Frame frame;
                if (!(packet.PayloadPacket is IPPacket ipPacket))
                {
                    continue;
                }

                if (ipPacket is IPv4Packet ipv4Packet && Ipv4Helpers.Ipv4PacketIsFragmented(ipv4Packet))
                {
                    var(isDefragmentationSuccessful, defragmentedIpv4Packet, fragments) =
                        ipv4DefragmentationEngine.TryDefragmentFragments(FrameFactory.CreateFromIpPacket(ipv4Packet, timestampTicks));
                    if (!isDefragmentationSuccessful)
                    {
                        continue;
                    }

                    frame = FrameFactory.CreateFromDefragmentedIpPacket(defragmentedIpv4Packet, fragments);
                }