# TASK 2.1
## FTP (File Transfer Protocol)
### Overview
* FTP uses **TCP ports 20 and 21**.
* Usernames and passwords are used for authentication, but no encryption (plain-text).
* For security, use FTPS (FTP over SSL/TLS) and SFTP (SSH File Transfer Protocol).
* Client can navigates file directories, add and remove directories, list files, etc., on server, and client sends ***[FTP commands](https://en.wikipedia.org/wiki/List_of_FTP_commands)*** to the server to perform these functions.
* FTP uses two types of connections:
1. **FTP control connection (TCP 21)**: established and used to send FTP commands and replies.
2. **FTP data connections (TCP 20)**: when files or data are to be transferred, seperate FTP data connections are establish and terminated as needed.
### FTP data connections - ACTIVE MODE
* Default method of establishing FTP data connections.
* Server initiates the data connection.
### FTP data connections - PASSIVE MODE
* Client initiates the data connection.
* Necessary when the client is behind a firewall, which could block the incoming connection from the server (firewalls usually don't permit "outside" devices to initiate connections).
## TFTP (Trivial File Transfer Protocol)
### Overview
* TFTP servers listen on **UDP port 69**.
* Only allows a client to copy a file to or from a server.
* No authentication (username/password), server will respond to all TFTP requests.
* No encryption (plain-text).
* Used to transfer small files quickly.
* UDP is connectionless and doesn't provide reliability with retransmissions.
* **However**, TFTP incorporates idle − RQ (stop and wait) error recovery mechanism:
1. Every TFTP data unit bears a sequence number.
2. Each data unit is separately acknowledged. After taking the acknowledgement, the next data unit is transmitted.
3. Error recovery is by retransmission after timeout. TFTP uses adaptive timeout with an exponential back-off algorithm.


~~not so related~~
### TFTP 3 MODES OF TRANSFER
1. Netascii is a modified form of ASCII, defined in RFC 764. It consists of an 8-bit extension of the 7-bit ASCII character space from 0x20 to 0x7F (the printable characters and the space) and eight of the control characters. The allowed control characters include the null (0x00), the line feed (LF, 0x0A), and the carriage return (CR, 0x0D). Netascii also requires that the end of line marker on a host be translated to the character pair CR LF for transmission, and that any CR must be followed by either a LF or the null. ~~*okay wtf*~~
* To simplify this, eventually netascii makes LF bytes (line feed) (0x0A) become CR-LF (0x0D 0x0A), and CR bytes (carriage return) (0x0D) become CR-null (0x0D 0x00)
3. Octet allows for the transfer of arbitrary raw 8-bit bytes, with the received file resulting byte-per-byte identical to the one sent. More correctly, if a host receives an octet file and then returns it, the returned file must be identical to the original.
4. Mail transfer mode uses Netascii transfer, but the file is sent to an email recipient by specifying that recipient's email address as the file name. RFC 1350 declared this mode of transfer obsolete.
## HTTP (HyperText Transfer Protocol)
HTTP is an application-layer protocol used for transmitting hypertext over the internet. It is the foundation of data communication on the World Wide Web.
How it works: A client (typically a web browser) sends an HTTP request to a server, and the server responds with the requested resource, such as a web page. The communication occurs over TCP (Transmission Control Protocol) on **port 80** by default.
Example: When you enter a URL in your web browser (e.g., http://www.example.com), your browser sends an HTTP request to the server hosting www.example.com, which then responds with the requested web page.
Some HTTP request methods are GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE, PATCH
*More to read about HTTP later: https://developer.mozilla.org/en-US/docs/Web/HTTP*
## HTTPS (HyperText Transfer Protocol Secure)
HTTPS is the secure version of HTTP. It adds a layer of encryption through SSL/TLS (Secure Sockets Layer/Transport Layer Security) protocols, ensuring that the data exchanged between the client and server remains confidential and secure.
How it works: Similar to HTTP, but the communication is encrypted. It uses **port 443** by default.
Example: When you visit a website with an "https://" URL (e.g., https://www.example.com), the data exchanged between your browser and the server is encrypted, providing a secure connection.
## DNS (Domain Name System)
DNS is a distributed system that translates human-readable domain names into IP addresses and vice versa, allowing computers to locate each other on the network.
How it works: When you enter a domain name in your browser, your computer queries a DNS server to obtain the corresponding IP address. This process involves multiple DNS servers, including authoritative servers and recursive servers.
Example: When you enter "www.example.com" in your browser, DNS resolves it to an IP address (e.g., 192.168.1.1), allowing your computer to connect to the correct server.
## ARP (Address Resolution Protocol)
ARP is used for mapping an IP address to the corresponding physical (MAC) address on a local network.
How it works: When a device needs to communicate with another device on the same local network, it uses ARP to discover the MAC address associated with a specific IP address.
Example: Before sending data to another device in the local network, a device might use ARP to determine the MAC address of the target device.
## SMB (Server Message Block)
SMB is a network protocol used for file and printer sharing, as well as communication between computers in a network.
How it works: Devices use SMB to share files, printers, and other resources on a network. It operates over TCP/IP and allows for the authentication and authorization of users.
Example: In a Windows network, when you access a shared folder on another computer, SMB is often used to facilitate the file sharing.