4
http://www.dummies.com/how-to/content/the-tcpip-networking-protocol-suite.html

I was reading the difference between the two, and in the example of TCP:

For example, when a user running a Web browser requests a page, the browser uses HTTP to send a request via TCP to the Web server. When the Web server receives the request, it uses HTTP to send the requested Web page back to the browser, again via TCP.

Example of UDP:

The best-known Application layer protocol that uses UDP is DNS, the Domain Name System. When an application needs to access a domain name such as www.dummies.com, DNS sends a UDP packet to a DNS server to look up the domain. When the server finds the domain, it returns the domain's IP address in another UDP packet.

Which of the two happens initially? How does connection to a website happens in the end?

2
  • You should read IP, then UDP, and finally TCP. Oct 30, 2014 at 18:13
  • Did any answer help you? if so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you could provide and accept your own answer.
    – Ron Maupin
    Aug 10, 2017 at 22:55

2 Answers 2

2

I'll try to answer your question directly without going into a huge rant about TCP v UDP.

Basically you need to understand that both HTTP and DNS are completely independent applications/protocols. Sometimes you need to actually send a DNS query to a DNS server, sometimes you don't (if the DNS record is cached locally on your PC/Server).

  1. We do NOT have a DNS record cached.

    • http://google.com is entered in the browser.
    • Your PC checks the local DNS cache, and sees it does NOT have a record for google.com
    • A UDP DNS query is sent to a DNS server, in this case it's most likely your ISP's DNS server.
    • The DNS server sends a UDP response back.
    • You now have your answer in the form of an IP address, now you can initiate your TCP connection to google.com
    • The 3-way handshake occurs between you and google.com (SYN, SYN/ACK, ACK) - if you do not know what this is you can search for "TCP 3 way handshake" and find some good information.
    • After the handshake completes, HTTP will render in the form of your favorite search engine.
  2. We HAVE a DNS record cached. There is a very small difference here, but I'm going to include the whole thing so you can see the comparison.

    • http://google.com is entered in the browser.
    • Your PC checks the local DNS cache, and sees it has a record cached in the form of an IP address.
    • You now have your IP address for google.com, now you can initiate your TCP connection to google.com
    • The 3-way handshake occurs between you and google.com (SYN, SYN/ACK, ACK)
    • After the handshake completes, HTTP will render in the form of your favorite search engine.

So just because you're trying to get to a webpage you do not have to send a UDP DNS query. DNS is independent, visiting a webpage is not the only time you'd need to use DNS. Feel free to comment if you need clarification.

2
  • So, post that, in both cases, HTTP works by sending a HTTP command using the TCP protocol, right? And also, what is the role of IP? Difference between IP and TCP? I guess, IP is just involved in IP addresses whereas TCP involves actual delivery of packets.
    – john
    Oct 29, 2014 at 19:00
  • "I guess, IP is just involved in IP addresses whereas TCP involves actual delivery of packets." This is correct, TCP or UDP (layer 4) can encapsulate IP packets (layer 3) for transport (delivery). As you move up the OSI layers, HTTP (layer 7) will eventually encapsulate the data in the TCP segments (there are layers between TCP and HTTP) to render the webpage. Oct 29, 2014 at 20:10
0

Think of UDP as sending a letter regular postage, and TCP as sending it with tracking numbers and notifications on delivery. Keep in mind UDP and TCP are just delivery methods, they don't give a damn what's in the packet or what the application receiving it does with the packet.

DNS is a stupid example to show someone the difference between TCP and UDP. SNMP (and traps in particular) is better. Let me try below. Note, examples are simplified slightly.

When a router sends an SNMP trap (an alert such as "Hey, I've just rebooted, thought you should know") to the SNMP server via UDP it does just that: it sends the packet to the server and that's it. If the server is programmed to send something back, UDP doesn't care. UDP delivered its packet, now it's going to the pub for a pint.

So what would happen with TCP? Well, the router world send the packet containing the trap message to the server. After a certain timeout period, it would then send the packet again... And again... And again... Until the server finally responds with an ACKNowledgement packet. And that's ALL TCP cares about. It doesn't care about the data packet that the server may (or may not) need to send back. TCP will deliver its packet and return with an ACKnowledgement, or die trying (more or less).

You may want to review the OSI model, keeping in mind that each layer encapsulates the one above it. That is, each layer wraps the stuff it received from the layer above and carries it with professional disinterest as to the contents.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.