CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Sending and Detecting TCP/IP Broadcastss

    I'm Updating an application that uses UDP on TCP/IP to send messages back and forth.. At the moment i pickup the network address (Subnet = 10.0.0.0 Mask = 255.255.255.0) and send a small "hello" packet to all the ip addresses on the subnet, And reply to any "Hello" packets recived..

    But this is a bit of a tedious method.. (255 packets for 1 small subnet.) + i'm looking to try pickup users on a wider scale (Ie. Across multiple subnets).

    But i'm not able to send a broadcast (10.0.0.0 or 10.0.0.255) nor am i able to pickup and broadcasts (My server sends them out every so often)

    Can anyone help me with this..

    Thanks in advance...

    Gremmy....
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  2. #2
    Join Date
    Nov 2005
    Posts
    36

    Re: Sending and Detecting TCP/IP Broadcastss

    Hey Gremmy,

    I'm not sure if this will help you at all, but a while ago I had to write an application that had the ability to use Windows Messenger to send a broadcast message to users on our network.

    We have multiple subnets on our network as well, say for example
    10.0.0.0
    10.0.1.0
    10.0.2.0
    10.0.3.0
    In total we have about 7 different subnets that we use.

    The way I went about it, was to use Active Directory. My app runs through AD and picks out all the computer names. The only problem with this is, if you try to broadcast to that list, and one of the names that it picked up is either turned off, or non-existent anymore, it will error out. I guess you could always use On Error Resume Next, but that just didn't suit me here.

    I set it up to where I would ping each name as I went through AD... If I got a response... add it to the list. If not, don't. Simple as that.

    The app works flawlessy across multiple ranges, but you would have to have AD for this method.

    If you think this may help the cause, let me know and I'll post a zip

    But i'm not able to send a broadcast (10.0.0.0 or 10.0.0.255) nor am i able to pickup and broadcasts (My server sends them out every so often)
    I'm not sure how familiar you are with subnetting, so I'll through this out there too.

    Let's say we have a subnet mask of 255.255.255.248
    That should give us a total of 8 IP's right?? .... No
    In the subnet of 10.0.0.0 << this is a subnet ID ... pingable, but should not be the actual address of anything on your network.
    10.0.0.1 will be your default gateway, usually a router, switch, or something to that effect.
    so now 10.0.0.2-10.0.0.6 are all good IPs
    10.0.0.7 you would think should be added in there too, however this IP is saved for a broadcast channel. I'm not really sure of the use for this though, been in IT for about 8 years now and have never really seen a use for it.

    Ok back to your subnet and mask.

    By using 255.255.255.0 you are stating that you are going to be using every IP in that range. So in the subnet of 10.0.0.0
    10.0.0.0 will be your Subnet ID, and shouldn't return anything from a broadcast message. and the same goes for 10.0.0.255 as it will be your broadcast channel.

    I really hope this helps, because you have helped me so much on here

  3. #3
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Sending and Detecting TCP/IP Broadcastss

    Quote Originally Posted by Buddy008
    Hey Gremmy,

    I'm not sure if this will help you at all, but a while ago I had to write an application that had the ability to use Windows Messenger to send a broadcast message to users on our network.

    We have multiple subnets on our network as well, say for example
    10.0.0.0
    10.0.1.0
    10.0.2.0
    10.0.3.0
    In total we have about 7 different subnets that we use.

    The way I went about it, was to use Active Directory. My app runs through AD and picks out all the computer names.

    If you think this may help the cause, let me know and I'll post a zip

    I'm not sure how familiar you are with subnetting, so I'll through this out there too.
    Hey Buddy008...

    Thank you for the Info, And the basics of network topology.. But i'm teribly sorry to tell you that this wont help in my case.. I'm trying to get around the use of A.D. The application is planned to be used over the internet (Kind of a serverless IRC), But i'm starting out on a small network i set up at home.(Home Office)

    The main reason i'm using 255.255.255.0 as a mask is my server hold's 2 Ip's.. (.1 and .2) ( Was some thing i was testing about a year ago and just left it like that..) DHCP assigned (.3 - .199) ADSL Connetion (.200). and 5 permanent systems (.3, .7, .8, .9, .29) and every so often i connect 10-15 systems up for Datacapture.

    Buy using a Broadcast, i hope to be able to cut down the trafic to a singlepacket per msg, rather than repeating packets to each user..

    Small scale like this is still ok, but if your looking at 100 + users. thats a lot of wasted bandwidth..

    I do a lot of network instalations and a few of the customers are looking for Serverless Chat software, with File Transfer capabilitys.. (Bandwidth is always mentioned - Expecialy for the server... ) I wrote the linked proggy about a year ago, and it transferd all of the bandwidth usage away from the server, but for me it still uses too much, Also i cant automatical find users on another subnet, And i dont fancy making the proggy search all subnets by ip address.. (over 20 gig of bandwidth usage this way..) (tested it some time ago.. +- 10 min to complete)

    Thanks for you time ..

    Maybe we can fing a method to improve your app as well..

    Gremmy..
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  4. #4
    Join Date
    Nov 2005
    Posts
    36

    Re: Sending and Detecting TCP/IP Broadcastss

    The application that I wrote was kind of an update for one that we had previously. The guy who did the previous one is as close to a genious as I think I have ever been

    He wrote his version in C++, something of which I have no knowledge. But in talking to him about how long my version took because of the whole ping situation, he referenced something called "Threading".

    Where my application sends out the broadcast to every user, one at a time, his sent it out to everyone at once.

    I didn't really have enough time to look into threading, but you might want to check it out. If it's even possible in VB.

    Also, when I was researching ways of doing my app, I came across a few threads about a chat app. Almost designed to be like MSN messenger. That way used app to app broadcasting. I saw a few problems with that, that I didn't really like.
    1.) Of course you have to install the application on the clients machine
    2.) The application must always be running

    This probably wouldn't be that difficult, because you can push out the app any way you like, whether it be logon batch file, script, or an application like SMS or even a self created one like I made
    and then you could put it either in the "Run" registry key to run on startup, or the startup folder.

    That gets into how technically preficient your users are. would they be like "uhh what is this" and would you have to go into significant explanation of use or could they get along with minimal explanation.

    Also you would almost have to write some sort of master application for yourself, and then a minature version for the users.

    This is making me almost want to rewrite mine

    Ok so anyway, make it so that when a user logs on and there app fires, it sends computer/username to your master app. So you know if they are logged on or not. From this create a list of "User's Online". Then you could also be able to pick one person from the list to send a message to, or send a message to all.

    And on their app when they get a message, a window would pop up with the message, and they could reply or disregard, whatever they wanted.

    Well, let me know what ya think

  5. #5
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Sending and Detecting TCP/IP Broadcastss

    Quote Originally Posted by Buddy008
    The application that I wrote was kind of an update for one that we had previously. The guy who did the previous one is as close to a genious as I think I have ever been

    He wrote his version in C++, something of which I have no knowledge. But in talking to him about how long my version took because of the whole ping situation, he referenced something called "Threading".

    Where my application sends out the broadcast to every user, one at a time, his sent it out to everyone at once.

    I didn't really have enough time to look into threading, but you might want to check it out. If it's even possible in VB.
    Threading might help, But Where would this help in reducing bandwidth... How he did it is probably with one thread running the app, and another to actually send the network packets... the app returns immidiately while a background thread carries on sending the packets...

    Also, when I was researching ways of doing my app, I came across a few threads about a chat app. Almost designed to be like MSN messenger. That way used app to app broadcasting. I saw a few problems with that, that I didn't really like.
    1.) Of course you have to install the application on the clients machine
    2.) The application must always be running
    Requirment for mine.. so this is not a problem...

    This probably wouldn't be that difficult, because you can push out the app any way you like, whether it be logon batch file, script, or an application like SMS or even a self created one like I made
    and then you could put it either in the "Run" registry key to run on startup, or the startup folder.
    This will all be available via a setup pannel in the app... A definite Must...

    Also you would almost have to write some sort of master application for yourself, and then a minature version for the users.
    This is too much like a Server- Client... Mine needs to be Peer to Peer...

    This is making me almost want to rewrite mine

    Ok so anyway, make it so that when a user logs on and there app fires, it sends computer/username to your master app. So you know if they are logged on or not. From this create a list of "User's Online". Then you could also be able to pick one person from the list to send a message to, or send a message to all.

    And on their app when they get a message, a window would pop up with the message, and they could reply or disregard, whatever they wanted.

    Well, let me know what ya think
    I do like what your saying here... Looks like you have a very simmular need as i do. (Can you Read minds??????)..

    Also Just a note, I do know how to do all of this, But i would like to use broadcasting, and I'd like to start there before i do all of the above....


    Gremmy...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  6. #6
    Join Date
    Nov 2005
    Posts
    36

    Re: Sending and Detecting TCP/IP Broadcastss

    Since I don't really know anything about threading, I can't say exactly how he did it.

    What I do know, is this isn't related to processor threading. It's something different. and for bandwidth, it will be a good bit at first, but better than constant load. Oh yeah and our network is about 500 or so.

    Next...

    Maybe I'm getting confused with the term broadcasting. Probably because I'm thinking on how it relates to my app.

    So, do you mean like a "net send" type broadcast to your entire domain or something different.

    I do like what your saying here... Looks like you have a very simmular need as i do. (Can you Read minds??????)..
    hehe I wish

    Something that just occured to me lol... I should probably take a look at your app to see where you are going with it.

  7. #7
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: Sending and Detecting TCP/IP Broadcastss

    Gremlin.
    I don't think you will be able to use BroadCasting in your app as you want it. The "Broadcast" you are thinking of, don't generally deal with TCP/IP like you want. For example, a DHCP broadcast does use UDP but there is no IP address. The DHCP server sends the information back to the MAC address. Same goes for BOOTP. This would be my solution to your problem. Set up a "Server" that is only available for user/IP/Computername requests. On your server put an application that responds on a port but only gives a list of user/computer name IP addresses. Set up your client so that when it gets installed, it attempts to get information from a "Server" address (low number 1,2) then if it can't find a server, have it walk the IP address up until it finds another client application on the LAN. If it finds one, it requests the "Server" information(where to find it). If there are currently no servers on the lan, then designate one of the client apps to be the server.

    There are a few nice things you can do with this. For example, all of the clients could technically be servers. And you could have all the clients vote for who the server is. Maybe to cut down on network traffic, you would have the server be the lowest IP address on the network. That way when you walk UP the network IP address, you will always reach the server quickly.

    Another thing is have the program monitor the current Memory/CPU usage. If it gets to high on a system, then your application designates the next best known server to take over. Or if a new systems comes on line with a lower IP, then it takes over as the server, and the next request from a client to the last server get responded to with "I AM NO LONGER THE SERVER, CHECK 192.168.0.7"

    It's a lot of programming, but there is a lot of redundancy built to so even if all the computers are shut off, they will eventually get back online with the right computer being the new "Server".

    Anyway, I hope I haven't babbled to much and you get my drift.

  8. #8
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Sending and Detecting TCP/IP Broadcastss

    Quote Originally Posted by sotoasty
    Gremlin.
    I don't think you will be able to use BroadCasting in your app as you want it. The "Broadcast" you are thinking of, don't generally deal with TCP/IP like you want. For example, a DHCP broadcast does use UDP but there is no IP address. The DHCP server sends the information back to the MAC address. Same goes for BOOTP.
    If the broadcast stops at the Mac Address and does not layer up to the IP, then there is no way to pick it up.. Pitty...
    Quote Originally Posted by sotoasty
    This would be my solution to your problem.......
    Set up your client so that when it gets installed, it attempts to get information from a "Server" address (low number 1,2) then if it can't find a server, have it walk the IP address up until it finds another client application on the LAN. If it finds one, it requests the "Server" information(where to find it). If there are currently no servers on the lan, then designate one of the client apps to be the server........
    Maybe to cut down on network traffic, you would have the server be the lowest IP address on the network. That way when you walk UP the network IP address, you will always reach the server quickly.....
    If a new systems comes on line with a lower IP, then it takes over as the server.......
    It's a lot of programming, but there is a lot of redundancy built to so even if all the computers are shut off, they will eventually get back online with the right computer being the new "Server".
    Wow you have spent a lot of time to work this one out... And i tell you what.... It looks good.. I like the redundency bit's... It's Server-Client on a Peer to Peer .... Network Responcible. (Bandwidth Saver.) And a well though out concept over all...

    The server Part is not too complicated.. (Small online DB <--- Dont even need a pysical DB.. ) And has no user interaction..

    The client Part is a Quick Query to the server... (Again A small online DB.. <-- Can share with the Server Part..) Maybe Can enter a remote Network address to search for local 'server' on that subnet..

    And then Peer To Peer for the Chat and Transfers......

    Hmmm... I'm just thinking ... Using Active X for each of the Sections and wrap them up in a small App...


    Quote Originally Posted by Buddy008
    So, do you mean like a "net send" type broadcast to your entire domain.
    Yes that's what i'm looking for... But looks like a no go...


    Thanks

    Gremmy.....






    Anyway, I hope I haven't babbled to much and you get my drift.[/QUOTE]
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  9. #9
    Join Date
    Nov 2005
    Posts
    36

    Re: Sending and Detecting TCP/IP Broadcastss

    Actually I don't think the "net send" type would have been good for you in your situation. Net send is kind of self reliant... a "Window's" based messenger service.

    Since your installing apps on all of your network clients/servers whichever, and those apps will be talking to each other, the better method would be what I believe you are taking on. Sending a message directly to your app through your app

    And of course you already know that you can modify this msg window to look however you want it too, much better than the default "Window's" messenger net send utility.

    I only hope that you post us a final version of this so we can check it out

    Good luck Gremmy !!

    Buddy

  10. #10
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Sending and Detecting TCP/IP Broadcastss

    I've already started to rewrite the original App.. OM MY GOODNESS.. I really coded badly when i wrote that....

    When i got a workable something i will post for you to, [i]Rip my code appart[i] test it.. (And i dont get offended by this, I preffer it as a test method)

    My Hex-Editor was written this way, Still finding a few little bugs in it, but it works well..

    Part 1 -- Server-Client for user list is 1/2 Complete...

    Will let ya know..

    Gremmy...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured