Question: Objective: Our primary objective is to capture and analyze network tra 8 ic in real - time a crucial task in network monitoring: 1 .
Objective: Our primary objective is to capture and analyze network traic in realtime a crucial task in network monitoring: Log detailed information about each packet, including source and destination addresses, protocol types, and packet sizes. Calculate and display a comprehensive set of network metrics to thoroughly understand your networks performance. Project Knowledge Requirements: The lab covers all the coding concepts required for this project, but this document highlights additional knowledge you may need. Adjust the lab knowledge to meet the project requirements. Project Components: Packet Capture and Parsing Utilize Scapy to capture packets at the Ethernet, IP TCP and UDP layers. Process and log essential packet details: Ethernet Layer: Source and destination MAC addresses. IP Layer: Source, destination IP addresses, and protocol used. TCPUDP Layers: Source and destination ports, packet size, and TCP flags Logging System Create a logging mechanism that stores each packet's details in a file networkevents.log with a timestamp. Log entries should include: Timestamp Protocol Ethernet IP TCP UDP Source and destination addresses Packet size Throughput Calculation Throughput measures the amount of data processed over a time interval, typically expressed in bits per second bps Data Collection: Track the total bytes of traic per protocol Ethernet TCP UDP Calculate the throughput by a set time interval eg seconds Throughput Formula: For each protocol, calculate throughput as: o Throughput bpsTotal Bytes Captured Time Interval Display these throughput results periodically. Latency Measurement Latency measures the time it takes for data to travel from the source to the destination. This project can approximate roundtrip latency by observing timestamps for responses in TCP or UDP packets. Latency Tracking: For each TCPUDP connection, capture the timestamp when a request packet is sent and the timestamp of the corresponding response packet. Store these timestamps in a dictionary, using unique identifiers for each connection. Latency Calculation: Calculate latency as the dierence between the response and request timestamps: o Latency msResponse Timestamp Request Timestamp Average these values to get the overall latency for each protocol. A snippet of a code that calculates throughput and latency, adjust as you see fit to work in your code: throughputdata defaultdictint latencydata exitflag threading.Event def updateeventdataprotocol srcaddr, destaddr, messagesize, timestamp: eventdataprotocolappendmessagesize throughputdataprotocol messagesize if protocol "Ethernet": uniquemacs.addsrcaddr else: uniqueips.addsrcaddr if protocol in TCP "UDP": connkey srcaddr, destaddr if connkey not in latencydata: latencydataconnkeystart: timestamp else: latencydataconnkeyend timestamp def calculatethroughputinterval: print
Throughput bps for protocol, bytescount in throughputdata.items: throughputbps bytescount interval printfprotocol: throughputbps:f bps throughputdataprotocol def calculatelatency: totallatency count for connkey, times in latencydata.items: if "start" in times and "end" in times: latency timesend timesstart totallatency latency count avglatency totallatency count if count else printf
Average Latency: avglatency:f ms MultiConnection Management Implement a TCP serverclient model to support multiple concurrent connections. Use threading to handle multiple connections, allowing realtime packet capture without interruption. Network Metrics Calculation Track metrics such as the total number of connections, unique IP addresses, and unique MAC addresses. Calculate protocolspecific metrics, including: Average packet size Total packets captured per protocol Rate of new connections connections over time Display these metrics in realtime, updating every seconds. RealTime Statistics Display and Analysis Display summarized statistics in realtime on the console. Every seconds, print an overview including: Number of connections per protocol Average packet size per protocol Number of unique IP and MAC addresses Results Visualization Using matplotlib use the data in networkevents.log and the results that youve got from calculating throughput and latency and produce these three graphs:Throughput Over Time: Create a line
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
