18,25/20
Este repositório reúne os dois trabalhos práticos desenvolvidos no âmbito da unidade curricular de Redes de Computadores. O primeiro trabalho é dedicado ao estudo do protocolo IPv4, enquanto o segundo corresponde ao desenvolvimento do Redium, uma plataforma de captura e análise de tráfego de rede. Os enunciados, disponibilizados nos diretórios TP1/docs e TP2/docs, orientam a componente experimental e a implementação apresentada neste repositório.
O primeiro trabalho prático estuda o protocolo IPv4 em duas vertentes complementares. Na primeira parte, são analisados os datagramas IP e o processo de fragmentação através de capturas de tráfego geradas com traceroute e ping. A atividade permite observar o funcionamento do campo TTL, as mensagens ICMP de tempo de vida excedido, o cálculo do tempo de ida e volta e os campos de identificação, mais fragmentos e deslocamento usados na fragmentação e remontagem de datagramas. A componente realizada no CORE utiliza uma topologia com os hosts Lost e Found, ligados por uma rede de routers, enquanto a componente na máquina nativa permite observar os mesmos mecanismos numa interface de rede real.
Na segunda parte do primeiro trabalho, o foco passa para o endereçamento e o encaminhamento IP. A topologia CORE disponibilizada representa vários polos ligados através de fornecedores de serviço de Internet e de uma rede de trânsito, permitindo aplicar endereçamento CIDR, subnetting, rotas estáticas, rotas por omissão e sumarização de rotas. Ao longo da atividade são analisadas tabelas de encaminhamento com netstat -rn e ip route, identificados problemas de conectividade com ping, traceroute e Wireshark, e estudadas as diferenças entre os percursos de pedidos e respostas ICMP. Os enunciados destas duas partes encontram-se em RC-TP1-1P-Enunciado.pdf e RC-TP1-2P-Enunciado.pdf.
O segundo trabalho prático consiste na criação do Redium, um packet sniffer capaz de capturar, identificar, classificar e caracterizar o tráfego que circula numa rede. A aplicação foi concebida para funcionar tanto numa topologia controlada do CORE como numa interface real autorizada, seguindo uma abordagem de inspeção passiva. O seu objetivo é permitir observar os protocolos lecionados, os campos relevantes dos seus cabeçalhos e as interações características que estabelecem entre si.
A aplicação combina um motor de captura e análise desenvolvido em Python, com recurso à biblioteca Scapy, com uma interface web em Next.js, TypeScript e Tailwind CSS. O backend comunica diretamente com as interfaces de rede do sistema, processa os pacotes em tempo real e organiza a informação de protocolos como Ethernet, ARP, IPv4, ICMP, TCP, UDP, DNS, DHCP, HTTP, HTTPS, QUIC e SSH. Para além da listagem dos pacotes, o Redium permite aplicar filtros BPF, guardar capturas nos formatos JSON, CSV ou texto, calcular métricas de tráfego e apresentar uma hierarquia de protocolos semelhante à disponibilizada pelo Wireshark.
O sistema inclui ainda mecanismos de análise que associam pedidos ICMP às respetivas respostas para calcular o tempo de ida e volta, interpretam mensagens ICMP de erro para reconstituir percursos de traceroute e analisam datagramas IPv4 fragmentados. A interface web recebe os pacotes através de eventos em tempo real, permitindo selecionar a interface de captura, aplicar filtros, consultar estatísticas, observar os detalhes dos cabeçalhos e acompanhar a sessão de captura. Em alternativa, o modo de consola permite executar a captura diretamente no terminal e consultar o respetivo resumo após a sua conclusão. O enunciado do trabalho está disponível em RC-TP2-Enunciado.pdf.
Made with ❤️ by Diogo Azevedo, Bruno Magalhães & Vera Almeida
This repository brings together the two practical assignments developed for the Computer Networks course. The first assignment focuses on the study of the IPv4 protocol, while the second consists of the development of Redium, a network traffic capture and analysis platform. The assignment statements, available under TP1/docs and TP2/docs, describe the experimental work and the implementation included in this repository.
The first practical assignment studies IPv4 from two complementary perspectives. Its first part analyses IP datagrams and fragmentation through traffic captures generated with traceroute and ping. The activity makes it possible to observe the TTL field, ICMP time exceeded messages, round-trip time calculation and the identification, more fragments and fragment offset fields used to fragment and reassemble datagrams. The CORE component uses a topology with the Lost and Found hosts connected through a network of routers, while the native-machine component makes it possible to observe the same mechanisms on a real network interface.
The second part of the first assignment focuses on IP addressing and routing. The supplied CORE topology represents several sites connected through Internet service providers and a transit network, making it possible to apply CIDR addressing, subnetting, static routes, default routes and route summarisation. Throughout the activity, routing tables are inspected with netstat -rn and ip route, connectivity issues are identified with ping, traceroute and Wireshark, and the differences between ICMP request and reply paths are analysed. The statements for both parts are available in RC-TP1-1P-Enunciado.pdf and RC-TP1-2P-Enunciado.pdf.
The second practical assignment consists of Redium, a packet sniffer capable of capturing, identifying, classifying and characterising network traffic. The application was designed to run both in a controlled CORE topology and on an authorised real interface, following a passive inspection approach. Its purpose is to make the protocols studied in class, the relevant fields of their headers and their characteristic interactions observable.
The application combines a Python capture and analysis engine, built with Scapy, with a web interface developed in Next.js, TypeScript and Tailwind CSS. The backend interacts directly with the system network interfaces, processes packets in real time and organises information from protocols such as Ethernet, ARP, IPv4, ICMP, TCP, UDP, DNS, DHCP, HTTP, HTTPS, QUIC and SSH. Beyond packet listing, Redium supports BPF filters, capture logging in JSON, CSV or text formats, traffic metrics and a protocol hierarchy similar to the one provided by Wireshark.
The system also includes analysis mechanisms that associate ICMP requests with their replies to calculate round-trip time, interpret ICMP error messages to reconstruct traceroute paths and analyse fragmented IPv4 datagrams. The web interface receives packets through real-time events, allowing the user to select the capture interface, apply filters, inspect statistics, view header details and follow a capture session. Alternatively, the terminal mode runs captures directly in the console and presents a summary when the session is complete. The assignment statement is available in RC-TP2-Enunciado.pdf.
Made with ❤️ by Diogo Azevedo, Bruno Magalhães & Vera Almeida
[PT] Pode criar um ambiente virtual Python e instalar as dependências do backend e do frontend a partir da raiz do projeto. A captura numa interface real requer permissões de administrador e só deve ser realizada em redes autorizadas.
[EN] You can create a Python virtual environment and install the backend and frontend dependencies from the root of the project. Capturing on a real interface requires administrator permissions and must only be performed on authorised networks.
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
npm install[PT] A interface web requer a execução simultânea do backend Python e do frontend Next.js. O backend fica disponível, por omissão, em http://127.0.0.1:8765 e a aplicação web em http://localhost:3000.
[EN] The web interface requires the Python backend and the Next.js frontend to run simultaneously. By default, the backend is available at http://127.0.0.1:8765 and the web application at http://localhost:3000.
sudo venv/bin/python3 TP2/backend/web_backend.pynpm run dev[PT] O modo de terminal executa a captura diretamente na consola. Deve indicar a interface de rede através da opção -i e escolher pelo menos uma saída através de --live ou --log. Pode aplicar filtros BPF, limitar o número de pacotes ou a duração da captura e guardar os dados nos formatos JSON, CSV ou texto.
[EN] Terminal mode runs the capture directly in the console. You must specify a network interface with -i and select at least one output through --live or --log. You can apply BPF filters, limit the number of packets or the capture duration and save data in JSON, CSV or text formats.
sudo venv/bin/python3 TP2/backend/main.py -i en0 --livesudo venv/bin/python3 TP2/backend/main.py \
-i en0 \
-f 'icmp or udp port 53' \
--live \
--log captura.json \
--format json \
--count 100[PT] Pode gerar a versão de produção do frontend através do comando build, iniciar a versão compilada com start e verificar os tipos TypeScript com typecheck.
[EN] You can generate a production version of the frontend with build, start the compiled version with start and check TypeScript types with typecheck.
npm run build
npm run start
npm run typecheck