Computer Science/Computer Network

2. Application Layer

  • -
728x90
반응형

Some network apps

  1. e-mail
  1. web
  1. text messaging
  1. remote login
💡
즉, Application layer에 있는 것들은 network 기능이 있는 process (thread)라고 생각해주면 된다. 대표적으로 web-browser가 있다.

추가적으로 코딩하는 입장에서는 단순히 application layer들끼리의 소통이라고 이해하는 정도면 충분하다. 즉, 하위 layer에 대한 정보를 몰라도 무방하다는 것이다.

→ 즉 이것이 layer를 나눠놓음으로써 얻는 Encapsulation의 장점이다.

Client-server architecture

Server

  • always-on host : 즉 항상 internet에 연결되어있어야
  • permanent IP address를 가져야 한다

Client

  • may have dynamic IP addresses
  • do not communicate directly with each other

Process communicating

운영체제에서 배운 것처럼 1개의 compouter 내에서 process들 끼리의 정보 교환은 IPC를 통해 진행된다.

→ 즉, 내부적으로 interface를 OS가 제공한다.

마찬가지로, Application layer들끼리의 데이터를 주고받는 것 또한 비슷하게 이해할 수 있다.

💡
이러한 interface를 socket 이라고 하는 것이다.

서로 다른 socket들을 연결하기 위해서는 일종의 이름이 필요한데 이는

IP 주소port number를 통해 식별한다.

💡
IP주소를 통해 컴퓨터를 특정하고, port number를 통해 process에 대응되는 socket를 특정한다고 생각해주면 된다.
💡
추가적으로 DNS가 인터넷 주소를 IP주소로 변환해준다. 포트 넘버는 변환해주지 않는다.

사실 대부분의 서버들이 port number 80번을 사용하고 있다. 앞서 언급한 것처럼 DNS를 통해 인터넷 주소를 IP 주소로 변환은 해주지만, port number가 사이트마다 다르다면, 그것 또한 전부 다 알아야하는 문제점이 발생하기 때문이다.

Sockets

process sends/receives messages to/from its sockets

  1. sending process shoves messages out door
  1. sending process relies on transport infrastructure on other side of door to deliver message to socket at receiving process

What transport service does an app need?

  1. data integrity

    → application에 따라 보낸 packet이 경우 반드시 도착해야하는 것이 있고, 아닌 경우가 있다.

  1. timing

    → application에 따라 packet이 전달되기까지 시간이 짧아야하는 경우가 있다.

  1. throughput
  1. security
💡
즉, application layer가 transport layer로부터 어떤 기능을 제공받고 싶은지에 대한 내용이다.
💡
현재 transport layer가 제공해주는 기능은 data integrity가 유일하다.
💡
timing과 throughput은 미묘하게 차이가 있다. 전자는 1개의 packet이 도달하는 시간에 대한 개념이고, 후자는 양에 대한 개념이다. 예를 들어 음성전화를 timing이 중요하고, 영화 다운로드는 throughput이 중요하다.

Internet apps : application, transport protocols

HTTP overview

HTTP : hypertext transfer protocol

  • client/server model
    • client : browser that requests, receives (using HTTP protocol) and displays Web objects
    • server : Web server sends (using HTTP protocol) objects in response to requests
💡
즉, client의 요청에 따라 server가 hypertext를 전송하는 protocol이다
💡
HTTP는 TCP를 사용한다. 따라서 HTTP를 하기 전에 TCP connection이 수반되어야 한다.
  • uses TCP

    순서는 다음과 같이 진행된다.

    1. client initiates TCP connection (creates socket) to the server, port 80
    1. server accepts TCP connection from the client
    1. HTTP messages exchanged between the browser and the Web server
    1. TCP connection closed
  • HTTP is stateless

    → server maintains no information about past client requests

    💡
    즉, 현재 request를 처리하는데에만 관심이 있다.

HTTP connections

앞서 언급한 것처럼 TCP를 사용할 때 TCP connection을 사용하는 방법에 따라 2가지고 나눠진다.

→ 현재 브라우저에서는 persistent HTTP를 기본으로 사용한다.

non-persistent HTTP

  1. at most one object sent over TCP connection

    → 즉 닫으면 connection도 사라진다

  1. downloading multiple objects required multiple connections
💡
즉, request에 대한 response가 끝나면 TCP connection을 끊는다.

persistent HTTP

  1. multiple objects can be sent over single TCP connection between client, server
💡
예를 들어 10개의 obejct가 있다고 가정해보자. 해당 object를 읽을 때마다 TCP connection을 만들면 non-persistent HTTP이고, 재활용하는 경우가 persistent HTTP이다.

What is a socket?

  • An interface between application and network
    💡
    일종의 OS가 제공해주는 API의 일종이라고 생각하면 된다.
    💡
    현재 OS에서는 transport layer가 2가지 protocol이 존재한다. 각각 UDP와 TCP이다. 즉 application layer는 TCP socket과 UDP socket 중 1개를 선택해야 한다.
  • once configured, the application can
    • pass data to the socket for network transmission
    • receive data from the socket

Two essential types of sockets

SOCK_STREAM

  • a.k.a TCP
  • reliable delivery
  • in-order guaranteed
  • connection-oriented
  • bidirectional

SOCK_DGRAM

  • a.k.a UDP
  • unreliable delivery
  • no order guaranteed
  • no notion of “connection”
  • can send or receive
💡
DGRAM : datagram을 의미한다.

Sockets API

  • bind : 특정 port에 bind를 시키겠다는 것
  • accept : client로 부터 정보를 받을 준비가 되었다는 것
💡
client쪽에서 connect를 부르게 되면 단단한 연결고리가 생성되는 것이다. 그 이후부터는 read, write를 하면 IPC하는 것 마냥 할 수 있는 것이다.
💡
client쪽에 bind가 없는 이유는 굳이 port를 지정할 이유가 없기 때문이다. 그냥 남는거 쓰면 되기 때문이다.
반응형
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.