c# - How to get Multicast working in VirtualBox Guest OS on OSX -


im tearing hair out trying multicast work under virtual box osx host , win7 guests. multicast code in general works fine on real network of windows7 machines need able develop away it.

i read possible vb creating additional interfaces , 1 of them getting multicast packets couldnt repeat it, wrote below code try deal still fails in vb under internalnetwork or hostonly.

do need physically wired network (not wifi) work? or still doing else wrong?

edit: simplified code somewhat, still doesn't work.

networkinterface[] nics = networkinterface.getallnetworkinterfaces();  // netowrk info int defaultport = 5050; string localname = dns.gethostname(); iphostentry hostentry = new iphostentry(); hostentry = dns.gethostbyname(localname); ipaddress localaddress = hostentry.addresslist[0];  // create socket pair every interafce for(int i=0;i<nics.length;i++) {     #region make outgoing socket on interface      if (!nics[i].supportsmulticast)     {         continue; // skip 1     }     console.writeline("adding socket nic: " + nics[i].name);     // output interface     socket mcastsocket = new socket(addressfamily.internetwork, sockettype.dgram, protocoltype.udp);      // bind socket default ip address , port.     mcastsocket.bind(new ipendpoint(localaddress,4568+i));      // select adapter outgoing multicast packets );     int optionvalue = (int)ipaddress.hosttonetworkorder(i);      // multicast address - add membership : ");     ipaddress mcastaddress = ipaddress.parse("224.5.6.7");      // port number - multicast members listening : ");     int mcastport = 4567;     multicastoption mcastopt = new multicastoption(mcastaddress,localaddress);      // add membership group.     mcastsocket.setsocketoption(socketoptionlevel.ip, socketoptionname.addmembership, mcastopt);      // set required interface outgoing multicast packets.     mcastsocket.setsocketoption(socketoptionlevel.ip, socketoptionname.multicastinterface, optionvalue);      mcastsocket.connect(new ipendpoint(mcastaddress,4567));      // add transmission list     transmissionlist.add(mcastsocket);      #endregion }  #region make incoming socket on interface  // make socket read incoming multicast socket insocket = new socket(addressfamily.internetwork, sockettype.dgram, protocoltype.udp); insocket.bind(new ipendpoint(localaddress, 4567)); insocket.setsocketoption(socketoptionlevel.ip,                socketoptionname.addmembership, new multicastoption(multicastipaddr)); receptionlist.add(insocket); 

excerpt blog mentioned above

there may other ways, , not of these steps may necessary , worked me:

  1. download , install latest virtualbox oracle vm virtualbox download , install oracle virtualbox extension pack (might not necessary, did.)

  2. install copy of win7 virtualbox vm.

  3. clone vm create second machine. critically important: clone starts same mac address parent. messed me long time. go network settings->advanced clone , request assign new mac pressing circular arrows next mac. (this works when virtual machine powered down.)

  4. set network type setting both machines "internal network". (note isolate them host , internet.)

  5. on command line of host, enable dhcp (this may not absolutely necessary did. alternative manually config ip both machines). assuming used default internal network name of "intnet", can (all on 1 line):
    dhcpserver add --netname intnet --ip 10.10.10.1 --netmask 255.255.255.0 --enable --lowerip 10.10.10.10 --upperip 10.10.10.128

critically important: in environment created virtualbox there multiple nics claim multicast capable. however, lying. furthermore, because of way virtualbox assigns metrics, outgoing socket assigned liar happily gobble multicast messages , not send them on. solution open outgoing socket on every nic claims multicast capable , send outgoing packets of them. below code opens sockets , makes list. foreach on list when sending packet.

networkinterface[] nics =                      networkinterface.getallnetworkinterfaces();   // netowrk info   int defaultport = 5050;   string localname = dns.gethostname();    iphostentry hostentry = new iphostentry();   hostentry = dns.gethostbyname(localname);   ipaddress localaddress = hostentry.addresslist[0];    for(int i=0;i<nics.length;i++){             if (!nics[i].supportsmulticast)             {                 continue; // skip 1             }             console.writeline("adding socket nic: " + nics[i].name);             // output interface             socket mcastsocket = new                  socket(addressfamily.internetwork,                       sockettype.dgram, protocoltype.udp);              // bind socket default ip address , port.             mcastsocket.bind(new ipendpoint(localaddress,4568+i));              //select adapter outgoing multicast packets );              int optionvalue = (int)ipaddress.hosttonetworkorder(i);              //multicast address - add membership :              ipaddress mcastaddress = ipaddress.parse("224.5.6.7");              // port number - multicast members listening              int mcastport = 4567;             multicastoption mcastopt = new                 multicastoption(mcastaddress,localaddress);               // add membership group.             mcastsocket.setsocketoption(socketoptionlevel.ip,                  socketoptionname.addmembership, mcastopt);              // set required interface outgoing multicast packets.             mcastsocket.setsocketoption(socketoptionlevel.ip,                  socketoptionname.multicastinterface, optionvalue);              mcastsocket.connect(new                  ipendpoint(mcastaddress,4567));              // add transmission list             transmissionlist.add(mcastsocket);         } 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -