1. Trang chủ
  2. » Công Nghệ Thông Tin

Advanced Computer Networks: Lecture 4 - Dr. Amir Qayyum

43 17 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề TCP Connections
Tác giả Dr. Amir Qayyum
Trường học Standard Format University
Chuyên ngành Advanced Computer Networks
Thể loại lecture
Năm xuất bản 2023
Thành phố Standard City
Định dạng
Số trang 43
Dung lượng 584,4 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Advanced Computer Networks: Lecture 4. This lecture will cover the following: TCP connections; transmission control protocol, at osi transport layer; recall: each protocol provides service interface; per-process table of I/O channels; client-server connection; sending and receiving data;...

Trang 1

CS716 Advanced Computer Networks

By Dr. Amir Qayyum

Trang 2

Lecture No. 4

Trang 3

• Transmission Control Protocol, at OSI transport  layer

• Recall: each protocol provides service interface

Trang 4

• Transfers a stream of bytes (interpreted by  application)

Trang 9

• User Datagram Protocol, at OSI transport  layer

• Thin layer over IP

Trang 12

• Big­endian (Sun, SGI, HP): most 

significant byte

Trang 13

• Network byte order  is big­endian

• Use of network byte order

– imperative for some data (e.g., IP addresses) – good form for all binary data (e.g., 

application­specific)

– ASCII/Unicode are acceptable alternatives

Trang 15

• Socket address structures (all fields in network byte order except sin_family)

short   sin_family ; /* e.g., AF_INET */

ushort   sin_port ; /* TCP / UDP port */

Trang 17

char* inet_ntoa (struct in_addr  inaddr );

translate IP address to ASCII dotted­decimal notation (e.g., 

Trang 21

client server

my­machine mail.yahoo.com

I am  mail.yahoo.com, 

port b

I accept  connections

Trang 22

I am  mail.yahoo.com, 

port b

I accept  connections

Trang 24

– other possibilities:  AF_INET6  (IPv6),  AF_UNIX ,  AF_OSI  or  

AF_LOCAL  (Unix socket),  AF_ROUTE  (routing)

type: style of communication

– SOCK_STREAM  for TCP (with AF_INET)

– SOCK_DGRAM  for UDP (with AF_INET)

protocol: protocol within family

Trang 25

addrlen: length of address structure = sizeof (struct 

Trang 26

• Allocated and assigned by the Internet Assigned Numbers Authority (IANA)

Trang 27

int  listen  (int  sockfd , int  backlog );

Put socket into passive state (wait for connections rather than initiate a connection). Returns 0 on success, ­1 and sets errno on failure

sockfd : socket file descriptor (returned from socket )

backlog : bound on length of un­accept()ed connection 

queue (connection backlog); kernel will cap, thus better to set high

Trang 29

int   accept  (int  sockfd , struct sockaddr*  cliaddr , int* 

addrlen );

Accept a new connection (first one of the queue of pending connections). Returns file descriptor or ­1. Also sets 

Trang 30

Sending and Receiving data

Trang 33

int  sendto  (int  sockfd , char*  buf , size_t  nbytes , int 

flags , struct sockaddr*  destaddr , int  addrlen );

Send a datagram to another UDP socket. Returns number of bytes written or ­1. Also sets errno on failure

sockaddr_in)

Trang 34

int  recvfrom  (int  sockfd , char*  buf , size_t  nbytes , int 

flags , struct sockaddr*  srcaddr , int*  addrlen );

Trang 35

Tearing Down a Connection

Trang 36

• After close() , sockfd is not valid for reading or writing.

Trang 37

int  shutdown  (int  sockfd , int  howto );

Force termination of communication across a socket in one or both directions. Returns 0 on success, ­1 and sets errno on failure

Trang 40

socket bind listen socket

Trang 41

socket bind listen

Trang 42

client

server

socket bind socket

sendto

recvfrom sendto recvfrom

Ngày đăng: 05/07/2022, 12:04