Some network apps
- e-mail
- web
- text messaging
- remote login
추가적으로 코딩하는 입장에서는 단순히 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들끼리의 데이터를 주고받는 것 또한 비슷하게 이해할 수 있다.
서로 다른 socket들을 연결하기 위해서는 일종의 이름이 필요한데 이는
IP 주소
와 port number
를 통해 식별한다.
사실 대부분의 서버들이 port number 80번을 사용하고 있다. 앞서 언급한 것처럼 DNS를 통해 인터넷 주소를 IP 주소로 변환은 해주지만, port number가 사이트마다 다르다면, 그것 또한 전부 다 알아야하는 문제점이 발생하기 때문이다.
Sockets
process sends/receives messages to/from its sockets
- sending process shoves messages out door
- 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?
- data integrity
→ application에 따라 보낸 packet이 경우 반드시 도착해야하는 것이 있고, 아닌 경우가 있다.
- timing
→ application에 따라 packet이 전달되기까지 시간이 짧아야하는 경우가 있다.
- throughput
- security
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
- uses TCP
순서는 다음과 같이 진행된다.
- client initiates
TCP connection
(creates socket) to the server, port 80
- server accepts TCP connection from the client
- HTTP messages exchanged between the browser and the Web server
- TCP connection closed
HTTP connections
앞서 언급한 것처럼 TCP를 사용할 때 TCP connection을 사용하는 방법에 따라 2가지고 나눠진다.
→ 현재 브라우저에서는 persistent HTTP를 기본으로 사용한다.
non-persistent HTTP
- at most one object sent over TCP connection
→ 즉 닫으면 connection도 사라진다
- downloading multiple objects required multiple connections
persistent HTTP
- multiple objects can be sent over single TCP connection between client, server
What is a socket?
- An interface between application and network
- 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
SOCK_DGRAM
- no notion of “connection”
Sockets API
- bind : 특정 port에 bind를 시키겠다는 것
- accept : client로 부터 정보를 받을 준비가 되었다는 것