1
votes

I'm doing a little socket programming and encountered a network behavior that I don't understand; I'm hoping someone can shed some light on what is happening.

I'm running Windows 7 Professional on a PC. I've got VMware installed and am running QNX Neutrino RTOS as a target within the VMware session. So the Windows PC is the host PC, and the guest OS is the QNX Neutrino RTOS. I configured the virtual machine to use a NAT network connection.

Ok, now on to the IP and interface configurations. Running 'ipconfig' on my Windows machine gives the following:

Windows IP Configuration

Ethernet adapter Local Area Connection:

  Connection-specific DNS Suffix  . :
  IPv4 Address. . . . . . . . . . . : 192.168.1.100
  Subnet Mask . . . . . . . . . . . : 255.255.255.0
  Default Gateway . . . . . . . . . : 192.168.1.1

Ethernet adapter VMware Network Adapter VMnet1:

  Connection-specific DNS Suffix  . :
  Link-local IPv6 Address . . . . . : fe80::c558:ae9f:e58e:e005%24
  IPv4 Address. . . . . . . . . . . : 192.168.184.1
  Subnet Mask . . . . . . . . . . . : 255.255.255.0
  Default Gateway . . . . . . . . . :

Ethernet adapter VMware Network Adapter VMnet8:

  Connection-specific DNS Suffix  . :
  Link-local IPv6 Address . . . . . : fe80::fce2:d22f:9ec:bd005%25
  IPv4 Address. . . . . . . . . . . : 192.168.248.1
  Subnet Mask . . . . . . . . . . . : 255.255.255.0
  Default Gateway . . . . . . . . . :

(** Other entries omitted for brevity **)

When I run 'ifconfig' on the VMware QNX system, I get the following:

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33192
        inet 127.0.0.1 netmask 0xff000000
ni0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        capabilities rx=7<IP4CSUM,TCP4CSUM,UDP4CSUM>
        capabilities tx=3f<IP4CSUM,TCP4CSUM,UDP4CSUM,TCP6CSUM,UDP6CSUM,TSO4>
        enabled=0
        address: 00:0c:29:04:00:ae
        media: Ethernet autoselect (1000baseT full-duplex)
        status: active
        inet 192.168.184.15 netmask 0xffffff00 broadcast 192.168.184.255
ni1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        capabilities rx=7<IP4CSUM,TCP4CSUM,UDP4CSUM>
        capabilities tx=3f<IP4CSUM,TCP4CSUM,UDP4CSUM,TCP6CSUM,UDP6CSUM,TSO4>
        enabled=0
        address: 00:0c:29:04:00:b8
        media: Ethernet autoselect (1000baseT full-duplex)
        status: active
        inet 192.168.248.15 netmask 0xffffff00 broadcast 192.168.248.255

So far, so good. Now, my socket program running on the VMware machine can successfully send a UDP message from VMware IP address 192.168.184.15 (port 65527) to the Windows PC 192.168.1.100 (port 2023), and my Windows socket program receives the message. However, when I try to send a UDP message from my Windows machine with IP address 192.168.1.100 (port 2044) to the VMware machine at 192.168.248.15 (port 2045), somehow the messages aren't reaching their destination. I did verify using Wireshark that the UDP message is on the wire with the expected IP source address and IP destination address, but even so, the socket program running on the VMware machine just doesn't receive the UDP message.

What I can do, though, is send a UDP message from Windows machine with IP address 192.168.248.1 to 192.168.248.15. When I do this, the socket program running on the VMware machine gets the UDP message. But what I'd like to know is why can't I successfully send a message from 192.168.1.100 to 192.168.248.15? Do I need to use some other type of network connection, other than NAT?

1

1 Answers

1
votes

NAT is the very reason why you are able to send and receive from your VMWare machine and not reverse.

The reason is that while sending, NAT is going to build a translation table containing the original IP address and port and then use a different IP address and port. When an answer comes, this table is consulted and the reply is delegated back to the original IP address and port.

If a message comes in for which there is no entry in the translation table, the message will be dropped. This is the same reason why you cannot send a message to say your neighbor if he is behind those typical home routers that also use NATPAT.

You can solve this by using a demiliterized zone or port forwarding. But how to do that in vm is unknown to me.