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

Multiple hosts's IP need to be set the same subnet when communicating each other? #274

Open
liyingzhi opened this issue Apr 18, 2019 · 0 comments

Comments

@liyingzhi
Copy link

System info:

  • A host: ubuntu 16.04
  • B host: windows 7
  • A and B are connected by a switch.

Test1:

  • A host IP : 160.69.69.69
  • B host IP: 192.168.151.79
  1. The talker at A host multicasts a message named 'EXAMPLE' to the network. The listeners at A and B host both receive the message and enter the handle function.

  2. The talker at B host multicasts a message named 'EXAMPLE' to the network. The listener at B host can receive the message and enter the handle function. But the listener at A host never enter the handle function. Then i use Wireshark to monitor the network data at A host, the message from B host can be obtained by A host.

Test2:

  • A host IP : 192.168.151.167
  • B host IP: 192.168.151.79
  1. The talker at A host multicasts a message named 'EXAMPLE' to the network. The listeners at A and B host both receive the message and enter the handle function.

  2. The talker at B host multicasts a message named 'EXAMPLE' to the network. The listeners at A and B host both receive the message and enter the handle function.
    The situation at Test1_2 does not happen!

Is there a problem with my A host configuration? Or multiple hosts's IP need to be set the same subnet when communicating each other?

Thank you and looking forward to your reply.

Codes:

  • LCM data type defination
package lcm_std_msgs;
struct Header
{
int32_t seq;
int64_t stamp;
string frame_id;
}
  • talker:
#include<windows.h>
#include<iostream>
#include<stdio.h>
#include <lcm/lcm-cpp.hpp>
#include "lcm_std_msgs/Header.hpp"
int main(int argc, char **argv)
{
    int i;
    lcm::LCM lcm("udpm://239.1.1.255:7667?ttl=1");
    if (!lcm.good())
        return 1;
    lcm_std_msgs::Header my_data;
    my_data.seq = 1;
    my_data.stamp = 2;
    my_data.frame_id = "OK";
    for(i = 0;i <5; ++i)
    {
        lcm.publish("EXAMPLE", &my_data);
        Sleep(1);
    }
    return 0;
}
  • listener:
#include <stdio.h>
#include <iostream>
#include "lcm_std_msgs/Header.hpp"
#include <lcm/lcm-cpp.hpp>

using namespace std;

class Handler {
public:
	~Handler() {}
	void handleMessage(const lcm::ReceiveBuffer *rbuf, const std::string &chan,
		const lcm_std_msgs::Header *msg)
	{
		int i;
		printf("Received message on channel \"%s\":\n", chan.c_str());
		printf("  timestamp   = %lld\n", (long long)msg->seq);
		printf("  position    = (%f, %f, %f)\n", msg->stamp);
		cout << msg->frame_id << endl;
	}
};

int main(int argc, char *argv[])
{
	string address = "udpm://239.1.1.255:7667?ttl=1";
	int i;
	lcm::LCM  lcm(address) ;
	if (!lcm.good())
		return 1;
	Handler handlerObject;
	lcm.subscribe("EXAMPLE", &Handler::handleMessage, &handlerObject);

	while (0 == lcm.handle()) {
		// Do nothing
	}

	return 0;
}

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

No branches or pull requests

1 participant