css432 foundation textbook ch1
Post on 13-Feb-2016
54 Views
Preview:
DESCRIPTION
TRANSCRIPT
CSS 432 1
CSS432 FoundationTextbook Ch1
Professor: Munehiro Fukuda
CSS 432 2
Building Blocks
Nodes: PC, special-purpose hardware… hosts switches
Links: coax cable, optical fiber… point-to-point
multiple access …
length
#nodes
limitations
CSS 432 3
Clouds - Networks
A set of nodes, each connected to one or more p2p link
Switched network Circuit switch Packet switch
A set of independent clouds (networks) interconnected to forma an internetwork
Internet
A network can be defined recursively as...
Switch: forwarding message Router/gateway:forwarding message
CSS 432 4
Strategies
Circuit switching: carry bit streamsoriginal telephone network
Packet switching: store-and-forward messages Internet
CSS 432 5
Addressing and Routing
Address: byte-string that identifies a node usually unique
Routing: process of forwarding messages to the destination node based on its address Forwarding: local, static, and implemented by h/w Routing: dynamic, complex, and implemented by s/w
Types of addresses unicast: node-specific broadcast: all nodes on the network multicast: some subset of nodes on the network
CSS 432 6
Multiplexing Synchronous Time-Division Multiplexing (STDM) Frequency-Division Multiplexing (FDM)
L1
L2
L3
R1
R2
R3Switch 1 Switch 2
Two limitations: If a host has no data to send, the corresponding time slot or
frequency becomes idle. The maximum number of flows, (#time slots and #different
frequencies) are fixed.
CSS 432 7
Statistical Multiplexing On-demand time-division Schedule link on a per-packet basis Packets from different sources interleaved on link Buffer packets that are contending for the link Buffer (queue) overflow is called congestion
…
CSS 432 8
Inter-Process Communication Turn host-to-host connectivity into process-to-process
communication. Fill gap between what applications expect and what
the underlying technology provides.
Host HostApplication
Host
Application
Host Host
Channel
CSS 432 9
IPC Abstractions
Connection-Oriented Examples
FTP Web (HTTP) NFS
Requirements At most one message
delivery FIFO order Security
Connectionless Examples
On-demand video Video conferencing
Requirements One/two-way traffic Bulk data transfer: 60Mbps Some data may be dropped
off. FIFO order in most cases Security
CSS 432 10
What Goes Wrong in the Network?
Bit-level errors (electrical interference) Packet-level errors (congestion) Link and node failures
Messages are delayed Messages are deliver out-of-order Third parties eavesdrop
CSS 432 11
Layering Use abstractions to hide complexity Abstraction naturally lead to layering Alternative abstractions at each layer
Connection-Orientedchannel
Connectionlesschannel
Application programs
Hardware
Host-to-host connectivity
CSS 432 12
Protocols and Interfaces Protocol: Building each layer of a network architecture Each layer’s protocol has two different interfaces
service interface: operations on this protocol peer-to-peer interface: messages exchanged with peer (only direct at
H/W level)Host
1
Protocol
Host 2
Protocol
High-levelobject
High-levelobject
Serviceinterface
Peer-to-peerinterface
CSS 432 13
OSI Architecture
Application
Presentation
Session
Transport
End host
One or more nodeswithin the network
Network
Data link
Physical
Network
Data link
Physical
Network
Data link
Physical
Application
Presentation
Session
Transport
End host
Network
Data link
Physical
CSS 432 14
Internet Architecture Defined by Internet Engineering Task Force (IETF) Hourglass Design Application vs Application Protocol (FTP, HTTP)
…
FTP HTTP NV TFTP
TCP UDP
IP
NET1 NET2 NETn Ethernet, FDDI, etc.
Internet Protocol
Reliable byte-stream channel Unreliable datagram delivery
Focal point for the architecture
Netscape, IE, Mosaic, etc.
CSS 432 15
Socket APICreating a socket: int socket(int domain, int type, int protocol)
domain = PF_INET, PF_UNIXtype = SOCK_STREAM, SOCK_DGRAM
Active Open (Client) Connectionless: UDP (SOCK_DGRAM)
sendto( sd, buf, sizeof( buf ), flag, struct sockaddr *name, socklen_t namelen );
recvfrom( sd, buf, sizeof( buf ), flag, struct sockaddr *addr, socketlen_t, *addrlen );
Connection-oriented: TCP (SOCK_STREAM)
connect( int sd, struct sockaddr *name, socklen_t namelen ) write( sd, buf, sizeof( buf ) ); writev( sd, struct iovec *iov, int
iovcnt ); read( sd, buf, sizeof( buf ) );
Passive Open (Server) Connectionless: UDP (SOCK_DGRAM)
bind( int sd, struct sockaddr *name, socklen_t namelen ); recvfrom( sd, buf, sizeof( buf ), flag, struct sockaddr *addr,
socketlen_t, *addrlen ); sendto( sd, buf, sizeof( buf ), flag, struct sockaddr *name,
socklen_t namelen );
Connection-oriented: TCP (SOCK_STREAM)
bind( int sd, struct sockaddr *name, socklen_t namelen ); listen( sd, 5 ); accept( sd, struct sockaddr *addr, socket_t *addrlen ); read( sd, buf, sizeof( buf ) ); readv( std, struct iovec *iov,
int iovcnt) write( sd, buf, sizeof( buf ) );
Connection request
Stream data
packets
HW1 uses these.
CSS 432 16
Sockets (Code Example)int sd, newSd;sd = socket(AF_INET, SOCK_STREAM, 0);
sockaddr_in server;bzero( (char *)&server, sizeof( server ) );server.sin_family =AF_INET;server.sin_addr.s_addr = htonl( INADDR_ANY )server.sin_port = htons( 12345 );bind( sd, (sockaddr *)&server, sizeof( server ) );
struct hostent *host = gethostbyname( arg[0] );sockaddr_in server;bzero( (char *)&server, sizeof( server ) );server.sin_family = AF_INET;server.s_addr = inet_addr( inet_ntoa( *(struct in_addr*)*host->h_addr_list ) );server.sin_port = htons( 12345 );
connect( sd, (sockaddr *)&server, sizeof( server ) );
sockaddr_in client; socklen_t len=sizeof(client);while( true ) { newSd = accept(sd, (sockaddr *)&client, &len);
write( sd, buf1, sizeof( buf ) );write( sd, buf2, sizeof( buf ) ); if ( fork( ) == 0 ) {
close( sd ); read( newSd, buf1, sizeof( buf1 ) ); read( newSd, buf2, sizeof( buf2 ) );
} close( newSd );}
read() read()
socket()
connect()
write()
socket()
connect()
write()
listen( sd, 5 );
socket()
bind()
listen()
accept()
buf2, buf1
buf2, buf1close( newsd);exit( 0 );
int sd = socket(AF_INET, SOCK_STREAM, 0);
CSS 432 17
Socket Implementation
Active Open (Client) connect( int sd, struct sockaddr *name, socklen_t namelen )
Passive Open (Server) bind( int sd, struct sockaddr *name, socklen_t namelen ); listen( sd, 5 ); accept( sd, struct sockaddr *addr, socket_t *addrlen );
Creating a socket: int socket(int domain, int type, int protocol)domain = PF_INET, PF_UNIXtype = SOCK_STREAM, SOCK_DGRAM
Client process Server process
01234
User file descriptor table File structure table
inode
typeprotocolso_pcbso_rcvso_snd
Socket data structure
l_addrl_portf_addrf_portsocket
inpcb: Internet protocol control block
file
01234
User file descriptor tableFile structure table
typeprotocolso_pcbso_rcvso_snd
Socket data structure
typeprotocolso_pcbso_rcvso_snd
Socket data structure
l_addrl_portf_addrf_portsocket
inpcb: Internet protocol control block
copiedcopied
int fd = open( “fileA”, O_RDONLY, 0 );
packetpacket
packet
packetpacket
packet
CSS 432 18
TCP Communication
write/read Send and receive a
message in buf
writev/readv Gather and scatter
messages in a single pair of writev/readv
Blocking write/read Write( ) is blocked until a
message is sent. Read( ) is blocked until a
message is received Non-blocking
Write( ) returns without confirming a message send
Read( ) returns null without waiting for a message.
default
1001400
1500
1500
Memory buffersBuffer descriptor list
CSS 432 19
Non-Blocking CommunicationC/C++ Example
Polling Periodically check if a socket is ready to read data: Example:
sd = socket( AF_INET, SOCKET_STREAM, 0);set_fl(sd, O_NONBLOCK); // set the socket as non-blockingstruct pollfd pfd;pfd.fd = sd;poll( &pfd, 1, timeout ) // poll the socket status
Interrupt Notified from the system when a socket is ready to read data; Example:
sd = socket(AF_INET, SOCKET_STREAM, 0);signal(SIGIO, sigio_func); // set a future interrupt to call sigio_func( )fcntl(sd, F_SETOWN, getpid( )); // ask OS to deliver this fd interrupt to mefcntl(sd, F_SETFL, FASYNC); // set this fd asynchronousint sigio_func( ) { // invoked upon an interrupt }
CSS 432 20
Protocol Implementation Issues Process Model
Process per protocol Process per message
avoid context switches
Buffer Model Copy from Application buffer to network buffer Zero copy / pin-down communication
avoid data copies
CSS 432 21
(a) (b)
Process Model
Process-per-Protocol
• Simple message passing mechanisms between processes
• A context switch required at each layer
Process-per-Message
• For sending, functions are called down from top to bottom.
• For receiving, functions are called up from bottom to top.
Applications
Presentation
Transport
Session
Process 1
Process 2
Process 3
Static piece of code
Static piece of code
Static piece of code
Network
CSS 432 22
Buffer Model
Avoid data copies Avoid OS interventions
message message message
message
copied
message
copied
message
passed
message
passed
message
bypassed
Conventional buffer transfer Zero copy communication Pin downed communication
CSS 432 23
Performance Metrics Bandwidth (throughput)
data transmitted per time unit link versus end-to-end notation
Mbps = 106 bits per second Gbps = 109 bits per second
Latency (delay) time to send message from point A to point B one-way versus round-trip time (RTT) components
Latency = Propagation + Transmit + QueuePropagation = Distance / SpeedOfLightTransmit = Size / Bandwidth Even in the same distance, latency varies depending on the size of
message.
CSS 432 24
Ideal versus Actual Bandwidth
RTT dominates Throughput = TransferSize / TransferTime TransferTime = RTT + 1/Bandwidth x TransferSize RTT:
a request message sent out and data received back
Example: 1-MB file across a 1-Gbps network with RTT=100ms. 1MB / 1Gbps = 8Mb / 1000Mbps = 8msec TransferTime = 100 + 8 = 108msec Throughput = 1MB / 108msec = 74.1 Mbps
CSS 432 25
Delay x Bandwidth Product
Amount of data “in flight” or “in the pipe” Example: 100ms x 45Mbps = 560KB Receiver must prepare a buffer whose
size is at least 2 x Delay x Bandwidth
Bandwidth
Delay
CSS 432 26
Reviews Components: hosts, links, switches, routers and networks Switching (circuit and packet) and multiplexing (STDM,
FDM, and statistical) OSI and Internet architectures Socket Performance metrics: Bandwidth and latency
Exercises in Chapter 1 Ex. 3 (RTT) Ex. 10 and 29 (STDM and FDM) Ex. 16 (Latency) Ex. 30 (Packet Sequence)
top related