lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] How to get the example tcpecho working on Windows?


From: address@hidden
Subject: [lwip-users] How to get the example tcpecho working on Windows?
Date: Sat, 29 Apr 2023 16:04:42 +0800 (CST)

Hello! I want to test my lwip netconn tcp application on a Windows PC. I try using the example tcpecho app as a start point, but I fail to get it working. The following is what I've done.

1. `git clone https://git.savannah.nongnu.org/git/lwip.git` to get lwip version 2.2.0, commit d8d1e4a

2. Install the latest WinPcap 4.1.3 and the Developer Pack 4.1.2, set the environment variable `PCAP_DIR`, and copy the lwipcfg.h.example to lwipcfg.h in the exmaple_app folder according to ports/win32/readme.txt

3. `mkdir build && cd build && cmake .. -G"Visual Studio 17 2022" -DWPDPACK_DIR="%PCAP_DIR%" && cmake --build .`  
The build fails because of warnings in lwip apps/http and ports/win32. So the `/WX` compiler option in CMakeCommon.cmake is turned off to continue the build despite warnings. The build succeeds after this.

6. Change lwipcfg.h and lwipopt.h in example_app.  

In lwipcfg.h:
- #define LWIP_TCPECHO_APP 1
- #define LWIP_TCPECHO_APP_NETCONN
- Set `LWIP_PORT_INIT_IPADDR`, `LWIP_PORT_INIT_GW`, `LWIP_PORT_INIT_NETMASK`, `LWIP_MAC_ADDR_BASE` according to the result of `ipconfig -all`. The MAC belongs to the only (Wireless) NIC on the PC.
- Set `PACKET_LIB_ADAPTER_GUID` according to the result of `getmac`.

In lwipopt.h:
```c
#define LWIP_IPV6 0
#define LWIP_IGMP 0
#define LWIP_ICMP 0
#define LWIP_UDP 0
#define LWIP_RAW 0
#define PPP_SUPPORT 0
```
and define the tcp related DEBUG macros to LWIP_DBG_ON.

Running example_app starts the tcpecho server, but the server cannot be connected. I try connecting the server from the same machine and from other machine in the same LAN and both fail. In the debugger, the call to `netconn_accept` never returns.

I use other tools to set up the tcp server at the same port and that works well. So it's not the problem of firewall, hardware or OS.

Here's the output of example_app:

> netif: netmask of interface  set to 255.0.0.0  
> netif: GW address of interface  set to 127.0.0.1  
> netif_set_ipaddr: netif address being changed  
> netif: added interface lo IP addr 127.0.0.1 netmask 255.0.0.0 gw 127.0.0.1  
> Starting lwIP, local interface IP is 192.168.1.3  
> netif: netmask of interface  set to 255.255.255.0  
> netif: GW address of interface  set to 192.168.1.1  
> netif_set_ipaddr: netif address being changed  
> 0: NPF_{AE45CEF9-2F0C-495B-A748-9E88333B97DB}  
>     Desc: "Microsoft"  
> 1: NPF_{7662A739-A4C2-4AA6-914B-EC3090DA965A}  
>     Desc: "Microsoft"  
> Using adapter_num: 0  
> Using adapter: "Microsoft"  
> netif: added interface e0 IP addr 192.168.1.3 netmask 255.255.255.0 gw 192.168.1.1  
> netif: setting default interface e0  
> status_callback==UP, local interface IP is 192.168.1.3  
> tcpip_thread: PACKET 00007FF6DA7792A0  
> tcp_bind: bind to port 7  
> tcpip_thread: PACKET 00007FF6DA7792A0  
> tcpip_thread: PACKET 00007FF6DA7792A0  
> tcpip_thread: PACKET 00007FF6DA7792A0  
> tcpip_thread: PACKET 00007FF6DA7792A0  
> tcpip_thread: PACKET 00007FF6DA7792A0  
> tcpip_thread: PACKET 00007FF6DA779280  
> tcpip_thread: PACKET 00007FF6DA779260  
> tcpip_thread: PACKET 00007FF6DA779240  
> tcpip_thread: PACKET 00007FF6DA779220  
> tcpip_thread: PACKET 00007FF6DA779200  
> tcpip_thread: PACKET 00007FF6DA779200  
> tcpip_thread: PACKET 00007FF6DA779200  
> tcpip_thread: PACKET 00007FF6DA779200  

Use Wireshark to monitor the traffic between the tcp client ip and the machine running lwip example_app. I notice sometimes lwip example_app gets a packet but Wireshark doesn't, sometimes Wireshark gets a packet but lwip example_app doesn't. The SYN packet from the tcp client shows in Wireshark but not in lwip. It's weird because Wireshark uses the same WinPcap library as lwip does.

Please tell me what's wrong in my configuration and how I could get the example tcpecho working. Thanks!

Meng

reply via email to

[Prev in Thread] Current Thread [Next in Thread]