How to test broadcast udp packets in Java on the same machine? - java

Can I perform a UDP broadcast packets on my machine? I don't have a network, i just have my cheap linux box. I want to have a server broadcasting a packet and two or more clients in the same machine receiving them. Is that possible? What IP do I use?
#gravyface gave me hope but I tried: 1) server sending to 127.255.255.255:54321 and clients listenting to 0.0.0.0:54321. 2) server sending to 127.255.255.255:54321 and clients listening to 127.0.0.1:54321. 3) server sending to 127.255.255.255:54321 and clients listening to 127.255.255.255:54321. None of them worked! :(
OBS: I am using REUSE_ADDR and SO_BROADCAST options.

I am able to confirm that 127.255.255.255 works on Linux (Ubuntu) and it does not work on Mac (Snow Leopard). If you ever find out how to do that on Mac let me know. :)

You can use virtual network adapters with different virtual addresses. For example in Windows you can use Microsoft Loopback or TUN/TAP in Linux.
Another solution would be to create an internal network with a Virtualization software such as VirtualBox but this would require a slight faster machine. If you could only afford(since it's a cheap box) a single Virtual Machine you could enable 1-4 network adapters that would allow you to bind your different UDP clients individually on each one of the virtual adapters of your virtual device.

Related

Java: multicast UDP socket example does not work

I'm learning how to use multicast UDP in Java language. I just studied the examples here.
However, after that I downloaded the codes and executed them, they work only if I run the multicast client and the multicast server in the same PC.
Hence, I tried to run multiple instance of the client and one instance of the server into a LAN network it did not work.
Finally, I deeply studied the code and take a look on the web and I found that it is correct.
My client is on GNU/linux ubuntu mate 16.04 LTS 64 bit while I tried to run other clients with same and different OS (also Windows).
I think that is not something related to OS configuration (on GNU/linux via ifconfig I saw multicast enabled), but it should be a problem of my local network. I configured the router in order to allow IGMP proxy and IGMP spoofing and I also disabled the firewall.
Then I used wireshark in order to capture the IGMP and UDP packages. I could see the client in my PC that send IGMP request to join the multicast group (address) and UDP data to the group while I could not receive any package.
What can I do?
My final goal is to test the code across Internet instead on my local LAN. Could an ISP block my multicast traffic?
Thank you
P.S.
I'm using reserved multicast IP
netstat -gn show that my network interface has joined the multicast group

Java bacnet4j communication over Network

I am able to get my virtual bacnet4j devices up and running. as I am running them on One windows machine i have used set of ip address 127.0.0.3-10.
I have a virtual Bacnet device which monitors other devices, which work fine when its on address 127.0.0.2 (or any other address starting with 127.0.0.* )
However I am now puuting it (Monitor) on Actual different windows machine running on IP say 192.168.2.3
My machines IP address on that Networks is say 192.168.2.2
Now The Monitor and devices won't recieve any broadcasted messagesfrom each other.
Any idea's if its achievable?
I have already tried using link service option within bacnet4j.
Now thinking of writing a bacnet router myself to achieve this. but wanted to confirm if What i am thinking is right? or is there a better way to achieve this communication.
The obvious: Any firewall activated?
Can you ping the other machine? Just to cover the bases.

How to stop routers blocking my applications network traffic

I have a application which listens for commands over IP.
The program works fine locally but when I try to send the application commands with a remote address it won't connect.
Is there anyway to get around the router blocking the inbound network traffic?
I'm using JAVA
Thanks.
If this is a pair of hosts you control, you can open the incoming port. You might also
succeed using a tunneling program such as Hamachi to effectively set up a VPN linking
the hosts.
If you're talking about a pair of unrelated computers (for example trying to set up
a connection for a game) there's no general solution that doesn't involve installing
and trusting additional software. The usual solution is to use a public server and
relay the traffic between the end points.

Communicating between two win2k guest Virtual boxes

I have not worked much on virtual machines and I need some help in resolving the virtual machine problem. Here is my set up.
I have two linux systems with Virtual Box VB1 and VB2 installed on each one.
Created two guest windows 2000 virtual machines in each of the virtual box.
Configured the ethernet adapter to use Bridge adapter for network connections.
I am running to run a corba server on one of the win2k guest on VB1 and running a client on one of the win2k guest on VB2. On running the client I get connection refused exception. This happens only when I run the server and client on two different virtual boxes.
"Connection refused" simply means that the client cannot open a TCP/IP connection to the server computer. That could be due to any of the following reasons:
The client is trying to connect to a server other than the one you expect
The server is not listening for incoming connections
Windows firewall is blocking incoming connections from the client
There is no TCP/IP connectivity between the machines at all (although it sounds like the DNS lookup happened correctly, otherwise you would have seen a "unknown host" error)
This is a networking issue, so to diagnose it you should try and increase the logging on your client to make sure it's connecting to the right host/port. If that doesn't help, increase the logging on the server to make sure it's listening on the correct port.
Also, if your CORBA application is using insecure IIOP then you could always turn on ethereal sniffing on your client box to see where it's connecting to.
Ok, I myself resolved the issue. The issue was with configuring the virtual machines. I had to use "Bridge Network Adapter" as a NIC card in each of the vm, earlier I was using NAT.. so this solved the problem.

BACNet plugin for Building Management System

I'm trying to get a BACNet scanner up on an Seimens server running the Apogee system with a BACNet interface. I've tried using BACNet4j put i get a port bind error on the LocalDevice object for test/Scan.java.
Does anyone know of any other libraries I could use or a reference to instructions for setting up a BACNet plugin to a building management system?
I have had the same problem before, i.e. the BACnet client needs to both send and receive from UDP port 47808. Since the BACnet server already uses that port to listen (and reply) my solution was to use a virtual IP (a bridge) so that my client runs on the same Ethernet card but with a different IP address. A bit convoluted, I know, but it works.
Whether or not the Apogee system supports virtual (or simply additional) network drivers is another question altogether. On my Linux and Windows machines I can run as many servers and clients as I need (I actually don't know what is the limit, I have run up to 5 servers and 3 clients without any problems).
Concerning the port bind error, you may have to configure your firewall because:
BACnet/IP is using UDP
the default port number is 47808 (0xBAC0)
Your issue might be the use of a (BACnet port #) socket that is already in-use; you have to ensure that it's not in exclusive-use - before binding to the socket, but also (slightly more) important, also ensure it's marked for reuse.
But unless you're listening for Who-Is broadcasts, I'd recommend listening for the (unicast) responses upon a different port #, e.g. 0xBAC1/47809, but still send upon the standard port # 0xBAC0/47808.

Categories