Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

echo_client sample return: Cannot connect to TCP remote (IPv6): 110 #24282

Closed
overheat opened this issue Apr 11, 2020 · 6 comments
Closed

echo_client sample return: Cannot connect to TCP remote (IPv6): 110 #24282

overheat opened this issue Apr 11, 2020 · 6 comments
Assignees

Comments

@overheat
Copy link
Contributor

overheat commented Apr 11, 2020

Describe the bug
I have tried echo_server sample, it works. And I leave it as the "server“,but got error after I start echo_client sample.

To Reproduce
Steps to reproduce the behavior:
Terminal 0
./net-setup.sh

Terminal 1

  1. west build -b native_posix samples/net/sockets/echo_server
  2. mv build build_server
  3. ./build_server/zephyr/zephyr.exe

Terminal 2

  1. west build -b native_posix samples/net/sockets/echo_client
  2. mv build build_client
  3. ./build_client/zephyr/zephyr.exe

Screenshots or console output
Screenshot_2020-04-10_20-38-47

Environment (please complete the following information):

  • OS: (Linux)
  • Toolchain (Zephyr SDK, ...)
  • Commit SHA 6540f81
@overheat overheat added the bug The issue is a bug, or the PR is fixing a bug label Apr 11, 2020
@overheat
Copy link
Contributor Author

I tried net-tools echo-server instead of echo_server sample, but it is the same issue.
FYI.

@jukkar
Copy link
Member

jukkar commented Apr 12, 2020

In your setup zephyr will get following IPv4 addresses 192.0.2.1 (server), 192.0.2.2 (client) and your Linux host will get 192.0.2.2. So there is IPv4 address conflict. Simplest solution is to set zeth in your Linux host to have some other address like 192.0.2.3. Just go to net-tools directory, copy zeth.conf to zeth3.conf, and then edit zeth3.conf and set the addresses correctly. Then do ./net-setup.sh -c zeth3.conf. Same thing applies to IPv6 addresses.

@overheat
Copy link
Contributor Author

overheat commented Apr 13, 2020

Update: linux server<->posix client case works, posix<->posix not.
I set up wireshark to monitor zeth interface, and still digging.

@jukkar Thanks. It make sense.
But I have tried posix<->posix configuration, which is server IP 192.0.2.1 and client IP 192.0.2.2, it return the same error number.

Please help us to check it.

@jukkar
Copy link
Member

jukkar commented Apr 15, 2020

I managed to get echo-server<->echo_client working using two native_posix processes. The procedure is a bit complicated but basic steps were already described in
samples/net/eth_native_posix/README.rst file.

Create net-tools/zeth-issue-24282-zeth1.conf file

# Configuration file for setting IP addresses for a network interface.
INTERFACE="$1"
HWADDR="00:00:5e:00:53:11"
IPV6_ADDR_1="2001:db8:100::2"
IPV6_ROUTE_1="2001:db8:100::/64"
IPV4_ADDR_1="198.51.100.2/24"
IPV4_ROUTE_1="198.51.100.0/24"
ip link set dev $INTERFACE up
ip link set dev $INTERFACE address $HWADDR
ip -6 address add $IPV6_ADDR_1 dev $INTERFACE nodad
ip -6 route add $IPV6_ROUTE_1 dev $INTERFACE
ip address add $IPV4_ADDR_1 dev $INTERFACE
ip route add $IPV4_ROUTE_1 dev $INTERFACE > /dev/null 2>&1

Create net-tools/zeth-issue-24282-zeth2.conf file

# Configuration file for setting IP addresses for a network interface.
INTERFACE="$1"
HWADDR="00:00:5e:00:53:22"
IPV6_ADDR_1="2001:db8:200::2"
IPV6_ROUTE_1="2001:db8:200::/64"
IPV4_ADDR_1="203.0.113.2/24"
IPV4_ROUTE_1="203.0.113.0/24"
ip link set dev $INTERFACE up
ip link set dev $INTERFACE address $HWADDR
ip -6 address add $IPV6_ADDR_1 dev $INTERFACE nodad
ip -6 route add $IPV6_ROUTE_1 dev $INTERFACE
ip address add $IPV4_ADDR_1 dev $INTERFACE
ip route add $IPV4_ROUTE_1 dev $INTERFACE > /dev/null 2>&1

Terminal 1:

./net-setup.sh -c zeth-issue-24282-zeth1.conf -i zeth.1

Terminal 2:

./net-setup.sh -c zeth-issue-24282-zeth2.conf -i zeth.2

Terminal 3:

sudo brctl addbr zeth-br
sudo brctl addif zeth-br zeth.1
sudo brctl addif zeth-br zeth.2
sudo ifconfig zeth-br up

Terminal 4:

west build -d build/server -b native_posix samples/net/sockets/echo_server -- -DCONFIG_NET_CONFIG_MY_IPV4_ADDR=\"198.51.100.1\" -DCONFIG_NET_CONFIG_PEER_IPV4_ADDR=\"203.0.113.1\" -DCONFIG_NET_CONFIG_MY_IPV6_ADDR=\"2001:db8:100::1\" -DCONFIG_NET_CONFIG_PEER_IPV6_ADDR=\"2001:db8:200::1\" -DCONFIG_NET_CONFIG_MY_IPV4_GW=\"203.0.113.1\" -DCONFIG_ETH_NATIVE_POSIX_DRV_NAME=\"zeth.1\" -DCONFIG_ETH_NATIVE_POSIX_MAC_ADDR=\"00:00:5e:00:53:01\" -DCONFIG_ETH_NATIVE_POSIX_RANDOM_MAC=n

Terminal 5:

west build -d build/client -b native_posix samples/net/sockets/echo_client -- -DCONFIG_NET_CONFIG_MY_IPV4_ADDR=\"203.0.113.1\" -DCONFIG_NET_CONFIG_PEER_IPV4_ADDR=\"198.51.100.1\" -DCONFIG_NET_CONFIG_MY_IPV6_ADDR=\"2001:db8:200::1\" -DCONFIG_NET_CONFIG_PEER_IPV6_ADDR=\"2001:db8:100::1\" -DCONFIG_NET_CONFIG_MY_IPV4_GW=\"198.51.100.1\" -DCONFIG_ETH_NATIVE_POSIX_DRV_NAME=\"zeth.2\" -DCONFIG_ETH_NATIVE_POSIX_MAC_ADDR=\"00:00:5e:00:53:02\" -DCONFIG_ETH_NATIVE_POSIX_RANDOM_MAC=n

Also if you have firewall enabled in your host, you need to allow traffic between zeth.1, zeth.2 and zeth-br interfaces.

@jukkar jukkar added question and removed bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug labels Apr 15, 2020
@jukkar
Copy link
Member

jukkar commented Apr 15, 2020

This is not a bug, it is just a matter of configuring the system to setup interfaces and route traffic between them.

@jukkar
Copy link
Member

jukkar commented May 8, 2020

FYI, I created #25136 that adds proper documentation for connecting multiple Zephyr instances together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants