Difference between dot notation and string based IP - network-programming

When setting the IP for where the client should connect,do I need to make distinguish between and IP like 208.56.123.1 and one like "www.domain.com" ?

IP is only the number.
So, 208.56.123.1 is IP, but www.domain.com is not - it's a symbolic name. Both are addresses, but only the number is IP.
Symbolic name will usually resolve to an actual IP using DNS server.
As to your question, will both work the same, the answer is - it only depends on how your client is implemented.
Both addresses should refer to the same location, though it might be better to target the symbolic name, because IP is more likely to change.

Depends on the use case. Most programming languages / network libraries come with built-in support for name resolution.
Low-level system calls like bind() or connect() do not support name resolution and require you to get the IP.

Related

Is it possible to change Preferred DNS Servers for IPV4 connection programatically using Delphi-10.3?

Is it possible to progamatically change the Preferred DNS servers for an active WIFI IPV4 connection using Delphi 10.3 and Windows 10? There are occasions when it would be useful for my program to use alternative DNS Servers. Normally to change them one has to take the long route of going through Network and Internet Settings and manually adding the preferred DNS Addresses. I was hoping to find an API call that may address this issue and allow me to simply select my chosen DNS Addresses from a combobox or similar and switch between the chosen addresses and those provided by the ISP, but as of yet my internet searches have yielded nothing.
Any Help would be much appreciated.

Is there a standardized notation to specify network ports/ranges?

I am implementing a component that receives IP addresses and port ranges from command line or configuration files. For IP addresses, I use the CIDR notation. However I'm unable to find out if there is a similar standard for specifying network ports or network port ranges.
I currently envision a simple comma-separated list of dash-separated ranges (e.g., "3999,5001-9999") but I'd like to refer to some specification (RFC or otherwise) that defines it. I'm even willing to switch to a different notation as long as there is some standard to back it.

Localhost OR loopback naming

During development of an IpAddress library's part, I'm confronted to a minor dilema.
How to name my function testing the address to be a LocalHost / Loopback.
What is the difference between this 2 designations?
In other libs , they make this choices:
Boost.asio -> is_loopback
Qt -> isLoopback
wxWidget -> IsLocalHost
Why do they call isLoopback a test like address == "::1" ??
ANSWER:
"localhost" is usually an alias for the "loopback" interface. They can and are often used interchangeably.
Subquestion: Is it the same definition between IPv4 and IPv6?
The previous answer is not entirely correct.
Loopback +interface+ may have configured multiple IP addresses, not only from localhost network. It is a common practice to put non-local address on loopback interface in e.g. dynamic routing, where you don't want to lose routes to router's IP in case any interface goes down.
On the other hand, loopback IPv4 +network+ is defined by IANA as 127.0.0.0/8. Surprisingly, for IPv6 they reserved only ::1/128 address.
To answer your question: if you want to check only addresses, I'd pick isLocalhost(). And to be a bit zealous, I'd check there for the whole network - I happened to see 127.0.0.2 a few times...

Regarding bonjour domains

I'm trying to understand how the choice of the bonjour domain will influence device discovery on the network. I find the documentation somewhat unclear on some points, and would like to ask for clarification.
From here:
Most network service browser clients do not have to use this method—it is sufficient to publish a service with the empty string, which registers it in any available registration domains automatically."
This seems like a recommendation. Lets put a pin on that.
From here:
#""—Registers the service in the default set of domains. Pass this value unless you have a specific reason not to."
Reforces the recommendation, but what does this mean? What's the default set of domains? And what does that imply?
From the same link:
#"local"—Registers the service only on the local network. Pass this value if you need to prevent publishing your service over Back to My Mac or wide-area Bonjour.
What does publishing "over Back to My Mac or wide-area Bonjour" mean? Should I use this if I'm using bonjour for proximity only? Doesn't this contradict the recommendation?
Also from the same link:
A user-specified domain—Registers the service in only the specified domain.
I actually tried this and the service doesn't even get advertised on the network. I get a call to the delegate method netServiceWillPublish: and that's it, nor didPublish nor didNotPublish are called afterwards. Is there a strict set of domains that can be used? I'm using simple names, like test.
Basically, it's still very unclear to me what the domain name accomplishes on the network. How does it influence the discovery process? Ou does it influence service matching? Does it have consequences on network performance? I know these seem like a lot of questions, but mostly, I think that if I understand what domains are for most of them will go away. Hopefully :)
Best.

Why do we need sender MAC address in ARP request?

Here is a wireshark capture of an ARP request PNG image, I contains the sender MAC inside the ARP packet. The receiving station can derive the MAC from the Ethernet frame. It seems to be redundant. Is there any particular use of separately including the sender MAC address in ARP Request too ?.
The "redundancy" was by design (RFC 826), and can be useful in targeting different layers. In RFC 3927 there's what is known as Gratuitous Address Resolution Protocol (GARP), and in certain circumstances the redundancy, or lack of, plays an important role, especially in troubleshooting and monitoring networking stacks.
Actually it's not rendunancy at all, the MAC (physical, layer 2) and IP (logical, layer 3) addresses are not the same thing. They serve different purposes on different network layers.
On large scale networks it's quite common to observe changes in the MAC/ARP/Source/Dest information, and at times can seem almost incorrect. For example, you might see a host send an ARP request with its own address as the target address. Depending on the exact situation, it might be telling us it's a link up/down event, maybe it's trying update other devices ARP tables, or possibly detecting an ip conflict and moving the ip to another NIC.
I could get into clustering, failovers — the list goes on, although I would end up writing a book trying to explain it all. Hopefully this gives you a bit of insight about the "redundancy" you were questioning. ;-)
More Info:
RFC 826 /
RFC 3927
/ Wireshark Gratuitous ARP
Although often used in conjunction with Ethernet, ARP by itself is an independent protocol. Imagine other link layer protocols that do not expose MAC addresses. ARP would not work in such circumstances if the sender field was not provided.
There is no rule that the ARP protocol field sender mac address to be same as ethernet source mac address. Eg: Its possible in few applications where multiple interfaces of same host are on network, but one only interface sends arp responses for all interfaces.

Resources