CS2105 3: Application Layer - 2

brandon·2023년 8월 29일
0

Network

목록 보기
2/11

1. Domain Name System

  • Servers communicate using ip addresses.

  • However, its easier for us to remember the host names instead.

  • This is why DNS server helps translating the host names to ip addresses.

  • Two ways to identify the host are:

    • Hostname : url
    • IP address : 32 bits segemented to 4 parts.
  • Domain Name System helps translating the host name into an ip address.

  • Sometimes the ip address can be multiple of them.

  • Canonical names are the official names of the host name.

    • Accessing through

DNS: Resource Records (RR)

  • A is

Distributed, Hierarchical Database

  • Goes down each level.
  • Root Server:
  • Top Level Domains: .com, .org, .net, .edu, .sg, .uk, .jp...
  • Authoritative Server: Organization's own DNS server(s).

Local DNS Server

  • When host makes a DNS query, the query is sent to its local DNS server.

DNS Caching

  • Local DNS server caches the query (name-to-address) information in cache.
  • has expiracy date (Time To Leave (TTL)), in case ip addresses change, or other infos change.
  • DNS runs over UDP.
    • Packet loss does not happen usually, because the request is sent to local DNS server.
    • If it is lost, can query again.
    • Browser sends multiple DNS query back-to-back, in case one query is lost, other query can get in.
    • TCP is slower, because has to make a TCP connection first before the packets are sent.

DNS Name Resolution

  • The above is an iterative query.
  • local DNS server makes query to root, TLD, and authoritative DNS server, then stores the information.
  • Above is a recursive query.
  • iterative query is used more commonly than recursive query.

2. Socket Programming

Process

  • program running within a host.
  • Within the same host, two processes communicate using Inter-Process Communication (IPC).
  • Processes in different hosts communicate by exchanging messages.

Addressing Processes

  • IP address is 32-bit integer (e.g. 999.999.99.99)
  • IP address is not sufficient to identify a process running in a host.
  • IP address can identify a host, but does not know which process to pass the packets to, because there could be multiple processes.
  • A process is defined by (IP address and Port Number).
  • Port number is 16-bit integer.

Socket

  • Application interface between application processes and transport layer. (WHY?)
  • Could think of it as a set of APIs.

Socket Programming

  • TCP socket and UDP socket.

UDP Socket

  • Has no connection between the server and the client.
  • Client sends each packet that contains the IP addresses and port number of the destination.

UDP Socket Process

  • Datagram is a name of packet for UDP.

Example: UDP Socket Server

  • AF_INET is a specific version if IP address. Will be covered in future lectures.
  • Binding to '' means to bind to the localhost.
  • recvfrom() inside the paranthesis is the byte size of the buffer.

Example: UDP Socket Client

  • mesasge.encode() is to change string to bytes.

TCP Socket

  • TCP connection set when client creates a socket.
  • Server TCP creates a new socket for server process to communicate with the client.
    • This allows the server to communicate with multiple clients individually.

Example: TCP Server Socket

  • serverSocket.list() waits for the client to request for TCP connection.
  • accept() accepts the TCP connection, returning new socket to communicate with client socket.

Example: TCP Client Socket

  • connect() to send TCP connection request to the server socket.
  • Then is welcome socket necessary to create additional sockets for individual TCP connection requests?
profile
everything happens for a reason

0개의 댓글

관련 채용 정보