Slides from University about Network and Security. The Pdf explores networking principles, defining protocols like TCP and UDP, and their role in communication. The Pdf, a presentation for Computer science students, delves into socket concepts, HTTP overview, and methods for improving HTTP performance.
See more39 Pages


Unlock the full PDF for free
Sign up to get full access to the document and start transforming it with AI.
A protocol defines the format and the order of messages exchanged between two or more communicating entities, as well as the actions taken on the transmission and/or receipt of a message or other event. In other words, a protocol is a set of rules and conventions that govern how two parties communicate.
Human Time Protocol Lecture Question Protocol Practical Question Protocol
How do we figure out the path our packets take to another host? Packets carry a Time-To-Live (TTL): number of "hops" before being dropped by a packet switch A packet that is sent from a source host to a packet switch, another packet switch, then a destination host, has a hop count of 3 To prevent packets from endlessly looping, TTL is decremented by each packet switch When TTL reaches 0, the packet switch drops the packet and sends an error message back
Two major protocols on the transport layer you will use in assignment 1:
AF_INET, SOCK_STREAM, omit protocol number.
AF_INET, SOCK_DGRAM, omit protocol number. The network is dumb, the endpoints are smart.
DNS (Domain Name System) typically uses UDP port 53 as its well-known server port. When clients make DNS requests, they use ephemeral (temporary) ports that their operating system assigns automatically. These ephemeral portsare typically in the range 32768-65535 on modern systems, though the exact range varies by operating system.
Sockets are objects managed by the kernel to represent endpoints for network-ish communication. Provide access not only to TCP and UDP, but also to protocols from some of the other (generally lower) layers, and even to protocols unrelated to the internet (such as interprocess communication, bluetooth, etc .. )
The behaviour of a socket is mainly determined by: Its address family- AF_INET (6) for IP(v6) -; Its type. The two major ones are SOCK_STREAM and SOCK_DGRAM which have TCP- and UDP-like semantics, respectively. The protocol, which is usually inferred from the address family and type.
Socket:
A day in the life of a TCP socket For when we didn't have time for the drawing.
Server SOCKET serverSocket = socket (AF_INET, SOCK_STREAM) BIND server Socket. bind ( ('', serverPort) ) LISTEN server Socket. listen (1) ACCEPT connectionSocket, addr = serverSocket. accept () RECEIVE Data (request) connectionSocket. send (echoedSentence) - SEND Data (reply) CLOSE connectionSocket. close () Note this uses two sockets on the server side!
Client CONNECT clientSocket . connect ( (serverName, server Port)) sentence = connectionSocket. recv (1024) SEND clientSocket . send (sentence) echoSentence = clientSocket. recv (1024) - RECEIVE CLOSE clientSocket.close()
Application layer protocols often have default server port numbers:
SOCKET clientSocket = socket (AF_INET, SOCK_STREAM) Connection establishment
Registry is administered by IANA (Internet Assigned Numbers Authority) For security binding to ports < 1024 under Linux requires root privilege.3
HTTP overview (HTTP 1.1 - RFC 26164 / 7230-7237) HyperText Transfer Protocol Web's application layer protocol
Some terminology: Web page consists of objects Object is simply a file: HTML file, JPEG image, Java applet, JavaScript Code snippet, Cascading Style Sheet, etc. Objects are referenced by Uniform Resource Locator (URL) a.k.a. Uniform Resource Identifier (URI). Formally, a URL is a special case of a URI, see RFC 3986, but in practise the two terms are used interchangeably by most. A basic URL consists of a scheme (http://), host part (www.example.org), and a path (/index.html). If any of these are missing, they are implied. Most Web pages consist of a base HTML (HyperText Markup Language) file and several referenced objects HTTP (HyperText Transfer Protocol) is the protocol used to retrieve these objects
Components of the Web application The Web uses the client-server model: Client: browser program that requests, receives and displays objects Chromium, Firefox, qutebrowser, . .. Server: server program that sends objects in response to requests Caddy, Nginx, Apache, lighttpd, Yaws, ...
GET /index.html HTTP/1.1 Host: cs.ru.nl HTTP Request HTTP/1.1 200 OK Date: Wed, 31 Jan 2018 12:51:31 GMT Server: Apache/2.4.7 (Ubuntu) Last-Modified: Thu, 07 Jan 2016 14:12:37 GMT ETag: "14a-528bf10117f40" Accept-Ranges: bytes Content-Length: 330 Content-Type: text/html Web browser Web server HTTP response <html> </html> Actual webpage in HTML
Improving the performance of HTTP
HTTP and Round-trip time (RTT) RTT: time it takes for a message to travel from client to server & back HTTP uses TCP for its RDT; TCP is connection-oriented. Building a connection takes an additional round-trip. Initiate TCP connection RTT TCP handshake Request file (HTTP) UL RTT HTTP File received time 4 time
20
Persistence of HTTP connections Non-persistent: each object suffers a delivery of 2 RTTs Persistent: only one RTT is required to transfer HTTP HTTP HTTP Persistent connection Non-persistent connection
In this way, a DNS lookup may be resolved recursively, instead of iteratively. A name server is said to be authoritative for a domain or certain records, when they appear in one of its zones.
Many name servers can be put in one of the following two categories: Authoritative name servers, that answer only queries pertaining to their zones. DNS resolvers, nameservers that need not have any zones of their own, but only aim to resolve recursive DNS queries as quickly as possible, e.g. Google's 8.8.8.8 or Cloudflare's 1.1.1.1. When you connect to an access network, your OS usually obtains a suitable local DNS resolver (via e.g. DHCP or NDP) often running on (or via) the local router. But you can also configure the DNS resolver manually.
TCP is always bidirectional A TCP connection always has a source IP, source port, destination IP, and destination port. A TCP socket is therefore identified by the combination of source IP, source port, destination IP, and destination port. or rather: local IP, local port, remote IP, andremote port. Two TCP segments from different source endpoints with the same destination IP and destination port will not end up at the same socket! .. . . except at the start! (listening for new connections)
Three-Way handshake: step-by-step
A TCP segment 0 1 2 3 01234567890123456789012345678901 Source Port Destination Port Sequence Number Acknowledgement Number (if ACK set) Data Res- N CEUAPRSF Offset erved S W C R CS SY Window Size 000 REGKHTNN Checksum Urgent pointer (if URG set) Options Application layer message (payload / data) 4
Classless Inter-Domain Routing Better way: flexibly determine the network part by specifying the number of network bits: Variable-Length Subnet Masking
Addresses with network prefix in CIDR notation: 223.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 223.1.1.0/24 ... Also in IPv6: fe80 :: /64
Subnet mask notation: set all network bits to 1, all host bits to 0, use octet notation: 255.0.0.0, 255.192.0.0, 255.255.0.0 etc. Not usually used nowadays, never for IPV6.
How to use subnet masks? Hosts with identical network parts are in the same (link-layer) network Determining this: compare only the network part bits, just ignore the host part bits. The same, but in software terms:
Boundaries do not have to fall on octet boundaries; e.g .: 200.23.16.0/23 200. 23. 16. 5 11001000.00010111.00010000.00000101 Network Host
Within each IPv4 prefix, two addresses are special: The host-part set to all-ones (e.g. 192.168.1.255/23) Subnet broadcast address: traffic gets sent to all hosts in the prefix Sometimes you just need this (you'll see why in a bit) Exactly how depends on the link layer May be forwarded by routers if appropriate There's also the link-local broadcast address 255.255.255.255 which should never be forwarded The host-part set to all-zeroes (e.g. 192.168.0.0/23) 'Network identifier' (RFC919) often not used for historic reasons.
In IPv6: Only the host-part set to all-zeroes has a special meaning (you'll probably never use: the subnet-router anycast address.) IPv6 doesn't do broadcasts Instead, it has something called link-local multicast What is multicast?
How does each network know what address to use? IP addressing is hierarchical: The whole IP space is divided up by ICANN, again through IANA Each Regional Internet Registry gets /8 blocks (IPv4) Afrinic (Africa) ARIN (North America) APNIC (Asia and the Pacific) LACNIC (Latin America) RIPE NCC (Europe) For IPV6, mostly /22 and /23 blocks are used Organizations (like ISPs, but basically anyone) can request allocations from the RIRs The blocks are subdivided as needed to allocate for these requests ISPs then allocate smaller blocks to their customers, either statically or dynamically Customers can further subdivide as needed to run multiple link-layer networks