-->APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse Parallel Data Warehouse
UDP is a connectionless and unreliable transport protocol.The two ports serve to identify the end points within the source and destination machines. User Datagram Protocol is used, in place of TCP, when a reliable delivery is not required.However, UDP is never used to send important data such as web-pages, database information, etc. Streaming media such as video,audio and others use UDP because it offers speed.
Ethereal Capture
2. What is the advantage of keeping checksum field turned off and when is it appropriate to keep checksum field turned off?
SFP/SFP+ transceivers are SINGLE-SPEED only. If its a Checksum error then the SFP could either be faulty, not a Cisco-branded SFP or counterfeit.
The
CHECKSUM
function returns the checksum value computed over a table row, or over an expression list. Use CHECKSUM
to build hash indexes.Syntax
Arguments
*
This argument specifies that the checksum computation covers all table columns.
This argument specifies that the checksum computation covers all table columns.
CHECKSUM
returns an error if any column has a noncomparable data type. Noncomparable data types include:- cursor
- image
- ntext
- text
- XML
Another noncomparable data type is sql_variant with any one of the preceding data types as its base type.
expression
An expression of any type, except a noncomparable data type.
An expression of any type, except a noncomparable data type.
Return types
int
Remarks
CHECKSUM
computes a hash value, called the checksum, over its argument list. Use this hash value to build hash indexes. A hash index will result if the CHECKSUM
function has column arguments, and an index is built over the computed CHECKSUM
value. This can be used for equality searches over the columns.The
CHECKSUM
function satisfies hash function properties: CHECKSUM
applied over any two lists of expressions will return the same value, if the corresponding elements of the two lists have the same data type, and if those corresponding elements have equality when compared using the equals (=) operator. Null values of a specified type are defined to compare as equal for CHECKSUM
function purposes. If at least one of the values in the expression list changes, the list checksum will probably change. However, this is not guaranteed.Therefore, to detect whether values have changed, we recommend use of CHECKSUM
only if your application can tolerate an occasional missed change. Otherwise, consider using HASHBYTES
instead. With a specified MD5 hash algorithm, the probability that HASHBYTES
will return the same result, for two different inputs, is much lower compared to CHECKSUM
.The expression order affects the computed
CHECKSUM
value. The order of columns used for CHECKSUM(*)
is the order of columns specified in the table or view definition. This includes computed columns.The
CHECKSUM
value depends on the collation. The same value stored with a different collation will return a different CHECKSUM
value.CHECKSUM ()
does not guarantee unique results.Examples
These examples show the use of
CHECKSUM
to build hash indexes.To build the hash index, the first example adds a computed checksum column to the table we want to index. It then builds an index on the checksum column.
This example shows the use of a checksum index as a hash index. This can help improve indexing speed when the column to index is a long character column. The checksum index can be used for equality searches.
Index creation on the computed column materializes the checksum column, and any changes to the
ProductName
value will propagate to the checksum column. Alternatively, we could build an index directly on the column we want to index. However, for long key values, a regular index will probably not perform as well as a checksum index.See also
CHECKSUM_AGG (Transact-SQL)
HASHBYTES (Transact-SQL)
BINARY_CHECKSUM (Transact-SQL)
< Communication Networks | TCP and UDP ProtocolsHASHBYTES (Transact-SQL)
BINARY_CHECKSUM (Transact-SQL)
The latest reviewed version was checked on 11 March 2018. There are template/file changes awaiting review.
- 1UDP
UDP[edit]
Unlike TCP, UDP doesn't establish a connection before sending data, it just sends. Because of this, UDP is called 'Connectionless'. UDP packets are often called 'Datagrams'. An example of UDP in action is the DNS service. DNS servers send and receive DNS requests using UDP.
Introduction[edit]
In this section we have to look at User Datagram protocol. It’s a transport layer protocol. This section will cover the UDP protocol, its header structure & the way with which it establishes the network connection.
As shown in Figure 1,the User Datagram Protocol (UDP) is a transport layer protocol that supports Network Application. It layered on just below the ‘Session’ and sits above the IP(Internet Protocol) in open system interconnection model (OSI). This protocol is similar to TCP (transmission control protocol) that is used in client/ server programs like video conference systems expect UDP is connection less.
Figure 1:UDP in OSI Layer Model
What is UDP?[edit]
'Figure 2:UDP
UDP is a connectionless and unreliable transport protocol.The two ports serve to identify the end points within the source and destination machines. User Datagram Protocol is used, in place of TCP, when a reliable delivery is not required.However, UDP is never used to send important data such as web-pages, database information, etc. Streaming media such as video,audio and others use UDP because it offers speed.
Why UDP is faster than TCP?
The reason UDP is faster than TCP is because there is no form of flow control. No error checking,error correction, or acknowledgment is done by UDP.UDP is only concerned with speed. So when, the data sent over the Internet is affected by collisions, and errors will be present.
UDP packet's called as user datagrams with 8 bytes header. A format of user datagrams is shown in figur 3. In the user datagrams first 8 bytes contains header information and the remaining bytes contains data.
Figure 3:UDP datagrams
Source port number: This is a port number used by source host,who is transferring data. It is 16 bit longs. So port numbers range between 0 to 65,535.
Destination port number: This is a port number used by Destination host, who is getting data. It is also 16 bits long and also same number of port range like source host.
length: Length field is a 16 bits field. It contains the total length of the user datagram, header and data.
Checksum: The UDP checksum is optional. It is used to detect error fro the data. If the field is zero then checksum is not calculated. And true calculated then field contains 1.
Characteristics of UDP
The characteristics of UDP are given below.
• End-to-end. UDP can identify a specific process running on a computer.
• Unreliable, connectionless delivery (e.g. USPS)::
UDP uses a connectionless communication setup. In this UDP does not need to establish a connection before sending data. Communication consists only of the data segments themselves
• Same best effort semantics as IP
• No ack, no sequence, no flow control
• Subject to loss, duplication, delay, out-of-order, or loss of connection
• Fast, low overhead
1.Suit for reliable, local network
2.RTP(Real-Time Transport Protocol)
Use of ports in Communication[edit]
After receiving the data,computer must have some mechanism what to do with it.Consider that user has three application open say a web browser,a telnet session and FTP session.All three application are moving data over the network. So, there should be some mechanism for determining what piece of traffic is bound for which application by operating system.To handle this situation , network ports are used.Available port's range is 0 to 65535.In them 0 to 1023 are well-known ports, 1023 to 49151 are registered ports and 49152 to 65535 are dynamic ports.
Figure 4: Port
List of well-known ports used by UDP:
Figure 5:List of ports used by UDP
UDP Header structure[edit]
It contains four section. Source port, Destination port, Length and Checksum.
Figure 6: UDP Header
Source port
Source port is an optional field. When used, it indicates the port of the sending process and may be assumed to be the port to which a reply should be addressed in the absence of any other information. If not used, a value of zero is inserted.
Destination port
It is the port number on which the data is being sent.
Length
It include the length of UDP Header and Data.
The length in octets of this user datagram, including this header and the data. The minimum value of the length is eight.
Checksum
The main purpose of checksum is error detection.It guarantees that message arrived at correct destination.To verify checksum,the receiver must extract this fields from IP Header .12-byte psuedo header is used to compute checksum.
Data
It is the application data.or Actual message.
Ethereal Capture
The UDP packet can be viewed using Ethereal capture. One such UDP packet is captured and shown below.
Figure 7: ethereal capture
Communication in UDP[edit]
In UDP connection,Client set unique source port number based on the program they started connection. UDP is not limited to 1-to-1 interaction. A 1-to-many interaction can be provided using broadcast or multi-cast addressing . A many-to-1 interaction can be provided by many clients communicating with a single server. A many-to-many interaction is just an extension of these techniques.
UDP Checksum and Pseudo-Header[edit]
The main purpose of UDP checksum is to detect errors in transmitted segment.
UDP Checksum is optional but it should always be turned on.
To calculate UDP checksum a 'pseudo header' is added to the UDP header.The field in the pseudo header are all taken from IP Header.They are used on receiving system to make sure that IP datagram is being received by proper computer.Generally , the pseudo-header includes:
Figure 8 : UDP Pseudo Header
IP Source Address 4 bytes
IP Destination Address 4 bytes
Protocol 2 bytes
UDP Length 2 bytes
Checksum Calculation[edit]
Sender side :
1. It treats segment contents as sequence of 16-bit integers.
2. All segments are added. Let's call it sum.
3. Checksum : 1's complement of sum.(In 1's complement all 0s are converted into 1s and all 1s are converted into 0s).
4. Sender puts this checksum value in UDP checksum field.
Receiver side :
1. Calculate checksum
2. All segments are added and then sum is added with sender's checksum.
3. Check that any 0 bit is presented in checksum. If receiver side checksum contains any 0 then error is detected. So the packet is discarded by receiver.
Here we explain a simple checksum calculation.As an example, suppose that we have the bitstream 0110011001100110 0110011001100110 0000111100001111:
This bit stream is divided into segments of 16-bits integers.
So, it looks like this:
0110011001100110 (16-bit integer segment)
0101010101010101
0000111100001111
The sum of first of these 16-bit words is:
0110011001100110
0101010101010101
1011101110111011
Adding the third word to the above sum gives
1011101110111011
0000111100001111
1100101011001010 (sum of all segments)
Now to calculate checksum 1's complement of sum is taken.As I mentioned earlier , 1's complement is achieved by converting all 1s into 0s and all 0s into 1s.So,the checksum at sender side is : 0011010100110101.
Now at the receiver side, again all segments are added . and sum is added with sender's checksum.
If no error than check of receiver would be : 1111111111111111.
If any 0 bit is presented in the header than there is an error in checksum.So,the packet is discarded.
You may wonder why UDP provides a checksum in the first place, as many link-layer protocols (including the popular Ethernet protocol) also provide error checking? The reason is that there is no guarantee that all the links between source and destination provide error checking -- one of the links may use a protocol that does not provide error checking. Because IP is supposed to run over just about any layer-2 protocol, it is useful for the transport layer to provide error checking as a safety measure. Although UDP provides error checking, it does not do anything to recover from an error. Some implementations of UDP simply discard the damaged segment; others pass the damaged segment to the application with a warning.
Summary[edit]
UDP is a transport layer protocol. UDP is a connectionless and unreliable protocol. UDP does not do flow control, error control or retransmission of a bad segment. UDP is faster then TCP. UDP is commonly used for streaming audio and video . UDP never used for important documents like web-page, database information, etc. UDP transmits segments consisting of an 8-byte header. Its contains Source port, Destination port, UDP length and Checksum. UDP checksum used for detect “errors” in transmitted segment.
Exercise Questions[edit]
1. Calculate UDP checksum of the following sequence: 11100110011001101101010101010101.
Answer : To calculate the checksum follow the following steps:
2. What is the advantage of keeping checksum field turned off and when is it appropriate to keep checksum field turned off?
Answer :
Retrieved from 'https://en.wikibooks.org/w/index.php?title=Communication_Networks/TCP_and_UDP_Protocols/UDP&oldid=3382688'