0% found this document useful (0 votes)
9 views

Network_Protocols_Detailed_Guide

Uploaded by

lliaiiitreghk348
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Network_Protocols_Detailed_Guide

Uploaded by

lliaiiitreghk348
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Network Protocols - Detailed Guide

This document provides a comprehensive guide to network protocols, explaining each type and
including code examples. We will cover protocols like HTTP, TCP, IP, ICMP, and more. The document
also includes images for better understanding.

OSI Model Overview

The OSI model is a conceptual framework used to understand and describe network interactions in
seven layers. Each layer handles specific tasks in data transmission. Below are the seven layers of the
OSI model:

1. Physical Layer 2. Data Link Layer 3. Network Layer 4. Transport Layer 5. Session Layer 6.
Presentation Layer 7. Application Layer

HTTP Protocol

HTTP (Hypertext Transfer Protocol) is the protocol used for transferring hypertext via the World Wide
Web. It works as a request-response protocol in a client-server model. Web browsers use HTTP to
request and receive data from web servers.

HTTP Code Example (Python)

import requests response = requests.get('https://www.example.com') print(response.status_code)

TCP Protocol

TCP (Transmission Control Protocol) is a connection-oriented protocol that ensures reliable data
transmission. It guarantees that data packets arrive in order and without loss. TCP is widely used in
applications that require reliable delivery, such as web browsing and email.

TCP Code Example (Server in Python)

import socket server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)


server.bind(('localhost', 12345)) server.listen(5) while True: client, address = server.accept()
print(f"Connection from {address}") client.sendall(b"Hello from server!") client.close()
IP Protocol

IP (Internet Protocol) is used for addressing and routing packets of data across networks. It is a
fundamental protocol of the Internet layer, ensuring data gets to the correct destination.

ICMP Protocol

ICMP (Internet Control Message Protocol) is used for network diagnostics and error messages. The
most common ICMP command is the 'ping' command, which tests connectivity between devices.

ICMP Code Example (Ping in Python)

import os response = os.system('ping www.example.com') if response == 0: print('Host is up') else:


print('Host is down')

SSL/TLS Protocol

SSL (Secure Sockets Layer) and TLS (Transport Layer Security) are cryptographic protocols designed
to provide secure communication over a computer network. They are commonly used in HTTPS to
encrypt the data transmitted between a client and a server.

SSL Code Example (Python)

import ssl import socket context = ssl.create_default_context() conn =


context.wrap_socket(socket.socket(socket.AF_INET), server_hostname='www.example.com')
conn.connect(('www.example.com', 443)) print(conn.getpeername())

Conclusion

Network protocols are the backbone of communication on the internet. Understanding the different
protocols and how they function is essential for network engineers, developers, and cybersecurity
professionals. This guide provided an overview of key protocols and included code examples for better
understanding and implementation.

You might also like