OSDev.org

The Place to Start for Operating System Developers
It is currently Sat May 04, 2024 7:16 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: Using Winsock to Connect to ADSL Connection
PostPosted: Sun Jan 04, 2004 4:08 am 
How can I connect to a PC that is connected to the web using an adsl connection.

thanks.


Top
  
 
 Post subject: Re:Using Winsock to Connect to ADSL Connection
PostPosted: Sun Jan 04, 2004 8:24 am 
Look up these functions in MSDN:

socket
connect
send
recv
closesocket


Top
  
 
 Post subject: Re:Using Winsock to Connect to ADSL Connection
PostPosted: Sun Jan 04, 2004 7:24 pm 
Hi again,

I guess that is what I get for not defining my problem properly.

Ok, I know how to use these functions, when I use them to connect to a computer that is connected using a dialup connection, everything goes well.

However, when I try the same thing connecting to a computer that is connected via adsl the connection fails.

When I look at the adsl modems web interface, it says that the ip address is something like this 186.45.96.80/32

I don't know how an ip like this works. So any info here would be good, I have no idea what it is so I cannot search google for answers.

Also, when using the various socket functions to get info about the computer the IP address is returned as 10.0.0.1 which is what the modem maps incoming data to, so I guess what I need to know is how to get through the ISP to the computer behind it.

I hope this is better stated so that you can help me further.

thanks.


Top
  
 
 Post subject: Re:Using Winsock to Connect to ADSL Connection
PostPosted: Mon Jan 05, 2004 1:32 am 
OK, before you start writing any code, check that it's possible to connect to the other machine at all. I guess those numbers are an IP address and a port number, so try ignoring the "/32" part and concentrate on the first four numbers as normal.

-- Try ping
-- Set up a web server on it and try to connect to that
-- Set up a web server on the port number you'd be using in your program and try to connect to that

If those don't work then you've got a problem with your setup and you're not going to be able to fix that in your program. ISPs commonly filter out incoming connections to prevent hacking; users often have firewalls enabled; and the remote host might not be a PC connected directly to the Internet but a network behind NAT, which will require some configuration on the NAT.


Top
  
 
 Post subject: Re:Using Winsock to Connect to ADSL Connection
PostPosted: Mon Jan 05, 2004 2:37 am 
Hi again,

Thanks for your help, the webserver did not work, however I know that file sharing software can create direct connections between my computer (the one with adsl) and any other computer.

I know this works so it must be possible, I use KazaaLite so does anyone know how this software handles it's connections.

Or where I can get some source code for a program that can do the same thing.

thanks.


Top
  
 
 Post subject: Re:Using Winsock to Connect to ADSL Connection
PostPosted: Mon Jan 05, 2004 5:11 am 
I don't know about Kazaa, but Napster used to handle this by only creating outgoing connections. It would detect if the computer used a proxy; if so, it would notify the server that this computer was unable to accept incoming connections. Then, when a connection to that computer was needed, the server would ask the computer to connect to the other computer which wanted to connect to it. If both computers where behind proxies, they would each connect to the Napster server itself, and the Napster server would relay the data.

Summary: This doesn't work automatically. You will need to design your protocol around this problem to solve it.


Top
  
 
 Post subject: Re:Using Winsock to Connect to ADSL Connection
PostPosted: Mon Jan 05, 2004 7:36 am 
Hi again,

So basically if I create an outgoing connection, that connection can then be used by the other computer to send me data?

If this is the case then how does the other computer know the IP of my computer, it seems as though there really should be a way to create a incoming connection as well, internet explorer is able to function normally, or would this also do something similar to what you mentioned.

There has to be a way to get data through, for example say that my ISP has a server setup to manage each adsl account connection, it would have an IP address, this would be where all data is sent, then somehow the server would need to determine which connection the data needs to go to, it needs a unique way to identify me.

Looking at my modems web interface, it has an IP address table, I will try to define the table below.

IP Address Table:

Intf | Address/Netmask | Type | Translation
----------------------------------------------------------
pppoa | 203.xxx.xxx.xxx/32 | Auto | pat
eth0 | 169.xxx.xxx.xxx/16 | Auto | none
eth0 | 10.0.0.138/8 | User | none
loop | 127.0.0.1/8 | Auto | none

I am assuming that pppoa is the interface used to negotiate connections, I don't use ethernet (assuming eth0 is ethernet) so I don't know why they are there, so if pppoa is the interface then 203.xxx.xxx.xxx is the address to talk to and I can be uniquely identified with the /32 part does this sound like anything??

In practical use I would probably implement the outgoing only stuff you mentioned as this is probably more user friendly but I want to understand this other stuff just for the knowledge.

Anyway, if anyone knows this stuff I would appreciate some info or resources that can help me.

Thanks for your help so far Tim.


Top
  
 
 Post subject: Re:Using Winsock to Connect to ADSL Connection
PostPosted: Mon Jan 05, 2004 2:04 pm 
Guest wrote:
So basically if I create an outgoing connection, that connection can then be used by the other computer to send me data?

If a computer (call it computer A) behind a proxy (call it computer B) can connect to a remote host on the other side of the proxy (call it computer C), then that remote host must be able to send data back. Otherwise the computer behind the proxy wouldn't be able to do anything at all.
Quote:
If this is the case then how does the other computer know the IP of my computer, it seems as though there really should be a way to create a incoming connection as well, internet explorer is able to function normally, or would this also do something similar to what you mentioned.

The Internet as a whole only sees computer B. It isn't aware of computer A. Similarly, computer A only talks to computer B. The proxy software on computer B knows where to forward requests, and when it gets data back from computer C, it knows where to return it. It requires special intelligence in the proxy.

For example, with HTTP, computer A sends a request to computer B saying "GET http://www.somesite.com/". Computer A then waits for some data back from computer B. Computer B makes a connection to www.somesite.com and says "GET /". Computer B waits for some data back from www.somesite.com and sends it back to computer A. The web browser on computer A knows about proxies, so it connects to computer B instead of trying to connect directly to www.somesite.com.

Network address translation (NAT) works differently. Computer A has its IP default gateway set to the IP address of computer B. That is, if the IP stack on computer A doesn't know where to send packets to (such as computer C), it sends them to computer B. Computer B is set up as a NAT server, so it knows to accept packets from computer A. Although these packets have arrived at computer B, they're still stamped with the address of computer C, so computer B forwards them on, and remembers that it has sent them. When computer C sends a packet back in reply, computer B knows to send it back to computer A.

However, incoming connections on NAT don't automatically go all the way through to computer A. Computer B doesn't know the difference between a connection request to computer A and a connection request to itself; remember, the only host that computer C can see is B. So the operating system on computer B has special configuration options which say, "if you get a connect request on port X, send it to computer B".
Quote:
I am assuming that pppoa is the interface used to negotiate connections, I don't use ethernet (assuming eth0 is ethernet) so I don't know why they are there, so if pppoa is the interface then 203.xxx.xxx.xxx is the address to talk to and I can be uniquely identified with the /32 part does this sound like anything??

Not sure what this table means. You might have to look at your modem's documentation.
Quote:
In practical use I would probably implement the outgoing only stuff you mentioned as this is probably more user friendly but I want to understand this other stuff just for the knowledge.

Yeah, your options are:
  • Design support for proxies into your protocol (this is what HTTP-based protocols do)
  • Require that users behind NAT set up their router correctly
It's not an easy problem to solve 100% of the time.


Top
  
 
 Post subject: Re:Using Winsock to Connect to ADSL Connection
PostPosted: Mon Jan 05, 2004 7:11 pm 
Wow, that was a mouthful. That has actually helped me understand how this stuff works.

Thanks alot.


Top
  
 
 Post subject: Re:Using Winsock to Connect to ADSL Connection
PostPosted: Tue Jan 06, 2004 5:19 am 
I just remembered: the ADSL modem/router I used has an option for virtual servers. Before I could run a web server on my PC, I had to tell the modem to forward any incoming connections on port 80 to port 80 on 192.168.0.10. So web browsers outside of my network would actually be connecting to my modem, which would in turn connect to my PC and pass packets back and forth.


Top
  
 
 Post subject: Re:Using Winsock to Connect to ADSL Connection
PostPosted: Tue Jan 06, 2004 1:36 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 22, 2004 11:00 pm
Posts: 1076
pppoa - ppp over atm
pppoe - ppp over ethernet...

my BT adsl uses... err... i think pppoa.... :)

but BT is moving pppoe into their stuff coz of fragmentation with pppoa connections... blah..

tired. brain fried. ugh.

_________________
-- Stu --


Top
 Profile  
 
 Post subject: Re:Using Winsock to Connect to ADSL Connection
PostPosted: Mon Jan 12, 2004 9:38 am 
Hi again,

Tim, that last comment you made about running a web server?

Can you tell me how to do this. I have an IP Route Table on my modem, I know how to add an entry to this, so do you have some more info that could help me.

Even a reference to somewhere else that can give me the details would be appreciated, even if you know a search term that could get the info on goggle for me.

thanks.


Top
  
 
 Post subject: Re:Using Winsock to Connect to ADSL Connection
PostPosted: Mon Jan 12, 2004 10:20 am 
How to do this is 100% modem-dependent. Mine has a web page interface where you can define a list of virtual servers. You can say, direct all incoming requests on port X to port Y on computer Z.


Top
  
 
 Post subject: Re:Using Winsock to Connect to ADSL Connection
PostPosted: Tue Jan 13, 2004 2:25 am 
Hi,

OK, I have added an entry to my NAPT table, it is even actually paritially working. The reason I know this is because I downloaded a sample vb winsock program, the server actually receives the connection request however it immediately returns without success and the client then automatically attempts two more times to get through (winsock control appears to do this by itself, no code to try again) but it fails.

After the 3 attempts the client fails with a timeout error. So clearly the entry in the NAPT table has made a difference however it still fails.

Any ideas??


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group