Skip to content

TCP \ IP Notes

Robbie Hume edited this page Feb 9, 2023 · 6 revisions

OSI Model:

  • Helps provide a big picture view and isolate issues to a certain layer
  • 7 layers:
    • (7) Application: where the application and user communicate; HTTP, SMTP, FTP, Telnet
    • (6) Presentation: format data for receiving application, also encrypt/decrypt data if needed
    • (5) Session: establish and terminate connections between devices
    • (4) Transport: TCP, UDP, port numbers
    • (3) Network: IP address and routing
    • (2) Data Link: MAC address, switches
    • (1) Physical: carry data across physical hardware; cable and hubs
    • All People Seem To Need Data Processing

TCP/IP Model:

  • 5 layers:

    • (5) Application: HTTP, SMTP, FTP; combines OSI layers 5-7 into one layer
    • (4) Transport: TCP, UDP
    • (3) Network: IP, routers
    • (2) Data Link: ethernet, switches
    • (1) Physical: cables
  • Data has a different name at different layers:

    • (5) data
    • (4) segment
    • (3) packet
    • (2) frame
  • Original TCP/IP model only had 4 layers (data link / physical were combined into one)

  • Classless Interdomain Routing (CIDR) and subnet masks:

    • Allows for more specific network address allocation
      • If a company needed 300 hosts, that's too many for a class C network, but if they used a class B then they would have 65,000+ wasted hosts
    • Also 4 octets
    • The bits set to 1 tell which part of the IP address is the network
    • The 0 bits are the hosts
    • Example:
      • IP address: 192.168.100.20
      • Subnet mask: 255.255.255.0
      • CIDR Notation: 192.168.100.20 /24
      • Network address: 192.168.100.0
        • Valid host addresses would be 192.168.100.1 - .254
        • .0 is reserved for the network address and .255 for the broadcast address
    • CIDR Notation:
      • Use /n after the IP address to indicate n bits used for subnet
        • Tells you how many first n bits are the network address
      • 172.16.1.0 /24
      • /24 = 255.255.255.0 = 1111 1111 1111 1111 1111 1111 0000 0000
    • CIDR Notation allows more specific network addresses
    • Can find out network address by doing bitwise AND with IP address and subnet mask
  • Each device on a LAN has its own private IP address and the router uses a single public IP address

  • For IP addresses, can think of the network address as the city/street in a mailing address and the host address would be the actual building number at that address - Ports could be thought of as different doors going into the building

  • Network port: identifies an application or service running on a networked device

Public vs Private IPs

  • A public IP address is the one that can be accessed directly over the internet and is assigned to your network router by your ISP
  • A private IP address is the address your network router assigns your device
    • Each device within the same network is assigned a unique private IP address. This is how devices on the same network communicate with each other
  • Private IP addresses are on one of these subnets:
    • 10.0.0.0
    • 172.16.0.0
    • 192.168.0.0

DNS:

  • Translates domain names into IP addresses

Address Resolution Protocol (ARP):

  • Used to find physical MAC hardware address of a device from its IP address
  • Source device sends out ARP request and receives back ARP response with MAC address of destination device

Network Address Translation (NAT):

  • NAT maps/translates one IP address(es) by modifying the network address info in the IP header of network packets
  • Allows for multiple devices to share the same public IP address
    • This helps prevent IPv4 address exhaustion

TCP vs UDP:

  • TCP (transmission control protocol): - Reliable, will resend any data segments that aren't received Uses sequence numbers to determine order of data - 3-way handshake to create connection - The benefits of reliability come at the cost of somewhat slower speed
  • UDP (user datagram protocol): - Unreliable, no error handling or sequencing - But it is faster - Useful for streaming or voice calls

Misc. Notes

Sockets:

  • A socket is one endpoint of a two-way communication link
  • An endpoint consists of a combination of an IP address and a port number

Port vs Protocol:

  • Protocol: how to communicate
  • Port: where to communicate

Subnets:

  • A subnet is a network inside a network. They make networks more efficient
  • Through subnetting, network traffic can travel a shorter distance without passing through unnecessary routers to reach its destination
  • Analogy: Imagine Alice puts a letter in the mail that is addressed to Bob, who lives in the town right next to hers. For the letter to reach Bob as quickly as possible, it should be delivered right from Alice's post office to the post office in Bob's town, and then to Bob. If the letter is first sent to a post office hundreds of miles away, Alice's letter could take a lot longer to reach Bob.
    • Like the postal service, networks are more efficient when messages travel as directly as possible
    • When a network receives data packets from another network, it will sort and route those packets by subnet so that the packets do not take an inefficient route to their destination
Clone this wiki locally