[CrashCourse CS] #29 The Internet

Steve·2021년 9월 9일
0
post-custom-banner

Our computer is connected to a large, distributed network called the Internet.

LAN -> WAN -> Internet

LAN: Local Area Network - wifi router at home.
WAN: Wide Area Network - router by ISP(Internet Service Provider). Could be several routers.

Traceroute program - Can see data routes taking different places on the internet.


IP

  • Internet packets have to conform to a standard called the Internet Protocol, or IP.
  • IP is very low level protocol - there isn't much more than a destination address in a packet's header, which is the metadata that's stored in front of the data payload.
  • This means that a packet can show up at a computer, but the comptuer may not know which application to give the data to; Skype or Call of Duty.
  • For this reason, more advanced protocols were developed that sit on top of IP.

UDP

  • One of the simplest and most common is the User Datagram Protocol, or UDP.
  • UDP has its own header, which sits inside the data payload.
  • Inside of the UDP header is some useful, extra information. (Port number, checksum, etc)

Port number

  • Every program wanting to access the internet will ask its host computer's Operating System to given a unique port.
  • When packet arrives to the computer, the Operating System will look inside the UDP header and read the port number.

Checksum

  • Checksum allows the data to be verified for correctness.
  • As the name suggests, it does by checking the sum of the data.
  • Before the packet is sent, the transmitting computer calculated the checksum by adding all the data together.
  • In UDP, the checksum value is stored in 16 bits. If the sum exceeds the maximum possible value, the upper-most bits overflow and only the lower bits are used.
  • When the receiving computer gets this packet, it repeats the process, adding up all the data.
  • Computer checks by comparing the checksum in the header with the actual sum of the data.

  • Unfortunately, UDP doesn't offer any mechanisms to fix the data, or request a new copy - receiving programs are alerted to the corruption, but typically just discard the packet.
  • Also, UDP provides no mechanisms to know if packets are getting through - a sending computer shoots the UDP packet off, but has no confirmation it ever gets to its destination succesfully.
  • Some applications, like Skype, are ok with this becuase UDP is really simple and fast. When we have bad internet connection, skype gets all glitchy since only some of the UDP packets are making it to the computer.

IP gets the packet to the right computer, but UDP gets the packet to the right program running on that computer.


TCP

  • When data must be transferred without loss (like email), programs use TCP, Transmission Control Protocol.
  • Like UDP, it rides inside the data payload of IP packets - for this reason, people refer to this combination of protocols as TCP/IP.
  • Like UDP, the TCP header contains a destination port and checksum and more features.
  1. First, TCP packets are given sequential numbers to allow a receiving computer to put the packets into correct order, even if they arrive at different times across the network.
  2. Second, TCP requires that once a computer has correctly received a packet - and the data passes the checksum - that it send back an acknowledgement, or "ACK", to the sending computer.
    • If ACK arrives succesfully, the sender can transmit the next packet.
    • If ACK delays or does not arrive, the sender will just retransmit the same packet. The receiver has sequence numbers and if a duplicate packet arrives, it can be discarded.
  • TCP can send many packets and have many ACKS, which increases bandwidth significantly, since you aren't wasting time waiting for acknowledgement packets to return.
  • Interestingly, the success rate of ACKs and also the round trip time between sending and acknowledging can be used to infer network congestion - TCP uses this information to adjust how aggressively it sends packets: a mechanism for congestion control.

TCP can handle out-of-order packet delivery, dropped packets including retransmission, and even throttle its transmission rate according to available bandwidth

  • The single biggest downside of TCP are all those acknowledgement packets doubles the number of messages on the network and yet not transmitting any more data.
  • The overhead, including associated delays, is sometimes not worth the improved robustness especially for time-critical applications like multiplayer FPS.

DNS

  • When a computer wants to make a connection to a website, you need two things - IP address, port.
  • A service that maps domains names to addresses - DNS, Domain Name System .
  • When a domain is typed onto a browser, it goes and asks a DNS server, usually one provided by ISP, to lookup the address.
  • DNS consults its huge registry, and replies with the address, if one exists - browser shoots off a request over TCP for the website's data.

  • There are over 300 million registered domain names, so to make a DNS Lookup a little more menageable, it's stored in a tree data structure.

Network Layers

  • Physical Layer - electrical signals on wires, radio signals transmitted through the air.
  • Data Link Layer - MAC address, collision detection, exponential backoff and similar low level protocols that mediate access to the physical layer are part of the Data Link Layer.
  • Network Layer - above the Data Link Layer, where all the switching and routing technologies operate.
  • Transport Layer - protocols like UDP, TCP, which are responsible for point to point data transfer between computers, and also things like error detection and recovery when possible.
  • Session Layer - where protocols like TCP and UDP are used to open a connection, pass information back and forth, and then close the connection when finished, what's called a session.

These are the bottom five layers of the Open System Interconnection (OSI) model, a conceptual framework for compartmentalizing all these different network processes.

OSI model has two more layers, the Presentation Layer and the Application Layer, which include things like Skype, HTML decoding, streaming movies and more.


Vocabulary

  • backbone - 척추
  • infer - 추론하다.
  • throttle (something) back/down/up - (자동차 등의 연료 조절판을 조절하여) (~의) 속도를 낮추다/낮추다/높이다
  • overhead - 비용. 특정한 목표를 달성하기 위해 간접적 혹은 추가적으로 요구되는 시간, 메모리, 대역폭 혹은 다른 컴퓨터 자원을 말한다.
  • rubustness - very strong or healthy.

Thougts

  • 코드스테이츠에서 OSI layer 이나 TCP, UDP 에 배울 때는 사실 이해가 안되었는데, 여기서 너무 쉽고 재미있게 설명해줘서 이해가 단번에 되었다. crashcourse computer science 는 미쳤다. 항상 현업 전문가의 칭찬이 댓글란에 적혀있는 이유가 있다. 크래쉬코스의 내용만 내 것으로 만들어도 computer science 의 기본은 알게 될 것 같다.
profile
게임과 프론트엔드에 관심이 많습니다.
post-custom-banner

0개의 댓글