- Today
- Total
목록프로그래밍 (Programming)/네트워크 스택 (17)
Byeo
accept system call의 개요와 관련된 내용은 이전 포스트에 정리되어 있습니다.: https://byeo.tistory.com/entry/accept-system-call-Intro accept system call 0 - Intro일반적인 BSD Socket API는 server가 socket을 생성하고 bind 하고 listen 하면, 그다음은 accept을 수행합니다. 이 accept은 client가 연결 요청을 시도 함으로 인해 listen queue에 차있는 established packet을 꺼내온byeo.tistory.com 언제나 그렇듯, __sys_accept에서 시작합니다. 단, 함수 명의 끝에 4가 붙어있습니다.0. Parameteraccpet의 parameter는 조금 특..
일반적인 BSD Socket API는 server가 socket을 생성하고 bind 하고 listen 하면, 그다음은 accept을 수행합니다. 이 accept은 client가 연결 요청을 시도 함으로 인해 listen queue에 차있는 established packet을 꺼내온 뒤, socket()으로 생성했던 fd와는 다른 새로운 fd(!)를 생성하여 userspace에 제공합니다. accept에서 확인해야 할 점은 다음과 같습니다. 1. TCP Passive open 3-way handshake 수행 지점:server의 3-way handshake (SYN | ACK 반환)는 listen이 하는 것도 아니고, accept이 하는 것도 아닙니다.(1) Kernel이 SYN packet을 받으면(2)..
이전 포스트: https://byeo.tistory.com/entry/listen-system-call-2-inetlisten listen system call 2 (inet_listen)이전 포스트: https://byeo.tistory.com/entry/listen-system-call-1-syslisten listen system call 1 (__sys_listen)BSD socket API에서 server쪽은 bind를 실행한 뒤, listen을 시작합니다. Application이 listen을 시작하면 이제 받byeo.tistory.com sk->sk_prot->hash(sk)는 tcp_prot 구조체에 선언되어 있고, inet_hash 함수포인터를 값으로 갖고 있습니다. 4. inet..
이전 포스트: https://byeo.tistory.com/entry/listen-system-call-1-syslisten listen system call 1 (__sys_listen)BSD socket API에서 server쪽은 bind를 실행한 뒤, listen을 시작합니다. Application이 listen을 시작하면 이제 받을 수 있게 됩니다. 이 때, listen은 client가 요청한 연결들을 보관하는 함수라고 볼 수 있을byeo.tistory.com sock->ops->listen 함수는 inet_listen입니다. 현재까지 흐름도 2. inet_listen// net/ipv4/af_inet.c/inet_listen() :193/* * Move a socket into listen..
BSD socket API에서 server쪽은 bind를 실행한 뒤, listen을 시작합니다. Application이 listen을 시작하면 이제 받을 수 있게 됩니다. 이 때, listen은 client가 요청한 연결들을 보관하는 함수라고 볼 수 있을 것 같은데요. 그 보관 가능한 최대 개수가 listen system call의 2번째 인자인 'backlog'라고 보면 될 것 같습니다. 이 큐를 소모하는 주체(consumer)는 일반적으로 listen 다음에서 불리는 accept() system call입니다. backlog와 관련된 내용은 별도의 포스트에서 다뤄보겠습니다. 이 번에는 BSD socket API중에서 listen를 분석해보려고 합니다. 이전 포스트 (bind system call..
이전 포스트https://byeo.tistory.com/entry/bind-system-call-2-inetbind bind system call 2 (inet_bind)이전 포스트 (bind system call 1: __sys_bind)https://byeo.tistory.com/entry/bind-system-call-1 bind system call 1 (__sys_bind)BSD socket API에서 socket을 생성한 뒤에는 server-side 측에서 bind를 실행합니다. bind는 나의 ip:port를 sbyeo.tistory.com 현재까지의 흐름도__inet_bind를 이어서 탐색해 봅시다. 4. __inet_bind3) __inet_bind로 돌아와서3-1) 주소 검사// net..
이전 포스트 (bind system call 1: __sys_bind)https://byeo.tistory.com/entry/bind-system-call-1 bind system call 1 (__sys_bind)BSD socket API에서 socket을 생성한 뒤에는 server-side 측에서 bind를 실행합니다. bind는 나의 ip:port를 socket과 연결하는 역할을 수행하죠. 이 번에는 BSD socket API중에서 bind를 분석해보려고 합니다. 이전byeo.tistory.com 현재까지의 흐름도3. inet_bind__sys_bind에서 그 다음으로 호출하는 함수는 sock->ops->bind였습니다.// net/socket.c/__sys_bind() :1693 err =..
BSD socket API에서 socket을 생성한 뒤에는 server-side 측에서 bind를 실행합니다. bind는 나의 ip:port를 socket과 연결하는 역할을 수행하죠. 이 번에는 BSD socket API중에서 bind를 분석해보려고 합니다. 이전 포스트 (socket system call)https://byeo.tistory.com/entry/socket-system-call socket system call 1 (syscall_socket ~ __sock_create)int socket(int domain, int type, int protocol); socket 시스템 콜의 동작을 한 번 들여다봅니다! https://man7.org/linux/man-pages/man2/socket...
* BSD socket API에 대한 소개와 Kernel 흐름도를 정리합니다. (linux 5.15 기준)BSD Socket API Model* BSD Socket API: Berkeley Software Distribution Socket API출처: https://www.keil.com/pack/doc/mw6/Network/html/using_network_sockets_bsd.html출처: https://en.wikipedia.org/wiki/Berkeley_sockets 1. Socket()socket(int address_family, int socket_type, int protocol); Socket Systemcall: https://byeo.tistory.com/entry/socket-..
이전 포스트: https://byeo.tistory.com/entry/socket-system-call-3 socket system call 3 (tcp_v4_init_sock)이전 포스트: https://byeo.tistory.com/entry/socket-system-call-2 socket system call 2 이전 포스트: https://byeo.tistory.com/entry/socket-system-call socket system call 1 int socket(int domain, int type, int protocol); socket 시스템 콜의 동byeo.tistory.com 7. sock_map_fd마지막으로 sock_map_fd 함수를 거칩니다. 이 함수는 기존에 tcp_ip..