W5500 CircuitPython 驱动测试知多少?
W5500 CircuitPython 驱动测试知多少?
The document you provided is a technical document describing the implementation and operational testing of a Telnet (remote control) server using the W5500 Telnet controller and CircuitPython (Python for microcontrollers).
Here is the summary of the requested text and a summary of the core role of the W5500.
1. Key Summary of the Text
This text compares and analyzes two implementations of a Telnet server: one that directly controls hardware sockets and another that uses a library to abstract this approach.
* Two implementation versions provided
* `TelnetServerAlone.py`: A method that directly controls the W5500's hardware socket driver. Suitable for a deep understanding of hardware principles.
* `TelnetServerPool.py`: A method that uses the `SocketPool` abstraction layer, which is a standard socket API. The code is concise and development is convenient.
* Analysis of the W5500 `accept()` Mechanism
* A physical socket on the W5500 can only hold one state (such as LISTEN or ESTABLISHED) at a time.
* We demonstrate through source code and logs that, in order to receive continuous client connection requests, it operates using a 'Socket Number Swap' method. This method involves transferring the existing socket number for client communication the moment a connection is established, assigning a new hardware socket number, and returning to the LISTEN state.
* Special Characteristics of Socket 0
* Among the eight sockets on the W5500, Socket 0 is the only one that supports MAC RAW mode (for network packet capture). Therefore, it is designed so that the system driver does not preempt or reserve it. For this reason, the Telnet server described in this document skips Socket 0 and alternates between using Socket 1 and Socket 2.
* 2. The Role of the W5500 in This Article
The W5500 acts as an independent hardware TCP/IP protocol stack controller that relieves the burden on the MCU (in this case, the ESP32-S3) and provides high-performance wired network capabilities. Its specific roles are as follows:
* Hardware TCP/IP Protocol Stack Processing
* It directly processes network protocols such as TCP, UDP, IPv4, ARP, and ICMP using internal chip logic rather than software. This frees the MCU from complex network calculations.
* Provision of 8 Independent Hardware Sockets
* It provides a physical gateway capable of maintaining up to 8 independent network connections (concurrent connections) simultaneously.
* Internal Data Buffer Management (Built-in SRAM Memory)
* Equipped with a total of 16KB of internal SRAM as a transmit/receive (TX/RX) buffer, it reliably buffers Ethernet packet data with minimal consumption of the main MCU's memory. * State Machine-based Connection Management
* It automatically manages and notifies the current connection status (`CLOSED`, `INIT`, `LISTEN`, `ESTABLISHED`, `CLOSE_WAIT`, etc.) through the internal socket register (`Sn_SR`). The MCU can fully determine the network status simply by reading the value of this register.
* Support for Special Network Mode (MacRAW)
* It provides the ability to capture pure raw frames from the lower MAC layer directly through Socket 0, enabling not only communication control but also network monitoring analysis.
======================
제시해주신 글은 W5500 이태넷 컨트롤러와 CircuitPython(마이크로컨트롤러용 파이썬)을 활용해 Telnet(원격 제어) 서버를 구현하고 구동 테스트를 진행한 기술 문서입니다.
요청하신 본문의 요약과 W5500의 핵심 역할에 대한 정리입니다.
1. 본문 핵심 요약
본문은 하드웨어 소켓을 직접 제어하는 방식과 이를 추상화한 라이브러리를 사용하는 방식, 두 가지 형태로 Telnet 서버를 구현하여 비교·분석하고 있습니다.
* 두 가지 구현 버전 제공
* `TelnetServerAlone.py`: W5500의 하드웨어 소켓(Socket) 드라이버를 직접 제어하는 방식. 하드웨어 원리를 깊게 이해하는 데 적합합니다.
* `TelnetServerPool.py`: 표준 socket API 형태인 `SocketPool` 추상화 레이어를 사용하는 방식. 코드가 간결하고 개발이 편리합니다.
* W5500 `accept()` 메커니즘 분석
* W5500의 물리 소켓은 한 번에 하나의 상태(LISTEN 또는 ESTABLISHED 등)만 가질 수 있습니다.
* 지속적인 클라이언트 연결 요청을 받기 위해, 연결이 수립되는 순간 기존 소켓 번호를 클라이언트 통신용으로 넘겨주고, 새로운 하드웨어 소켓 번호를 할당받아 다시 LISTEN 상태로 만드는 '소켓 번호 교환(Socket Number Swap)' 방식으로 동작함을 소스코드와 로그를 통해 증명합니다.
* 소켓 0(Socket 0)의 특수성
* W5500의 8개 소켓 중 Socket 0은 유일하게 MAC RAW 모드(네트워크 패킷 캡처용)를 지원하므로 시스템 드라이버가 선점하거나 예약하지 않도록 설계되어 있습니다. 이 때문에 본문의 Telnet 서버는 소켓 0을 건너뛰고 소켓 1과 소켓 2를 교체해가며 사용합니다.
2. 이 글에서 W5500의 역할
W5500은 MCU(여기서는 ESP32-S3)의 부담을 덜어주고 고성능 유선 네트워크 기능을 제공하는 독립된 하드웨어 TCP/IP 프로토콜 스택 컨트롤러 역할을 합니다. 구체적인 역할은 다음과 같습니다.
* 하드웨어 TCP/IP 프로토콜 스택 처리
* 소프트웨어가 아닌 칩 내부 하드웨어 로직으로 TCP, UDP, IPv4, ARP, ICMP 등의 네트워크 프로토콜을 직접 처리합니다. MCU는 복잡한 네트워크 연산에서 자유로워집니다.
* 8개의 독립적인 하드웨어 소켓(Socket) 제공
* 동시에 최대 8개의 독립적인 네트워크 연결(컨커런트 연결)을 유지할 수 있는 물리적인 창구를 제공합니다.
* 자체 데이터 버퍼 관리 (SRAM 메모리 내장)
* 총 16KB의 내부 SRAM을 송수신(TX/RX) 버퍼로 탑재하고 있어, 메인 MCU의 메모리를 거의 소모하지 않고 이더넷 패킷 데이터를 안정적으로 완충(Buffering)합니다.
* 상태 머신(State Machine) 기반의 연결 관리
* 소켓 내부 레지스터(`Sn_SR`)를 통해 현재 연결 상태(`CLOSED`, `INIT`, `LISTEN`, `ESTABLISHED`, `CLOSE_WAIT` 등)를 스스로 관리하고 통보해 줍니다. MCU는 이 레지스터 값을 읽는 것만으로 네트워크 상태를 완벽히 파악할 수 있습니다.
* 특수 네트워크 모드(MacRAW) 지원
* 소켓 0번을 통해 하위 MAC 계층의 순수 원시 프레임(Raw Frame)을 그대로 캡처할 수 있는 기능을 제공하여, 통신 제어뿐만 아니라 네트워크 모니터링 분석까지 가능하게 합니다.

