Download presentation
Presentation is loading. Please wait.
1
CSS432 Foundation Textbook 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 network can be defined recursively as...
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 Switch: forwarding message Router/gateway: forwarding message CSS 432
4
Strategies Circuit switching: carry bit streams
original 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 R3 Switch 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 Application Channel CSS 432
9
IPC Abstractions Connection-Oriented Connectionless Examples 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
Host-to-host connectivity
Layering Use abstractions to hide complexity Abstraction naturally lead to layering Alternative abstractions at each layer Application programs Connection-Oriented Connectionless channel channel Host-to-host connectivity Hardware 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 High-level object Service interface Peer-to-peer CSS 432
13
OSI Architecture CSS 432 End host Application Presentation Session
Transport End host One or more nodes within the network Network Data link Physical CSS 432
14
Internet Architecture
Defined by Internet Engineering Task Force (IETF) Hourglass Design Application vs Application Protocol (FTP, HTTP) Focal point for the architecture Netscape, IE, Mosaic, etc. … FTP HTTP NV TFTP TCP UDP IP NET 1 2 n Reliable byte-stream channel Unreliable datagram delivery Internet Protocol Ethernet, FDDI, etc. CSS 432
15
Socket API Passive Open (Server) Active Open (Client) HW1 uses these.
Creating a socket: int socket(int domain, int type, int protocol) domain = PF_INET, PF_UNIX type = 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) 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 ) ); packets Connection request Stream data HW1 uses these. CSS 432
16
Sockets (Code Example)
int sd = socket(AF_INET, SOCK_STREAM, 0); int sd, newSd; sd = socket(AF_INET, SOCK_STREAM, 0); socket() connect() write() socket() connect() write() socket() bind() listen() accept() 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( ); 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( ); read() read() listen( sd, 5 ); 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 ); buf2, buf1 buf2, buf1 close( newsd); exit( 0 ); CSS 432
17
Socket Implementation
Creating a socket: int socket(int domain, int type, int protocol) domain = PF_INET, PF_UNIX type = SOCK_STREAM, SOCK_DGRAM 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 ); file Client process inode Server process int fd = open( “fileA”, O_RDONLY, 0 ); type protocol so_pcb so_rcv so_snd Socket data structure type protocol so_pcb so_rcv so_snd Socket data structure File structure table 1 2 3 4 User file descriptor table 1 2 3 4 User file descriptor table File structure table packet copied copied packet packet packet packet type protocol so_pcb so_rcv so_snd Socket data structure packet l_addr l_port f_addr f_port socket inpcb: Internet protocol control block l_addr l_port f_addr inpcb: Internet protocol control block CSS 432 f_port socket
18
TCP Communication write/read writev/readv Blocking write/read
default 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. Memory buffers Buffer descriptor list 100 1400 1500 CSS 432 1500
19
Non-Blocking Communication C/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-blocking struct 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; 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 me fcntl(sd, F_SETFL, FASYNC); // set this fd asynchronous int 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
Process Model Process-per-Protocol Process-per-Message
Applications (a) (b) Presentation Process 1 Static piece of code Session Process 2 Static piece of code Transport Process 3 Static piece of code Network 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. CSS 432
22
Buffer Model Avoid data copies Avoid OS interventions
Pin downed communication Conventional buffer transfer Zero copy communication message message message message bypassed message copied message passed message passed message copied Avoid data copies Avoid OS interventions CSS 432
23
Performance Metrics Bandwidth (throughput) Latency (delay)
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 + Queue Propagation = Distance / SpeedOfLight Transmit = 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 = = 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 CSS 432
26
Reviews Exercises in Chapter 1
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) CSS 432
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.