在Linux上运行lwIP Echo Server的网络配置问题

时间:2017-09-08 19:44:29

标签: linux ubuntu lwip

我对使用lwIP IP Stack进行编程感兴趣。为了进行实验,我一直在尝试运行示例应用程序中包含的echo server。但是,我在设置内部网络配置以与服务器通信时遇到困难,我想找到我做错的事情。这是我到目前为止所做的。

首先,我使用sudo成功启动了echo服务器并将其设置为以172.16.0.1作为网关侦听172.16.0.2:

>>sudo ./echop -i 172.16.0.2 -m 255.255.0.0 -g 172.16.0.1
[sudo] password for user: 
Host at 172.16.0.2 mask 255.255.0.0 gateway 172.16.0.1
TCP/IP initialized.
SNMP private MIB start, detecting sensors.
Applications started.

程序成功启用tap0界面并启动网关:

>>ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80::a00:27ff:fe4c:f329  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:4c:f3:29  txqueuelen 1000  (Ethernet)
        RX packets 10860  bytes 10827195 (10.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8571  bytes 904790 (904.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 811  bytes 93113 (93.1 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 811  bytes 93113 (93.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

tap0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.16.0.1  netmask 255.255.0.0  broadcast 172.16.255.255
        inet6 fe80::49f:4fff:fe82:d8fb  prefixlen 64  scopeid 0x20<link>
        ether 06:9f:4f:82:d8:fb  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 129  bytes 14904 (14.9 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

我可以成功ping网关:

>>ping -c 5 172.16.0.1
PING 172.16.0.1 (172.16.0.1) 56(84) bytes of data.
64 bytes from 172.16.0.1: icmp_seq=1 ttl=64 time=0.028 ms
64 bytes from 172.16.0.1: icmp_seq=2 ttl=64 time=0.076 ms
64 bytes from 172.16.0.1: icmp_seq=3 ttl=64 time=0.097 ms
64 bytes from 172.16.0.1: icmp_seq=4 ttl=64 time=0.037 ms
64 bytes from 172.16.0.1: icmp_seq=5 ttl=64 time=0.039 ms
--- 172.16.0.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4086ms
rtt min/avg/max/mdev = 0.028/0.055/0.097/0.027 ms

但是,如果我尝试访问实际的echo服务器,则找不到路由:

>>ping -c 5 172.16.0.2
PING 172.16.0.2 (172.16.0.2) 56(84) bytes of data.
From 172.16.0.1 icmp_seq=1 Destination Host Unreachable
From 172.16.0.1 icmp_seq=2 Destination Host Unreachable
From 172.16.0.1 icmp_seq=3 Destination Host Unreachable
From 172.16.0.1 icmp_seq=4 Destination Host Unreachable
From 172.16.0.1 icmp_seq=5 Destination Host Unreachable

如果列出当前路线,似乎已经添加了路线:

>>route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway         0.0.0.0         UG    100    0        0 enp0s3
10.0.2.0        0.0.0.0         255.255.255.0   U     100    0        0 enp0s3
link-local      0.0.0.0         255.255.0.0     U     1000   0        0 tap0
172.16.0.0      0.0.0.0         255.255.0.0     U     0      0        0 tap0

为了确保,我尝试向echo服务器添加显式路由,但仍然找不到该路由:

>>sudo route add 172.16.0.2 dev tap0 gw 172.16.0.1
>>route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway         0.0.0.0         UG    100    0        0 enp0s3
10.0.2.0        0.0.0.0         255.255.255.0   U     100    0        0 enp0s3
link-local      0.0.0.0         255.255.0.0     U     1000   0        0 tap0
172.16.0.0      0.0.0.0         255.255.0.0     U     0      0        0 tap0
172.16.0.2      172.16.0.1      255.255.255.255 UGH   0      0        0 tap0

>>ping -c 5 172.16.0.2
PING 172.16.0.2 (172.16.0.2) 56(84) bytes of data.
From 172.16.0.1 icmp_seq=1 Destination Host Unreachable
From 172.16.0.1 icmp_seq=2 Destination Host Unreachable
From 172.16.0.1 icmp_seq=3 Destination Host Unreachable
From 172.16.0.1 icmp_seq=4 Destination Host Unreachable
From 172.16.0.1 icmp_seq=5 Destination Host Unreachable

--- 172.16.0.2 ping statistics ---
5 packets transmitted, 0 received, +5 errors, 100% packet loss, time 4094ms
pipe 4

我想帮助配置我的接口/路由,以便我可以尝试在端口7上配置的lwIP(1.30)echo服务器。使用版本1.30,因为我在较旧的设备上使用它。

操作系统信息:

>>uname -a
Linux ReSyst 4.8.0-59-generic #64-Ubuntu SMP Thu Jun 29 19:38:34 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

由于

0 个答案:

没有答案