Professional Documents
Culture Documents
Network
danny@cmlab.csie.ntu.edu.tw
Outline
OSI Overview
TCP/IP Model
7
6
5
4
3
2
1
OSI
TCP/IP
Application
Presentatio
n
Application
Session
Transport
Network
Data Link
Physical
Not
present
Transport
Internet
Host-toNetwork
TCP
IP
TCP Overview
Connection-Oriented
Reliable Protocol
Connectionless
Unreliable Protocol
IP Overview
Network Address
Subnet Address
Host Address
140.112.28.XX
140.112.28.XX
Gatew
Gatew
ay
ay
(Route
(Route
r)r)
140.112.30.XX
140.112.30.XX
IP Overview (cont.)
IP Header
Ethernet Layer
multicast
multicast
multicast
multicast
Support Mechanism
Various Networking
Inter-Process Communication
Addr
Family
Description
UNIX
INET
AX25
IPX
Novell IPX
X25
Socket Type
Description
Stream
Datagram
Unreliable, Not
sequenced, Like UDP
Reliable
Delivered
Messages
Sequenced
Packet
Network
Applications
User
Kernel
BSD
BSDSockets
Sockets
Socket Interface
INET
INETSockets
Sockets
Protocol Layers
TCP
TCP
UDP
UDP
IP
IP
Network Devices
PPP
PPP
SLIP
SLIP
ARP
ARP
Ethernet
Ethernet
Client/Server
Communication
Connect
4. Create a socket
1. Create a
socket
Accept
2. Bind an addr
Client
Client
Server
Server
Send
Recv
See An Example
BSD Initialization
BSD Socket
Ex. fd=Socket(AF_INET,
SOCK_STREAM,0);
files_struct
count
close_on_exec
open_fs
fd[0]
fd[1]
fd[255]
file
f_mode
f_pos
f_flags
f_count
f_owner
f_op
f_inode
f_version
inode
BSD Socket
File Operations
lseek
read
write
select
ioctl
close
fasync
socket
SOCK_STREAM
type
protocol
data (sk)
sock
type
protocol
socket
SOCK_STREAM
Address Family
socket operations
Binding an Address
Listening
Listening (cont.)
Connecting
Only for client
Before connecting,
socket.socket_state =
SS_UNCONNECTED;
Int connect(int csockfd, const struct
sockaddr *address, size_t add_len)
Add the sock to tcp_listening_hash
waiting for servers response
Accepting
Accepting (cont.)
next
sk_bufer structure
prev
dev
head
data
tail
end
Packet to
be
len transmitted
truesize
Push
Pull
Put
Trim
References