Can we use SSL/TLS over UDP OR DTLS over TCP IP? - networking

I am new to networking and I have a doubt on what would happen if we interchange the use of security protocols with their respective transport layer protocols.
Will there be any kind of affect on the delivery performance?
And How is one security protocol different and optimised for specific transport protocol it is designed to be used for?

If you read DTLS - RFC 6347, you will read, that it contains a lot of counter measures for UDP usage. It also explains, why using TLS (with its inherent assumption) will not work for UDP.
If DTLS over TCP would makes sense, depends mostly from your expectations. So why would you like to do that?

Related

using UDP to parallelize HTTP reads

Apparently, I don't get true parallel reads of different URLs on the same server, even issuing truly contemporary requests, on multiple physical interfaces (NICs).
I think the problem could be that HTTP protocol is connection oriented, then requests are serialized at lower level into TCP/IP stack (is this correct wording?).
Does make sense to attempt to 'reimplement' an high level HTTP request with a connectionless schema, like UDP, and handle myself packet addressing, to speedup streaming ?
HTTP requests are independent. They can be issues over arbitrarily many independent connections. HTTP does not impose an limits regarding concurrency.
You hit some resource limit. Maybe your client library restricts the number of concurrent calls. Maybe the server does. Maybe the network is fully utilized. Maybe back-end resources that the server uses are maxed out.
Find the bottleneck and eliminate it. The transport protocol is not the problem. Changing it can't help.
different URLs
Whether the URL is different or not makes no difference, except if the server implements some special throttling. Highly unlikely.
on multiple physical interfaces (NICs).
You are probably not network-bound.
requests are serialized at lower level into TCP/IP stack
No. Connection management is not part of HTTP. The client decided how many connections to use. Reconfigure the client.
Does make sense to attempt to 'reimplement' an high level HTTP request with a connectionless schema, like UDP, and handle myself packet addressing, to speedup streaming ?
You will have to re-implement flow control, segment fragmentation, re-transmission and other features of TCP protocol yourself. And then your HTTP implementation will not be compatible with the standard one.
So no, it does not make much sense.
For streaming you may like to use protocols designed for streaming, like WebRTC.

Icecast transport layer protocol - TCP or UDP?

I don't seem to find a answer, so I'm asking you.
Does a stock Icecast2 server use TCP or UDP to broadcast the streaming data? I know that it uses a custom HTTP based Application Layer protocol, so one might think its TCP, but on the other hand it is a broadcast application, so UDP would be more logical to me. If it uses TCP nonetheless, why does it do that?
Icecast and SHOUTcast both use TCP for both the source streams and streaming to end clients. There are many reasons this is beneficial:
The codecs used by most internet radio stations do not lend themselves well to having lost chunks of data. If the stream were corrupt, either by lost or out-of-order packets, the decoder will sometimes be able to re-sync and continue, but many will simply fail.
Most internet radio stations have no real latency requirement. Nobody knows or cares if they get the audio delayed by a few seconds. It is actually typical to crank up the buffer size to allow clients to start playback quickly, causing delays of 10-30 seconds.
It is important to be compatible with HTTP. I suspect that when Nullsoft originally built SHOUTcast, their goal was to get up and running with it as simply as possible, so it makes sense that they mimicked HTTP. I suspect that the reason Icecast and SHOUTcast are so popular is that it is easy to write a client for them because it is essentially HTTP. Now that web-based players are a reality (with Flash and even HTML5), it is critical that the protocol be compatible with HTTP as many browsers do not support other streaming protocols. (Flash has its own protocol, but it is not nearly as simple as HTTP to implement.) If a client can play a file streamed from an HTTP server, it can stream from Icecast (and SHOUTcast if it is lenient in its HTTP implementation).
You mentioned broadcast... I don't know if you meant in the sense of UDP broadcast packets, but those do not work well in practice over the internet. Therefore, the only benefit to using UDP would be to reduce overhead, but I think you will see that for the reasons above, the few bytes of overhead don't outweigh the benefits of TCP for this type of application.
In short, this is not a telephony application where latency matters and custom clients can be used.

Reliable Data Transfer (RDT), Go-Back-N (GBN) and Selective Repeat (SR)

I'm taking a course on networking right now and trying to understand where the three protocols are used. I understand that they are efforts to make the unreliable link layer (IP) reliable.
Are they actually implemented anywhere? Does TCP implement any of them? And for that matter, are there any other protocols that operate on the transport layer other than TCP and UDP?
I'm using the book Computer Networking by Kurose & Ross.
Any help is greatly appreciated!
"where the three protocols are used. I understand that they are efforts to make the unreliable link layer (IP) reliable."
First, do not get RDT confused with GBN and SR because GBN and SR are RDT protocols. When we talk about RDT, it's like we are talking in general.. RDT specifies the requirements of a reliable data transfer protocol, the requirements are retransmission, error detection, and acknowledgments. As long as any protocol (maybe one that you make and get approved IETF :) ) satisfies those requirements can be considered a rdt protocol. Good examples of rdt are SW (stop and wait), GBN, and SR.
That answers first question, except I cant help myself to mention the error you at the end of the question, not the "link layer" I'm sure you meant the network layer.
"Are they actually implemented anywhere? Does TCP implement any of them? "
Again, for a protocol to be reliable, it doesn't have to be considered GBN or SR as long as it satisfies rdt principles. For instance, we wouldn't call TCP a GBN protocol or SR protocol but rather its own.. however it does share some with both, such as cumulative acks (though in a slightly different way, as it doesn't have an ack timer as GBN) and it keeps out of order packets in its buffer to eventually reorder them (same as SR while SR uses independent acks).
"And for that matter, are there any other protocols that operate on the transport layer other than TCP and UDP?"
Sure, you can even make your own as I mentioned before and consult with IETF ;) but TCP and UDP are the most prevalent and widely used protocols.
Hope that clarifies it.
Yes, TCP implements all of them, although "selective repeat" is an option (RFC 2018).
Your second question is a little harder to answer because it always devolves into a semantic argument. There are other protocols (OSPF and EIGRP to name two) that ride on top of IP and have their own transport functions built in. But they don't fit neatly into the OSI model, so you can call them either transport or application layer protocols depending on your point of view.

How do applications know which OSI protocol to use?

I would like to understand what happens when we type "google.com" in our browser wrt OSI model. What all protocols comes into picture AT EACH LAYER any how does they know which one to be used?
Also I would like to know, TCP/UDP which one to be used in Transport layer is decided for network/application? That is for a normal web page like google.com TCP must be used but for video streaming UDP. how is this conveyed to network?
Is the browser also part of this as it is helping. Should it also come under application layer?
Http comes under Application layer of OSI model. now for this particular example, what will come under Presentation and Session layers? Will the sessions be maintained in session layer or HTTP will be doing it on their behalf?
It sounds like you would like a tutorial on TCP/IP. May I suggest a couple of good books
URLs in webpages have a prefix that tells the applications what to do with that link. For instance, ftp:// opens an ftp session, which uses tcp (ref RFC 959 - File Transfer Protocol). As a general rule, the URL prefixes correspond to a standardized protocol, which was specified via RFC. The RFC denotes which transport protocol is used.
EDIT
In the case of youtube, their videos have a http:// URL prefix, but after you make the request, it is redirected to a rtsp:// URL. RTSP can be streamed over UDP.
To answer questions like this, you may find that wireshark is very useful to investigate these things... keep in mind that wireshark works best on wired connections.
Applications don't use any layer of the OSI protocol stack. They use TCP or UDP from the TCP/IP stack, and they 'know which' because of they are programmed to use one or the other or both. The OSI model is obsolete and certainly doesn't apply to TCP/IP.
EDIT: The OSI layer model is a Procrustean bed into which TCP/IP does not fit. You should forget about OSI immediately. It doesn't describe anything in the real world.

When to use TCP and HTTP in node.js?

Stupid question, but just making sure here:
When should I use TCP over HTTP? Are there any examples where one is better than the other?
TCP is full-duplex 2-way communication. HTTP uses request/response model. Let's see if you are writing a chat or messaging application. TCP will work much better because you can notify the client immediately. While with HTTP, you have to do some tricks like long-polling.
However, TCP is just byte stream. You have to find another protocol over it to define your messages. You can use Google's ProtoBuffer for that.
Use HTTP if you need the services it provides -- e.g., message framing, caching, redirection, content metadata, partial responses, content negotiation -- as well as a large number of well-understood tools, implementations, documentation, etc.
Use TCP if you can't work within those constraints. However, if you use TCP you'll be creating a new application protocol, which has a number of pitfalls.

Resources