4.1 The Internet

IP Address

What is an IP Address: A numeric label assigned to every device that uses the internet to communicate. IP stands for Internet Protocol. IP addresses are the identifiers that allow data to be sent over the internet.

  • contain location information
  • allows devices to communicate over internet
  • differentiates between computers, routers, and websites

A set of 4 8-bit numbers seperated by periods. Each number is in the range 0-255. Exceptions are 0.0.0.0 and 255.255.255.255

  • 4.20.0.255
  • 16.23.234.1

ipaddresstypes

IP Addresses allow us to send information in three main ways.

  1. Unicast - a specific device. Internet wide access. TCP is used
  2. Multicast - a group of devices. It is specific range of IP addresses. Internet-wide access. UDP is used
  3. Broadcast - all devices. LAN-wide. Data stops at the router. UDP is used

Popcorn Hack - Finding your IP

  • https://www.whatsmyip.org/ works for both mac and windows
  • Alternatively, you can open up a command prompt (cmd into search bar), and type ipconfig

The OSI Model and TCP/IP Model

TCP/IP Protocols

A TCP/IP Protocol is a set of rules that governs something within computer communication. The IETF, or Internet Engineering Task Force, manages these rules and facilitates the open development of them.

Example: ASCII Protocol

  • ASCII (American Standard Code for Information Interchange) is a internet protocol that you may be familiar with, is a type of character encoding
  • ASCII is a protocol governing how text is represented as binary
  • 128 characters, 95 printable

There are many more protocols, each governing a specific area of how computer communicate. Ex. ARP, DNS, FTP, UDP, PPP, SAP

We obviously can’t cover every protocol, but we’ll be talking about a few important ones today.

OSI Model

The OSI model, also known as the Open Systems Interconnection Model, helps represent communications between two computers.

  • The OSI model helps coordinate and classify standards
  • Each of the many protocols can be classified into one of the seven layers
  • Each layer has a function and the protocols in that layer all help with that function

Layer Name Function Example
1 Physical Transport of data between tangible, physical things DSL
2 Data Link Device identification and forwarding on a LOCAL network (i.e. home, school) PPP
3 Network Manages identification and path that a device should take, very few of these protocols STP
4 Transport Manages transport of data between computers (delivery method, i.e. fast vs slow) UDP
5 Session Manages connectivity between devices SAP
6 Presentation Translates from data sent between computers (binary) to something humans can understand TLS
7 Application User Interaction, like resource sharing HTTP

Popcorn Hack

  • We just gave an example of a protocol, ASCII, above. What OSI Layer does ASCII fall into?
  • Give another example of a protocol from that layer
  1. Presentation because it switches between binary to human text

TCP/IP Model

  • Another method of classifying protocols
  • Simplifies OSI model into four layers
  • Application, Presentation, Session layers are summarised into one Application layer
  • Data Link and Physical layers and summarised into one Link or Physical layer
  • This layer, also known as Network Access, is focused on the transport of bits (1s and 0s) between networks

Protocols

DNS - Domain Name Service

  • DNS, or Domain Name Service, is a naming system for websites on the internet.
  • DNS assigns and has records that relate domain names to ip addresses

What is a Domain Name?

  • Domain Names are strings used to identify addresses
  • They map hard to remember IP addresses into simple string of text
  • Would you rather remember 162.159.128.233 or discord.com?
  • Each website has its own IP address that you are sent to when you visit the website
  • https://www.nslookup.io/website-to-ip-lookup/
  • nslookup (website) in command prompt

Popcorn Hack

  • Open up a command prompt and type “nslookup google.com”
  • You should get 142.250.68.78, we mainly care about the bottom address for now
  • Try visiting that website in your search bar!

Subdomains

  • Subdomains are a prefix added to a domain to separate parts of the website
  • There can many subdomains, up to 127, and each can be up to 64 characters long
  • We saw an example of this in our passion projects
  • (SUBDOMAIN).stu.nighthawkcodingsociety.com

Domain Name Service Providers

  • DNS Providers manage and sell domain names

Popcorn Hack

  • List 4 more websites you use often and their IPs
  • What’s a subdomain of your passion project backend from last time?
  • What’s the domain of your current binary CPT project?
  • Youtube - 142.250.113.93
  • Google - 142.250.217.142
  • Github - 103.224.182.241
  • Slack - 3.143.19.65
  • hanlunli - subdomain
  • napoleon-bonaparte-official

HTTP vs HTTPS - HyperText Transfer Protocol

HTTP (Hypertext Transfer Protocol) and HTTPS (Hypertext Transfer Protocol Secure) are both protocols used for transferring data over the web. The key difference lies in the security aspect.

HTTP is the standard protocol for transmitting data over the internet. However, it does not provide any encryption, making it susceptible to eavesdropping and unauthorized access. This means that any information exchanged between the user’s browser and the website, such as login credentials or personal data, is sent in plain text.

HTTPS

On the other hand, HTTPS adds a layer of security by incorporating SSL/TLS (Secure Sockets Layer/Transport Layer Security) encryption. This encryption ensures that the data exchanged between the user and the website is encrypted, making it much more challenging for malicious actors to intercept or tamper with the information.

image

We SSL based encryption last trimester with certbot. Certbot generated SSL certificates for us to ensure HTTPS connection between the client and your website.

image

TCP and UDP - Transmission Control Protocol and User Datagram Protocol

TCP and UDP are both Transport protocols (layer 4 of OSI and layer 3 of TCP/IP). This means they are a set of rules that specify how data is exchanged between devices over the Internet.

TCP Packets

What’s in a TCP packet? Packets are a unit of information that are sent over the network. They contain user data, among other identification information.

image

TCP Handshake

The TCP handshake process - this is how a TCP session is initiated.

Step 1: Client A requests a client-to-server communication session with Server B (SYN)

image

Step 2: Server B acknowledges client-to-server communication session, requests server-to-client communication session (SYN-ACK)

image

Step 3: Client A acknowledges server-to-client communication session (ACK)

image

After these steps are executed in order, the communication pathway is established between Client A and Server B.

How does TCP actually send the data?

  1. Client A wants to send some file to Server B. TCP will first split the data into 6 segments
  2. TCP forwards the first 3 segments to the Server B
  3. Server B must acknowledge that it has received the segments by sending back an ACK. If Client A doesn’t receive the ACK, it resends the segments
  4. Client A sends the remaining 3 segments
  5. Again, Server B must send back an ACK to confirm it has received the other 3 segments

TCP Session Termination

  1. Client A sends segment to server B with the FIN flag to terminate the client-to-server session
  2. Server B sends ACK to client A
  3. Server B sends FIN to client A to terminate the server-to-client session
  4. Client A sends ACK to server B
  5. The session closes

image

UDP

Enough about TCP… what about UDP?

UDP Pros:

  • Little cost
  • Faster

UDP Cons:

  • Little data checking
  • Generally unreliable, as no ACK messages are sent
  • Packets may arrive out of order or have duplicates/missing packets

UDP sends out all packets at once without any form of handshake or acknowledgement.

Popcorn Hack

  • When do we use UDP? While it seems terrible, try to think of some use cases!
  • When might we use TCP? -UDP, or User Datagram Protocol, finds application in scenarios prioritizing low-latency communication where occasional data loss is acceptable. Real-time applications like online gaming, video conferencing, and VoIP benefit from UDP’s swift data transmission without the overhead of acknowledgment and retransmission delays. Additionally, UDP is favored in streaming services, live broadcasts, and IoT settings where quick delivery of small data packets takes precedence over ensuring every packet’s arrival. Its lightweight nature makes UDP suitable for DNS queries, network monitoring, and situations requiring broadcast or multicast communication. While lacking TCP’s reliability features, UDP’s speed and efficiency make it a pragmatic choice in specific use cases where real-time responsiveness trumps guaranteed data delivery.

Homework Questions

Please answer all of these questions on your personal blog and explain. Don’t just give an answer. Homework is due Sunday night at 6 pm

IP Addresses

  1. Which of the following IP Addresses are possible? Explain (yes/no) for each answer choice.
    • 1.1.1.1.1 => no b/c 5 sets
    • 23.23.23.23 => yes b/c it has 4 sets and is less than 255.
    • 134.492.100.0 => no b/c greater than 255
    • 255.256.55.255 => no b/c greater than 255
    • 2.93.255.19 => yes b/c it has 4 sets and is less than 255.
  2. If Dian Du isx at home on his home network and sends a message to every computer on the network, what is this an example of? Explain.
    • Multicast
    • Unicast
    • Broadcast
  • Broadcast because it is sending a message to multiple computers in the network instead of specific ones.

    Models

    1. Three of the four following protocols are on the same layer. Identify which ones and what layer they are on, and why they are on each layer:
    • ASCII (see above for information) - presentation
    • FTP (facilitates transfer of files over the internet) - application
    • TLS (see HTTPS section) - presentation
    • USB (permits data exchange between electronics) - physical
  • ASCII and TLS because they are both presentation layers. They both translate data between binary and an understandable format for humans. I’m not sure what the third one is supposed to be. FTP is application because it transfers files and USB is physical because it transfers data between physical electronics.
  1. Telnet is a internet protocol which allows remote access to other computers over a local network or the internet. What layer of the OSI model would this protocol be located on? What is the function of this layer?
  • Telnet is at the application layer because it provides service to end-users. It stands as the mid-ground between the software applications and the network.

DNS

  1. Bob wants to use the domain bob.is.the.best.com. What domain should he buy from a DNS provider (assume it is available)? What would be the subdomains?
  • Bob should buy the domain ‘the.best.com’ and the subdomains are ‘bob’ and ‘is’

HTTP and HTTPS

  1. What is a difference between HTTP and HTTPS?
    • HTTPS is an extension of HTTP with security that ensures that data transmitted between the user and the website is encrypted and secure. HTTPS is ideal for websites that handle data from user that may be sensitive. - What protocol does HTTPS use that HTTP doesn’t?
    • HTTPS uses the SSL/TLS protocols, which HTTP doesn’t. SSL and TLS are cryptographic protocols that provide secure communication over a computer network, helping to add an additional layer of security.
  2. Last trimester we sent HTTP requests for our passion projects
    • Did we use HTTP or HTTPS?
    • We used HTTP because we didn’t use encryption or have any security measures for creating a secure website. - What are the benefits and disadvantages of this?
    • While HTTP has its advantages in simplicity and performance, the lack of security features makes it unsuitable for scenarios where data confidentiality is important. HTTPS is better for most websites to ensure security.

      TCP and UDP

  3. Bob is setting up a video streaming service, and he needs the stream to be real time.
    • What protocol should he use, TCP or UDP? Why?
    • UDP is preferred for real-time applications like video streaming due to its lower latency and simpler connection establishment. Its design prioritizes speed by avoiding the complex connection setup of protocols like TCP, making it suitable for scenarios where quick transmission of data is crucial, like streaming.
    • What are some cons of this protocol? Give an example of a potential issue.
    • The lack of reliability and error recovery mechanisms in UDP makes it unfavorable for applications that require guaranteed delivery of data. While it is good for real-time applications like video streaming, it can have problems such as using forward error correction, retransmission strategies, or application-layer error-handling mechanisms.
  4. TCP has error checking, which ensures that all packets arrive properly. Why is this important?
    • TCP’s error checking mechanisms is crucial in ensuring the reliability and accuracy of data transmission. By confirming the correct delivery of packets, addressing errors, and maintaining the order of data, TCP contributes to the dependable and error-free exchange of information over networks.
    • Give an example of how TCP ensures that there are no errors.
    • TCP ensures error-free data transmission through mechanisms such as checksums and acknowledgment. When a TCP client sends data to a server, it calculates a checksum for each packet, which is included in the packet header. When the packet is recieved, the server recalculates the checksum and verifies it against the received value. If the checksums match, the server sends an acknowledgment to the client, confirming. If the client doesn’t receive an ACK within a specified time, it assumes packet loss or corruption and triggers a retransmission. This process, including checksum verification and acknowledgment, ensures the accuracy and reliability of data transmission, making TCP well-suited for applications where error-free communication is crucial.
  5. Server A computer is communicating with Server B. They have already initiated communication and Server A is now attempting to send data to Server B.
    • How does Server B ensure that they have received any sent packets before Server A continues sending packets in TCP? In UDP?
    • In TCP, Server B ensures it has received sent packets from Server A through the acknowledgment mechanism. After receiving a TCP packet, Server B sends an acknowledgment to confirm successful receipt. TCP’s flow control further ensures that Server B can communicate its buffer capacity to Server A, preventing data overflow. UDP doesn’t have a built-in acknowledgment or flow control mechanisms. So, Server B in UDP does not actively acknowledge packet receipt and there is no automatic retransmission of lost packets. - What is another use of this?
    • Another use of TCP can be used in detecting and addressing packet loss or corruption during transmission. When Server B sends an acknowledgment to Server A, it signifies the successful receipt and serves as feedback on the integrity of the received packet. If an acknowledgment is not received or is delayed, it means there may be potential issues with the transmitted packet, such as loss or corruption. This prompts Server A to retransmit the missing or corrupted packet, ensuring that the data reaches Server B accurately and in the correct order.