HTTP_COAP_XMPP_UDP_notes
HTTP_COAP_XMPP_UDP_notes
HTTP stands for HyperText Transfer Protocol. It is the main way web browsers and servers
communicate to share information on the internet. Tim Berner invents it. HyperText is the type of text
that is specially coded with the help of some standard coding language called HyperText Markup
Language (HTML). HTTP/2 is the new version of HTTP. HTTP/3 is the latest version of HTTP,
which is published in 2022.
When you visit a website, HTTP helps your browser request and receive the data needed to display
the web pages you see. It is a fundamental part of how the internet works, making it possible for us to
browse and interact with websites. In this article, we are going to discuss the Full form of HTTP along
with its working, advantages, and disadvantages.
What is the Full Form of HTTP?
HTTP stands for “Hypertext Transfer Protocol.” It is a set of rules for sharing data on the World Wide
Web (WWW). HTTP helps web browsers and servers communicate, allowing people to access and
share information over the internet.
Key Points
Basic Structure: HTTP forms the foundation of the web, enabling data communication and file
sharing.
Web Browsing: Most websites use HTTP, so when you click on a link or download a file, HTTP
is at work.
Client-Server Model: HTTP works on a request-response system. Your browser (client) asks for
information, and the website’s server responds with the data.
Application Layer Protocol: HTTP operates within the Internet Protocol Suite, managing how
data is transmitted and received.
What is HyperText?
The protocol used to transfer hypertext between two computers is known as HyperText Transfer
Protocol. HTTP provides a standard between a web browser and a web server to establish
communication. It is a set of rules for transferring data from one computer to another. Data such as
text, images, and other multimedia files are shared on the World Wide Web. Whenever a web user
opens their web browser, the user indirectly uses HTTP. It is an application protocol that is used for
distributed, collaborative, hypermedia information systems.
Working of HTTP [HyperText Transfer Protocol]
First of all, whenever we want to open any website we first open a web browser after that we will type
the URL of that website (e.g., www.facebook.com ). This URL is now sent to the Domain Name
Server (DNS). Then DNS first checks records for this URL in their database, and then DNS will
return the IP address to the web browser corresponding to this URL. Now the browser is able to send
requests to the actual server.
After the server sends data to the client, the connection will be closed. If we want something else from
the server we should have to re-establish the connection between the client and the server.
HTTP Response
CoAP
Message Format
CoAP Features
Lightweight and Simple
RESTful Architecture
UDP-Based
Asynchronous Communication
Low Header Overhead
Multicast Communication
Proxy and Caching
Applications of CoAP
Real Time Monitoring in Grid - Smart cities can monitor the distribution and generation of
power remotely. The CoAP sensors could be embedded inside the transformers and the data could
be transferred over GPRS or 6LowPAN.
Defense utilities - The armory and tanks are now-a-days fitted with sensors so that information
could be communicated remotely without any interference. The CoAP sensors could detect any
intrusion. This makes them capable to transfer more data even under low bandwidth network.
Aircraft utilities - The Aircraft sensors and actuators could be connected with other sensors and
communication can take place using smart CoAP based sensors and actuators.
The difference between MQTT and CoAP protocols could be understood from the following article on
GFG: Difference between CoAP and MQTT
Conclusion
CoAP is a versatile and efficient protocol developed to meet the specific needs of restricted devices
and networks. Due to less overhead and capability to transfer data effectively even under low
bandwidth, CoAP has became a primarily choice for IoT and cloud computing system architecture.
CoAP messages have a fixed size header which is of 4 bytes. Alongside this, CoAP message format
have some optional fields which includes fields like token, options, and payload. This message format
of CoAP is binary encoded in 0/1 format. CoAP works on request response model which majorly
resembles HTTP methods like GET, POST, PUT, and DELETE along with its own unique method
Observe
Frequently Asked Questions on CoAP - FAQs
Is CoAP better than MQTT?
CoAP is meant to use UDP, making it better suitable for constrained networks and resources.
User Datagram Protocol (UDP ) is a Transport Layer protocol. UDP is a part of the Internet
Protocol suite, referred to as UDP/IP suite. Unlike TCP, it is an unreliable and connectionless
protocol. So, there is no need to establish a connection before data transfer. The UDP helps to
establish low-latency and loss-tolerating connections over the network. The UDP enables process-
to-process communication.
What is User Datagram Protocol?
User Datagram Protocol (UDP) is one of the core protocols of the Internet Protocol (IP) suite. It is a
communication protocol used across the internet for time-sensitive transmissions such as video
playback or DNS lookups . Unlike Transmission Control Protocol (TCP), UDP is connectionless
and does not guarantee delivery, order, or error checking, making it a lightweight and efficient
option for certain types of data transmission.
UDP is a connectionless protocol that offers minimal error recovery services. For more insights into
network protocols like UDP, consider the GATE CS Self-Paced Course .
UDP Header
UDP header is an 8-byte fixed and simple header, while for TCP it may vary from 20 bytes to 60
bytes. The first 8 Bytes contain all necessary header information and the remaining part consists of
data. UDP port number fields are each 16 bits long, therefore the range for port numbers is defined
from 0 to 65535; port number 0 is reserved. Port numbers help to distinguish different user requests
or processes.
UDP Header
Source Port: Source Port is a 2 Byte long field used to identify the port number of the source.
Destination Port: It is a 2 Byte long field, used to identify the port of the destined packet.
Length: Length is the length of UDP including the header and the data. It is a 16-bits field.
Checksum: Checksum is 2 Bytes long field. It is the 16-bit one’s complement of the one’s
complement sum of the UDP header, the pseudo-header of information from the IP header, and
the data, padded with zero octets at the end (if necessary) to make a multiple of two octets.
Notes – Unlike TCP, the Checksum calculation is not mandatory in UDP. No Error control or flow
control is provided by UDP. Hence UDP depends on IP and ICMP for error reporting. Also UDP
provides port numbers so that is can differentiate between users requests.
Applications of UDP
Used for simple request-response communication when the size of data is less and hence there
is lesser concern about flow and error control.
It is a suitable protocol for multicasting as UDP supports packet switching.
UDP is used for some routing update protocols like RIP(Routing Information Protocol).
Normally used for real-time applications which can not tolerate uneven delays between sections
of a received message.
VoIP (Voice over Internet Protocol) services, such as Skype and WhatsApp, use UDP for real-
time voice communication. The delay in voice communication can be noticeable if packets are
delayed due to congestion control, so UDP is used to ensure fast and efficient data transmission.
DNS (Domain Name System) also uses UDP for its query/response messages. DNS queries are
typically small and require a quick response time, making UDP a suitable protocol for this
application.
DHCP (Dynamic Host Configuration Protocol) uses UDP to dynamically assign IP addresses to
devices on a network. DHCP messages are typically small, and the delay caused by packet loss
or retransmission is generally not critical for this application.
Following implementations uses UDP as a transport layer protocol:
o NTP (Network Time Protocol)
o DNS (Domain Name Service)
o BOOTP, DHCP.
o NNP (Network News Protocol)
o Quote of the day protocol
o TFTP, RTSP, RIP.
The application layer can do some of the tasks through UDP-
o Trace Route
o Record Route
o Timestamp
UDP takes a datagram from Network Layer , attaches its header, and sends it to the user. So, it
works fast.
TCP vs UDP
User Datagram Protocol
Basis Transmission Control Protocol (TCP) (UDP)
TCP provides extensive error-checking UDP has only the basic error-
Error checking mechanisms. It is because it provides flow checking mechanism using
mechanism control and acknowledgment of data. checksums.
Acknowledgme
An acknowledgment segment is present. No acknowledgment segment.
nt
There is no retransmission of
Retransmission of lost packets is possible in
lost packets in the User
TCP, but not in UDP.
Retransmission Datagram Protocol (UDP).
TCP has a (20-60) bytes variable length UDP has an 8 bytes fixed-
Header Length header. length header.
Handshaking Uses handshakes such as SYN, ACK, SYN- It’s a connectionless protocol
Techniques ACK i.e. No handshake
Advantages of UDP
Speed: UDP is faster than TCP because it does not have the overhead of establishing
a connection and ensuring reliable data delivery.
Lower latency: Since there is no connection establishment, there is lower latency and
faster response time.
Simplicity: UDP has a simpler protocol design than TCP, making it easier to
implement and manage.
Broadcast support: UDP supports broadcasting to multiple recipients, making it useful
for applications such as video streaming and online gaming.
Smaller packet size: UDP uses smaller packet sizes than TCP, which can reduce
network congestion and improve overall network performance.
User Datagram Protocol (UDP) is more efficient in terms of both latency and
bandwidth.
Disadvantages of UDP
No reliability: UDP does not guarantee delivery of packets or order of delivery, which
can lead to missing or duplicate data.
No congestion control: UDP does not have congestion control, which means that it
can send packets at a rate that can cause network congestion.
Vulnerable to attacks: UDP is vulnerable to denial-of-service attacks , where an
attacker can flood a network with UDP packets, overwhelming the network and causing
it to crash.
Limited use cases: UDP is not suitable for applications that require reliable data
delivery, such as email or file transfers, and is better suited for applications that can
tolerate some data loss, such as video streaming or online gaming.
How is UDP used in DDoS attacks?
A UDP flood attack is a type of Distributed Denial of Service (DDoS) attack where an
attacker sends a large number of User Datagram Protocol (UDP) packets to a target port.
UDP Protocol : Unlike TCP, UDP is connectionless and doesn’t require a handshake
before data transfer. When a UDP packet arrives at a server, it checks the specified
port for listening applications. If no app is found, the server sends
an ICMP “destination unreachable” packet to the supposed sender (usually a
random bystander due to spoofed IP addresses).
Attack Process :
o The attacker sends UDP packets with spoofed IP sender addresses to
random ports on the target system.
o The server checks each incoming packet’s port for a listening application
(usually not found due to random port selection).
o The server sends ICMP “destination unreachable” packets to the spoofed
sender (random bystanders).
o The attacker floods the victim with UDP data packets, overwhelming its
resources.
Mitigation : To protect against UDP flood attacks, monitoring network traffic for sudden
spikes and implementing security measures are crucial. Organizations often use
specialized tools and services to detect and mitigate such attacks effectively.
UDP Pseudo Header
The purpose of using a pseudo-header is to verify that the UDP packet has reached its
correct destination
The correct destination consist of a specific machine and a specific protocol port
number within that machine
XMPP is a short form for Extensible Messaging Presence Protocol. It’s protocol
for streaming XML elements over a network in order to exchange messages and
present information in close to real-time.
Let’s dive into each character of word XMPP:
X : It means eXtensible. XMPP is an open-source project which can be
changed or extended according to the need.
M : XMPP is designed for sending messages in real time. It has very efficient
push mechanism compared to other protocols.
P : It determines whether you are online/offline/busy. It indicates the state.
P : XMPP is a protocol, that is, a set of standards that allow systems to
communicate with each other.
These are the basic requirements of any Instant Messenger which are fulfilled by
XMPP:
1. Send and receive messages with other users.
2. Check and share presence status
3. Manage subscriptions to and from other users.
4. Manage contact list
5. Block communications(receive message, sharing presence status, etc) to
specific users.
Other XMPP features:
Decentralised:
XMPP is based on client-server architecture, i.e. clients don’t communicate
directly, they do it with the help of server as intermediary. It is decentralised
means there is no centralised XMPP server just like email, anyone can run their
own XMPP server. Each XMPP client is identified by JID (Jabber ID).
#JID
{
user,
server,
resource
}
For example, I’m a whatsApp user and I’m identified by my mobile number, so
user = "8767898790"
server = "whatsapp.com"
resource = "mobile"
JID : "[email protected]/mobile"
resource is used in case the application support mobile as well as desktop or
web application, so it can be optional in case a Instant Messenger Application
support only single kind of resource.
XMPP implementation:
The original protocol for XMPP is Transmission Control Protocol using open ended
XML streams over long lived TCP connections. In some cases, there are restricted
firewalls, XMPP(port 5222) is blocked, so it can’t be used for web applications
and users behind restricted firewalls, to overcome this, XMPP community also
developed a HTTP transport. And as the client uses HTTP, most firewalls allow
clients to fetch and post messages without any problem. Thus, in scenarios
where the TCP port used by XMPP is blocked, a server can listen on the normal
HTTP port and the traffic should pass without problems.
XMPP Applications:
While vanilla XMPP is very less used, but it’s modified and customised versions is
highly used by applications for managing contact list, online presence in
applications like WhatsApp, Kik Messenger, Zoom, etc.