CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13
  1. #1
    Join Date
    Apr 2005
    Posts
    221

    ipconfig information

    When I do an ipconfig at a DOS prompt on my computer it lists two different IP addresses. One is described as the "Ethernet adapter Local Area Connection" and the other is listed at the "PPP adapter". WHat is the difference bwteen the two? Which one is actuallythe IP addresses with which my computer is listed "on" the Internet? Or are both of them listed as such? Can my computer be accessed from other computers on the Internet via EITHER of these IP addressess?

    - Roger Garrett

  2. #2
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: ipconfig information

    Quote Originally Posted by RogerGarrett
    Can my computer be accessed from other computers on the Internet via EITHER of these IP addressess?
    Probably not, at least not with "typical" setups today.

    A typical setup looks like this:

    Internet <--> modem/cable-box <--> router/switch <--> multiple workstations in a LAN

    Each of the workstations will have a non-routable IP address, like 10.10.aaa.bbb or 192.168.aaa.bbb. None of them can be reached from the Internet by that address.

    To reach a workstation from the Internet, you need to do two things: use the IP address of the modem, and configure the router for port forwarding. These are both network architecture issues.

    See "Using UPnP for Programmatic Port Forwardings and NAT Traversal" at http://www.codeproject.com/internet/PortForward.asp

    Mike

  3. #3
    Join Date
    Apr 2005
    Posts
    221

    Unhappy Re: ipconfig information

    Mike,

    Thank you for the reply.

    But I'm still confused.

    My situation is NOT one of multiple workstations. I have two SEPARATE computers (not connected together by any LAN) and each is connected to the Internet separately, one by way of a cable modem and one by way of a dialup modem.

    When I do the ipconfig on the cable-connected computer it shows two IP address, one listed as the "Ethernet adapter Local Area Connection" and the other as the "PPP adapter".

    I've written two MFC applications, a server program and a client program. The server program, running on the cable-connected computer, uses gethostname() and gethostbyname() in order to retrieve the URL of the local machine. The URL that those functions return is the one given as the "Ethernet adapter Local Area Connection" (via the ipconfig program). I then use that same URL number on the client program, running on the dialup-connected computer in order to connect to the host computer.

    It has been running this way perfectly for over a year.

    But it recently stopped working.

    I've also been running (completely separately from my host/client programs) a commercial application called AnyPlace, which lets you connect between computers for remote control of another computer. That Anyplace program appears to use the URL number as specified for the "PPP adapter", NOT the URL as specified for the "Ethernet adapter Local Area Connection" .

    So I'm confused. WHICH of the two URLS is the one that is "visible" on the internet and is therefore the one that I should use when attempting to connect to it via the Internet?

    - Roger Garrett

  4. #4
    Join Date
    Feb 2002
    Posts
    4,640

    Re: ipconfig information

    Quote Originally Posted by RogerGarrett
    My situation is NOT one of multiple workstations. I have two SEPARATE computers (not connected together by any LAN) and each is connected to the Internet separately, one by way of a cable modem and one by way of a dialup modem.

    When I do the ipconfig on the cable-connected computer it shows two IP address, one listed as the "Ethernet adapter Local Area Connection" and the other as the "PPP adapter".
    How is your cable modem connected to the computer? USB? Ethernet? PCI (i.e. internal)?

    Viggy

  5. #5
    Join Date
    Apr 2005
    Posts
    221

    Re: ipconfig information

    It apears to me that it's an ethernet cable. It's definitely not a USB cable, and it is defintely not an internal model, so I gues it's reasonable to conclude that it's an ethernet cable.



    - Roger

  6. #6
    Join Date
    Feb 2002
    Posts
    4,640

    Re: ipconfig information

    Then my guess would be that the computer is using the ethernet adapter to connect to the Internet.

    Viggy

  7. #7
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: ipconfig information

    To discover your external IP address (i.e., the one that the Internet sees), open a brownser to a site like www.whatismyip.com . These sites tell you the IP address that they see you connecting from.

    Whether this is the same as the PPP address or the ethernet address, or whether it's some other address entirely, is anyone's guess. It definitely will vary from computer to computer, based on the network architecture by which the computer connects to the Internet, so if you are looking for a simple rule that you can apply in futeure cases, there si none.

    Mike

    PS: Give us the actual IP addresses that ipconfig is giving to you, and we might be able to tell you more. For privacy, you can mask the last dotted number with xxx or something

  8. #8
    Join Date
    Apr 2005
    Posts
    221

    Re: ipconfig information

    Mike,

    Thank you for that link to whatismyip.com. That confirmed that the IP that is "visible" on the Internet is the one that shows up as the PPP adapter IP when I use ipconfig on my computer, as opposed to the Ethernet adapter IP on my coputer.

    But that is incredibly odd. For over a year now I have been using the Ethernet adapter IP while testing the client/server propgrams that I am developing. That Etehrnet adapter IP is also the IP that is returned when I call the gethostname() and gethostbyname() methods from within my MFC application program. And that Ethernet adapter IP has worked perfectly fine for all this time, until last week, when it stopped working.

    So I am baffled.

    For my application I absolutely cannot use the PPP adapter IP since that is different each and every time that the computer is started up. The Ethernet adapter IP changes maybe once every three or four months, which is acceptible. So I am at a loss as to how to proceed at this point.

    Any advice would be greatly appreciated.

    - Roger Garrett

  9. #9
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: ipconfig information

    Set up an account with a dynamic DNS (DDNS) service. There are many free ones listed at Google Directory under Computers > Software > Internet > Servers > Address Management > Dynamic DNS Services at http://directory.google.com/Top/Comp..._DNS_Services/ and you should be able to locate more by Googling on "free "dynamic DNS server" " (without the outer quotes but use the inner quotes for a better search).

    These services will allow you to establish a "friendly" name like RogerGarrett.yi.org from the DDNS provider. The name is technically called a "third level" domain name (since the "important" information is found in the third field from the right).

    To use it, the listening computer must install a helper application which periodically contacts the DDNS service to thereby allow the service to determine the listener's IP address. Thus, even if the IP address changes often, the DDNS service will nearly always have the most current and correct IP address. You can therefore use the PPP address, even if it changes often.

    With this service, anyone on the Internet can reach the listener using the friendly name alone. The second level of the friendly name directs the DNS query to the DDNS service, and it's the responsibility of the DDNS service to map the third level of the friendly name to your IP address.

    Mike

  10. #10
    Join Date
    Apr 2005
    Posts
    221

    Re: ipconfig information

    Mike,

    Thanks for the reply.

    I don't think that your suggestion of the Dynamic DNS is a feasible solution to this particular application. My server and client programs will potentially be used by hundreds of thousands of users in a peer-to-peer application. A large perentage of them will be running the server software so that other users can acces them through the cleint programs.

    I think that the bottom line is how can an MFC program determine what the IP address is for the computer that its running on. The gethostname() and gethostbyname() functions return the wrong IP address. On my computer, for example, those functions end up returning the Ethernet IP address, when in fact the IP address that is "visible" to the Internet for my computer is the one given by the PPP adapter. I need to somehow get the IP address that is visible to the Internet. I already have a means of providing that IP address to the client programs running on the other users' computers. But it seems that gethostname() and gethostbyname() are not giving me the correct IP address that I need.

    So, how can I determine the correct IP address, the one that's actually visible to the rest of the Internet, from within an MFC application program?

    - Roger Garrett

  11. #11
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: ipconfig information

    Most people connect programmatically with a site like www.whatismyip.com, and then parse the results.

    Be prepared for extreme user confusion when deploying a peer-to-peer application. Such applications require significant work (as you are discovering) in the correct configuration of each user's network/router. For example, since the cable modem on your computer is connected to the computer with an ethernet cable, it's fairly clear that the modem has a built-in router. The router will need to be configured to port-forward incoming connections to your computer, or else an incoming connection request to the router will be ignored by the router, thereby defeating the peer's connection request. And, each different user will have a different configuration, necessitating a different solution tailored for each different user's configuration.

    See "Using UPnP for Programmatic Port Forwardings and NAT Traversal" for one solution to port-forwarding: http://www.codeproject.com/internet/PortForward.asp

    Mike

  12. #12
    Join Date
    Apr 2005
    Posts
    221

    Re: ipconfig information

    Mike,

    I really appreciate the information you've provided.

    This is pretty frustrating. I've been working on this program for quite some time and the test configuration that I've been using has been working just fine up until last week, when it started giving me problems in connecting between computers, each separately connected to the Internet. Those problems prompted my posting here, and now I learn of these additional difficulties, that I hadn't previously encountered.

    I have to wonder how a program like Kazaa works, where each user can set it up so that some of his files become accessible to other Kazaa users, effectively (as far as I can tell) making the user's computer act like a server to other user's computers. I don't think that each user has to explicitly configure his computer/network/router specifically for this. Rather, it appears that all the Kazaa user has to do is tell the Kazaa program what files to make accessible and it is the Kazaa program that sets things up appropriately. That's what I have been assuming in the design of my own P2P application, that my application itself can do all the work of setting itself up as a server.

    Can you recommend any book that thoroughly addresses these issues and describes how to set these kinds of P2P applictions up, ideally in an MFC, dialog-based application? I know that's asking quite a bit of a book, but acquiring all the necessary information piecemeal, from whatever other books, articles, and web sites that I can find has been a particularly grueling task.

    - Roger Garrett

  13. #13
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: ipconfig information

    Quote Originally Posted by RogerGarrett
    I have to wonder how a program like Kazaa works, where each user can set it up so that some of his files become accessible to other Kazaa users, effectively (as far as I can tell) making the user's computer act like a server to other user's computers. I don't think that each user has to explicitly configure his computer/network/router specifically for this. Rather, it appears that all the Kazaa user has to do is tell the Kazaa program what files to make accessible and it is the Kazaa program that sets things up appropriately. That's what I have been assuming in the design of my own P2P application, that my application itself can do all the work of setting itself up as a server.
    I think it's a fair characterization to view programs like Kazaa as something that makes a user's computer act like a server to another user's computer. Bittorrent clients (like Azureus) act like that too.

    All of those programs usually require a fair amount of user interaction in setting up an appropriate network configuration, so as to accept incoming requests from the Internet. Bittorrent clients won't work at all unless the user configures things correctly. Kazaa will work without user interaction only under one situation which is not uncommon: where only one user is behind a router and the other is not. In that situation, Kazaa has a special mode in which the user behind the router will make an outgoing "reverse request" to serve up a file to the other computer. Since the request is an outgoing request, the user behind the router does not ever accept an incoming request and he therefore does not need to configure his network to accept incoming requests.

    For Azureus, the program tries to make life easy for the user, by programmatically using UPnP to configure the network/router in the way that's needed for proper operation. If it can configure the network programmatically, then the user never knows the complexities of what was done on his behalf. But if it can't (e.g., if UPnP is not enabled on the router), then the user must make the configurations manually.

    See this thread for some other thoughts: "How Kazaa works ... ? " at http://www.codeguru.com/forum/showthread.php?t=341667 . This thread points to a page by Bryan Ford concerning a "hole-punching" technique that allows two users, both behind routers, to establish p2p contact with each other. Ford's site (at http://midcom-p2p.sourceforge.net/ ) includes a link to source code.

    Many p2p programs rely on the existence of a trustworthy server (sometimes called a rendezvous server) to establish p2p communications between two users behind routers. The above "hole punching" technique does too.

    Quote Originally Posted by RogerGarrett
    Can you recommend any book that thoroughly addresses these issues and describes how to set these kinds of P2P applictions up, ideally in an MFC, dialog-based application? I know that's asking quite a bit of a book, but acquiring all the necessary information piecemeal, from whatever other books, articles, and web sites that I can find has been a particularly grueling task.
    Sorry, but I'm not aware of any.

    Mike
    Last edited by MikeAThon; October 6th, 2006 at 04:58 PM.

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