Data Link Layer and Transport Layer - networking

What is the need of error control at data link layer when Transport layer provides error control ? What is the difference between the two error controls ?

Transport layer data could be broken down to many data-link layer frames/packets.
So it is possible that even without any data-link errors the transport layer stream/packet may be corrupt. Edit: This is because a transport layer path is usually composed of many data-link layer hops, for example:
Host1 <----> switch1 <----> switch2 <----> Host2
if a packet was lost between switch1 and switch2 then there would be no errors recorded on the switch2 Host2 link, but the corresponding transport layer stream would be corrupted.
On the other hand - once a data-link error is encountered it's possible to drop/restart the transport-layer transmission, without wasting resources.

This is because Data link layer deals exclusively with bit-level error correction. It takes a packet the receiving computer already has in its possession and determines if an error occurred in transmission and whether the data is intact or corrupt. However, there need to be additional controls in place to make sure the system knows that all the packets are arriving. This is called end to end error control and is the responsibility of transport layer. Transport layer couldn't care less whether the data in the payload is good or bad. That's Data link's job. Transport only cares if it is getting every packet that it is supposed to, and whether or not there are arriving in the right order. It is the transport layer that detects the absence of packets or the corruption of packets that occurred on the transmission end before they arrived at the Data link layer.
For additional details, refer to
http://books.google.ca/books?id=9c1FpB8qZ8UC&pg=PA216&lpg=PA216&dq=why+error+detection+and+correction+both+in+transport+and+link+layer+?&source=bl&ots=RI7-DU8RO0&sig=0U5Z9AmKkx3m3TA71WfIe1uTeW0&hl=en&sa=X&ei=LbqPUsahOtDEqQHyvIHQCw&ved=0CDUQ6AEwAQ#v=onepage&q=why%20error%20detection%20and%20correction%20both%20in%20transport%20and%20link%20layer%20%3F&f=false

It really depends on the protocols rather than the layer, but assuming you mean TCP...
TCP's error detection is minimal and designed more as an integrity check than any kind of reliable error detection. The reason you don't see this is practice is that data-link layers such as Ethernet, PPP, FrameRelay, etc. have much, much more robust error detection algorithms and so there are virtually no transmission errors for the TCP protocol to detect.
If you had a different transport layer protocol with robust error detection then you wouldn't strictly need it at lower levels. There is benefit, largely performance and resource use related, to discarding errors as low in the stack as possible.
Note that errors can creep in above the transport layer due to ram glitches, etc, so if data is really, really important then you should include error checking right in your application.

Assuming the checksum was correct this result meant that the data was damaged in transit.
Furthermore, the damage took place not on the transmission links (where it would be caught by the CRC) but rather must have occurred in one of the intermediate systems (routers
and bridges) or the sending or receiving hosts.
http://conferences.sigcomm.org/sigcomm/2000/conf/paper/sigcomm2000-9-1.pdf

Firstly, retransmission of packets from end-to-end is an expensive task and potentially takes a lot of time. Having these checks at each link reduces the "length" that the retransmitted packet has to travel. Consider a case when there is an error-prone link on the end-to-end path. This link will probably cause many packet drops, being that it is unreliable. If there wasn't any link layer reliability, the retransmission could only be handled by the transport layer protocol. Therefore, the malformed packet would have to reach its destination, send a NACK (or equivalent), and only then could the retransmission take place. On the other hand, if link layer has reliability built in the packet would be retransmitted immediately only on the unreliable link.
Secondly, link layer reliability relies on bit checks only, while transport layer reliability also utilizes sequencing and acknowledgments. Consider a case where the segment passed to the network layer needs to be fragmented because the MTU is too small. Link layer reliability will only check for the integrity of each individual fragment. If one fragment is lost, link layer may not raise an alarm. On the other hand, transport layer will because it expects all the fragmented packets.
Finally, link layer is not only carrying TCP and other transport layer protocols within its payload. Therefore, it is befitting to have reliability built in for protocols which do not have reliability built-in so that malformed payloads don't go up the stack.

In a noisy channel where the error rate is high, like wireless networks, the error correction is done at the datalink layer.
In robust networks where the error rate is low, like LANs, the error correction is done at the transport layer, so the retransmission cost is minimized.

Related

In Opendaylight, we send openflow's multipart request and why wireshark can see accumulate multipart request in a single packet?

Like this figure,enter image description here
I can find many openflow1.3 which are multipart requests in this packet, but I don't know why happened here?
Actually, isn't it only one openflow1.3 here ?
It is related to openflowjava do serialize, wireshark, NIC, tcp nagle's algorithim?
Thanks!
TCP is a byte stream, i.e. packet has no semantic from the perspective of the application layer (i.e. OpenFlow). At the transport level there can be multiple application layer "messages" in a single TCP packet, messages cross packet boundaries etc - it does not matter for the application. While often TCP packet boundaries are also message boundaries because of timing in the application and maybe a disabling of NAGLE algorithm, the assumption that TCP packet boundaries are always message boundaries is wrong and any reliance on this will often cause sporadic and hard to reproduce problems.
And based on this what you see is also not a "multipart request". These are just multiple OpenFlow messages (application level) send at the same time or shortly after each other and they are put together into the same transport level entity (packet) since this way it is less overhead to transport each message.

clarification regarding "connection oriented"

I just want to check my understanding of terms,I was stuck at the term "Connection-oriented".In case of virtual circuits which works at layer 3,connection establishment is nothing but reservation of resources like buffers.and it identifies path by combination of (VPI and VCI).I was under impression that term "connection oriented" means same in case of TCP which works at transport layer and does 3 way handshake for connection establishment. But after reading https://networkengineering.stackexchange.com/questions/6307/does-tcp-use-virtual-circuit-model
which mentions "But TCP connections still aren't circuits, because they don't reserve bandwidth during connection on every switch between the two nodes." I am confused.Am i missing some important terminology or concept?Thanks in advance.
In case of TCP, 'connection-oriented service' means having a session established in the transport layer. In case of TCP, data transmission is guaranteed. You have acknowledgements in TCP. These are some reasons why it is called 'connection-oriented'.

What are the chances of losing a UDP packet?

Okay, so I am programming for my networking course and I have to implement a project in Java using UDP. We are implementing an HTTP server and client along with a 'gremlin' function that corrupts packets with a specified probability. The HTTP server has to break a large file up into multiple segments at the application layer to be sent to the client over UDP. The client must reassemble the received segments at the application layer. What I am wondering however is, if UDP is by definition unreliable, why am I having to simulate unreliability here?
My first thought is that perhaps it's simply because my instructor is figuring in our case, both the client and the server will be run on the same machine and that the file will be transferred from one process to another 100% reliably even over UDP since it is between two processes on the same computer.
This led me first to question whether or not UDP could ever actually lose a packet, corrupt a packet, or deliver a packet out of order if the server and client were guaranteed to be two processes on the same physical machine, guaranteed to be routed strictly over localhost only such that it won't ever go out over the network.
I would also like to know, in general, for a given packet what is the rough probability that UDP will drop / corrupt / or deliver a packet out of order while being used to facilitate communication over the open internet between two hosts that are fairly geographically distant from one another (say something comparable to the route between the average broadband user in the US to one of Google's CDNs)? I'm mostly just trying to get a general idea of the conditions experienced when communicated over UDP, does it drop / corrupt / misorder something on the order of 25% of packets, or is it more like something on the order of 0.001% of packets?
Much appreciation to anyone who can shed some light on any of these questions for me.
Packet loss happens for multiple reasons. Primarily it is caused by errors on individual links and network congestion.
Packet loss due to errors on the link is very low, when links are working properly. Less than 0.01% is not unusual.
Packet loss due to congestion obviously depends on how busy the link is. If there is spare capacity along the entire path, this number will be 0%. But as the network gets busy, this number will increase. When flow control is done properly, this number will not get very high. A couple of lost packets is usually enough that somebody will reduce their transmission speed enough to stop packets getting lost due to congestion.
If packet loss ever reaches 1% something is wrong. That something could be a bug in how your congestion control algorithm responds to packet loss. If it keeps sending packets at the same rate, when the network is congested and losing packets, the packet loss can be pushed much higher, 99% packet loss is possible if software is misbehaving. But this depends on the types of links involved. Gigabit Ethernet uses backpressure to control the flow, so if the path from source to destination is a single Gigabit Ethernet segment, the sending application may simply be slowed down and never see actual packet loss.
For testing behaviour of software in case of packet loss, I would suggest two different simulations.
On each packet drop it with a probability of 10% and transmit it with a probability of 90%
Transmit up to 100 packets per second or up to 100KB per second, and drop the rest if the application would send more.
if UDP is by definition unreliable, why am I having to simulate unreliability here?
It is very useful to have a controlled mechanism to simulate worst case scenarios and how both your client and server can respond to them. The instructor will likely want you to demonstrate how robust the system can be.
You are also talking about payload validity here and not just packet loss.
This led me to question whether or not UDP, lose a packet, corrupt a packet, or deliver it out of order if the server and client were two processes on the same machine and it wasn't having to go out over the actual network.
It is obviously less likely over the loopback adapter, but this is not impossible.
I found a few forum posts on the topic here and here.
I am also wondering what the chances of actually losing a packet, having it corrupted, or having them delivered out of order in reality would usually be over the internet between two geographically distant hosts.
This question would probably need to be narrowed down a bit. There are several factors both application level (packet size and frequency) as well as limitations/traffic of routers and switches along the path.
I couldn't find any hard numbers on this but it seems to be fairly low... like sub 5%.
You may be interested in The Internet Traffic Report and possibly pages such as this.
I was spamming udp packets over wifi to some nanoleaf panels and my packet loss was roughly 1/7000.
I think it depends on a ton of factors.

Checksums on TCP

Is TCP not responsible for making sure that a stream is sent intact over the wire by doing whatever may become necessary as losses etc. occur during a transfer?
Does it not do a proper job of it?
Why do higher application-layer protocols and their applications still perform checksums?
While TCP does contain its own checksum, it is only a 16-bit checksum and it is certainly possible for a multi-bit transmission error to slip by the TCP checksum mechanism. This is quite rare, but it is still possible and I have in fact seen it happen (once or twice in a couple of decades).
A robust protocol will want to use a higher-level hash function to assure integrity of transmitted data. Having said that, not many applications that transmit a small amount of data go to this trouble. Bulk transfer applications (such as a package manager or auto-update mechanism) will usually use a cryptographic hash function to increase the assurance of data integrity.
TCP ensures that TCP packets are delivered reliably, using checksums to trap errors introduced during transmission, and retransmitting lost or damaged packets as required. When a packet is transmitted it is retained in a retransmission queue until the peer host acknowledges receipt; if no acknowledgement is received within a certain timeout period then the packet is retransmitted. But the host won't keep retransmitting a packet forever - if a packet repeatedly fails then TCP eventually gives up and closes the connection.
Higher-level protocols assume that TCP works reliably (a fair assumption) and use their own checksums or whatever to check that the higher-level data stream arrived safely. I've written lots of buggy sockets applications that screwed up their own higher-level buffers and mangled the application data stream!
In any production-grade TCP/IP stack with a robust application I think you can be confident that the problem is that your connection is dropping out. Or you might have a buggy application, but I doubt that your fetch/wget is buggy.

Why Does RTP use UDP instead of TCP?

I wanted to know why UDP is used in RTP rather than TCP ?. Major VoIP Tools used only UDP as i hacked some of the VoIP OSS.
As DJ pointed out, TCP is about getting a reliable data stream, and will slow down transmission, and re-transmit corrupted packets, in order to achieve that.
UDP does not care about reliability of the communication, and will not slow down or re-transmit data.
If your application needs a reliable data stream, for example, to retrieve a file from a webserver, you choose TCP.
If your application doesn't care about corrupted or lost packets, and you don't need to incur the additional overhead to provide the additional reliability, you can choose UDP instead.
VOIP is not significantly improved by reliable packet transmission, and in fact, in some cases things in TCP like retransmission and exponential backoff can actually hurt VOIP quality. Therefore, UDP was a better choice.
A lot of good answers have been given, but I'd like to point one thing out explicitly:
Basically a complete data stream is a nice thing to have for real-time audio/video, but its not strictly necessary (as others have pointed out):
The important fact is that some data that arrives too late is worthless. What good is the missing data for a frame that should have been displayed a second ago?
If you were to use TCP (which also guarantees the correct order of all data), then you wouldn't be able to get to the more up-to-date data until the old one is transmitted correctly. This is doubly bad: you have to wait for the re-transmission of the old data and the new data (which is now delayed) will probably be just as worthless.
So RTP does some kind of best-effort transmission in that it tries to transfer all available data in time, but doesn't attempt to re-transmit data that was lost/corrupted during the transfer (*). It just goes on with life and hopes that the more important current data gets there correctly.
(*) actually I don't know the specifics of RTP. Maybe it does try to re-transmit, but if it does then it won't be as aggressive as TCP is (which won't ever accept any lost data).
The others are correct, however the don't really tell you the REAL reason why. Saua kind of hints at it, but here's a more complete answer.
Audio and Video is real-time. If you are listening to a radio, or watching TV, and the signal is interrupted, it doesn't pick up where you left off.. you're just "observing" the signal as it streams, and if you can't observe it at any given time, you lose it.
The reason, is simple. Delay. VOIP tries very hard to minimize the amount of delay from the time someone speaks into one end and you get it on your end, and your response back. Otherwise, as errors occured, the amount of delay between when the person spoke and when the signal was received would continuously grow until it became useless.
Remember, each delay from a retransmission has to be replayed, and that causes further data to be delayed, then another error causes an even greater delay. The only workable solution is to simply drop any data that can't be displayed in real-time.
A 1 second delay from retransmission would mean it would now be 1 second from the time I said something until you heard it. A second 1 second delay now means it's 2 seconds from the time i say something until you hear it. This is cumulative because data is played back at the same rate at which it is spoken, and so on...
RTP could be connection oriented, but then it would have to drop (or skip) data to keep up with retransmission errors anyways, so why bother with the extra overhead?
Technically RTP packets can be interleaved over a TCP connection. There are lots of great answers given here. Two additional minor points:
RFC 4588 describes how one could use retransmission with RTP data. Most clients that receive RTP streams employ a buffer to account for jitter in the network that is typically 1-5 seconds long and which means there is time available for a retransmit to receive the desired data.
RTP traffic can be interleaved over a TCP connection. In practice when this is done, the difference between Interleaved RTP (i.e. over TCP) and RTP sent over UDP is how these two perform over a lossy network with insufficient bandwidth available for the user. The Interleaved TCP stream will end up being jerky as the player continually waits in a buffering state for packets to arrive. Depending on the player it may jump ahead to catch up. With an RTP connection you will get artifacts (smearing/tearing) in the video.
UDP is often used for various types of realtime traffic that doesn't need strict ordering to be useful. This is because TCP enforces an ordering before passing data to an application (by default, you can get around this by setting the URG pointer, but no one seems to ever do this) and that can be highly undesirable in an environment where you'd rather get current realtime data than get old data reliably.
RTP is fairly insensitive to packet loss, so it doesn't require the reliability of TCP.
UDP has less overhead for headers so that one packet can carry more data, so the network bandwidth is utilized more efficiently.
UDP provides fast data transmission also.
So UDP is the obvious choice in cases such as this.
Besides all the others nice and correct answers this article gives a good understanding about the differences between TCP and UDP.
The Real-time Transport Protocol is a network protocol used to deliver streaming audio and video media over the internet, thereby enabling the Voice Over Internet Protocol (VoIP).
RTP is generally used with a signaling protocol, such as SIP, which sets up connections across the network. RTP applications can use the Transmission Control Protocol (TCP), but most use the User Datagram protocol (UDP) instead because UDP allows for faster delivery of data.
UDP is used wherever data is send, that does not need to be exactly received on the target, or where no stable connection is needed.
TCP is used if data needs to be exactly received, bit for bit, no loss of bits.
For Video and Sound streaming, some bits that are lost on the way do not affect the result in a way, that is mentionable, some pixels failing in a picture of a stream, nothing that affects a user, on DVDs the lost bit rate is higher.
just a remark:
Each packet sent in an RTP stream is given a number one higher than its predecessor.This allows thr destination to determine if any packets are missing.
If a packet is mising, the best action for the destination to take is to approximate the missing vaue by interpolation.
Retranmission is not a proctical option since the retransmitted packet would be too late to be useful.
I'd like to add quickly to what Matt H said in response to Stobor's answer. Matt H mentioned that RTP over UDP packets can be checksum'ed so that if they are corrupted, they will get resent. This is actually an optional feature on most PBXs. In Asterisk, for example, you can enable / disable checksums on your RTP over UDP traffic in the rtp.conf configuration file with the following line:
rtpchecksums=yes ; or no if you prefer
Cheers!

Resources