Recognizing WAN from LAN

My Application built for the LAN is being used over the WAN, Since my package uses TWinSocket I cannot differentiate unless the customer confesses. Can I get to know the location of the computer where my application is running from (within the application).
I use Delphi on Windows
Allan_FernandesAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mohammed KhawajaManager - Infrastructure:  Information TechnologyCommented:
The easiest thing to do is look at the local machine IP default gateway and determine if the destination is on same network or not.  If different then assume it is WAN.
LesterClaytonCommented:
You can get the Client IP address, and if the client address is a private address (i.e. 10.x.x.x, 192.168.x.x or 172.16.x.x-172-31.x.x) then you can rest assured that it's on your LAN.  If it's anything else - then it's coming from the Internet/WAN.

Unfortuantely I don't know if TWinSocket has the ability to show client address - it is most likely t.  I use ICS mainly, and in that case I would use Client.GetPeerAddr on the OnClientConnect event.

NOTE: This won't be the case with IPv6

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ste5anSenior DeveloperCommented:
There is no reliable way to do this. Cause LAN's may not use private only addresses. WAN's may also use private IP addresses.

The only thing you can do, is trying to determine, whether you talk to clients in the same network. But a network may be spanned over more then one LAN or WAN's.
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

Sinisa VukSoftware architectCommented:
you can retrieve HOPs count .... should be under 2 for lan. Test it.
Function for hop count is here.

another way is to check MAC addresses in a white list.
Allan_FernandesAuthor Commented:
How about in a LAN with above 500 machines and multiple switches / routers being used ?
Asking as I am not familiar about how the Hardware is set in these situations.
LesterClaytonCommented:
My answer has provided you with the information, and will include a large scale corporate environemnt if necessary.  Due to the fact that there are insufficient IP addresses available, 99.9% of corporations use private IP addresses (ranges provided in my first answer) for their workstations.  Connections coming from inside your network will be one of those addresses.  Connections coming from outside will appear outside of those ranges.
Geert GOracle dbaCommented:
There is no real accurate way of doing that

in big companies there can be different forests
just some sample forests: emea, na, la, aspac ...

every forest can be divided into different sites, and within that ip-ranges

AdExplorer from sysinternals is a free tool which you could use ...

if you can read the sites in active directory, you can find the ip-ranges
within the same ip-range it should be safe to think your in the same lan
within the same site is about 90% in the same LAN

everything else is probably over wan

the only sure way would be to ask the network admins for 2 different ip's how they are connected
they usually have some tools which provide a network map with all the routers / switches / etc

PLC programs/connections should be as short as possible ... and wan is not really an option here
but ... WAN is usually not really the actual problem
it's the speed of the WAN ... 10Mb network is the minimum for acceptable traffic

money is the real problem
> companies have a limited amount of money and outweigh the cost of the speed of the WAN's against the performance they get
the person complaining usually only has budget to buy your program and has no control over the WAN speed.
sit down with them and ask their network admin to join your conversation

that will get you way further

for large wan's some people setup hardware to compress the traffic
it uses deduplication to prevent sending already sent packages
if your data has lots of similar packages to send, it could be faster than the LAN ...
Geert GOracle dbaCommented:
one other thing
the lan can be crippled by loopback's or broadcasts ... but the network admin's usually prevent this (or try to)

adding the network topic to this question would give the input of those experts too ...
Allan_FernandesAuthor Commented:
In fact the data I have got from here is good enough for me . I am not looking for a perfect solution as this is pertaining to unethical / ignorant customers. I can put few of the above solutions together and accordingly get informed about the customer's setup, if in doubt I can visit the customer and revise his Invoice accordingly.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.