willemmulder / Diont

Easy Service Discovery on Local Networks in 100% pure Javascript / Typescript
43 stars 6 forks source link

Issues recognizing in local network #1

Closed khuongduybui closed 8 years ago

khuongduybui commented 9 years ago

First of all let me admit that my setup is complex and hard to debug. I will try my best to describe.

I have a main router M, a wifi extender E, a basement router B, a Windows server W, a Windows laptop S, and a Linux VM L running on Hyper-V on W. L is connected to a Hyper-V virtual bridge on W; W is connected via Ethernet to E; E is connected wirelessly to M; M is connected via Ethernet to B; and S is connected wirelessly to B. To simplify it, the route is L -virtual-> W -wired-> E -wifi-> M -wired-> B -wifi-> S. B and E are both set to bridge mode, so all devices are in the same /24 subnet managed only by M.

I have this simple server.js file that are executed on both S and L.

var diont = require('diont')({'broadcast': true});

diont.on("serviceAnnounced", function(serviceInfo) {
    console.log("A new service was announced", serviceInfo.service);
    console.log("All known services", diont.getServiceInfos());
});

var service = {
    name: "server",
    port: "80"
};
diont.announceService(service);

If I start the script above on L then on S, S detects L but L doesn't detect S. If I start it on S then on L, nothing happens at all. I checked that no firewalls are blocking anything.

willemmulder commented 9 years ago

I'm not sure what the problem might be, but I do know that routers can have unexpected behaviour in what messages they will forward to the network and what messages they don't.

I just updated diont to support the manual setting of the TTL for Multicast (although you are using broadcast at the monent). Could you try using Multicast with a TTL of e.g. 10 and see how that works?

var diont = require('diont')({
    ttl: 10
});

Also, I've had problems when I put my PC to sleep and multicast wouldn't work properly after waking up. A fresh restart fixes those problems.

khuongduybui commented 9 years ago

I tried that but it didn't help either. What has been driving me nuts is that one can detect the other but not the opposite.

willemmulder commented 9 years ago

I'm afraid I'm out of ideas as well. Yet, it has probably something to do with packet-routing of a switch/hub somewhere. You might want to try a network-sniffer (e.g. WireShark) to see what's happening at the network-level and see if the right packets arrive at the right places...

kfatehi commented 9 years ago

@khuongduybui you ever figure this out? did you try using wireshark?

willemmulder commented 8 years ago

@khuongduybui could you try with the latest version and see if that makes any difference? Thanks!

khuongduybui commented 8 years ago

Sorry my network configuration has changed a lot since then so I cannot try again with the exact same setup, but I will give the latest version a try. At the very least I will test if it works with a laptop ---wifi---> router <---ethernet--- server configuration

willemmulder commented 8 years ago

@khuongduybui Thanks. Did you manage to try it yet? Please disable your firewall on your laptop while you're testing!

khuongduybui commented 8 years ago

I successfully tested Diont in the following (a bit tricky) setup:

laptop --wifi--> bridged_router --Ethernet--> main_router <-- Ethernet-- level-2-switch <-- Ethernet-- server

Detection worked with both multicast and broadcast options. I'm very happy šŸ‘

willemmulder commented 8 years ago

Excellent; thanks for retrying! If you have anything to share about what you're building, I'm happy to give it some exposure.

khuongduybui commented 8 years ago

I'm building Sniper, a distributed penetration testing platform, for Lunarline (https://lunarline.com/sniper). The project has multiple components that detect each other's presence on the (local) network using polo. I'm considering swapping it for Diont for better reliability. šŸ‘

willemmulder commented 8 years ago

Nice platform! Let me know if Diont worked for you; it would be great to have you in the list of references :+1:

khuongduybui commented 8 years ago

I switched to using Diont in latest version for Sniper (1.1.1). It is more reliable than polo.

willemmulder commented 8 years ago

Thanks for letting me know; cool! I have listed Sniper right at the top in the Readme :+1: