CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr....

32
CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000

Transcript of CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr....

Page 1: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

CSC 600Internetworking

withTCP/IP

Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22)

Dr. Cheer-Sun Yang

Fall 2000

Page 2: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

Theoretical Basis for Data Transmission

• Information can be transmitted through a medium by varying some physical property.

• The physics of the universe (noise, distortion, attenuation) places some limits on what can be sent over a channel.

• Purpose of physical layer – to transport a raw bit stream from one machine to another.

Page 3: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

How do we transmit these waves?

• Feed an electrical signal to the antenna of a transmitter

• The signal makes the atoms of the antenna vibrate (changing energy levels).

• This change causes the antenna to emit electromagnetic waves.

Page 4: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

• Bits can be sent as a voltage or current through a wire

• For example:zero = +1 volts

one = -1 volts

(Later we’ll see some problems with this representation…)

Sample Data Representation

voltage

1 0 1 0 10

+1

-1

0

Page 5: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

Bandwidth A given transmission medium can accommodate

signals within a given frequency range. The bandwidth is equal to the difference between the highest and the lowest frequencies that may be transmitted. For example, a telephone signal can handle frequencies between 300 Hz and 3300 Hz, giving it a bandwidth of 3000 Hz. This means, very high- or low-pitched sound cannot pass through the telephone system. Sometimes, bandwidth is used to denote the number of bits that can be transmitted.

Page 6: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

Chapter 2 Transmission Media

• Copper Wires• Glass Fibers• Radio• Satellites• Geosynchronous Satellites• Low Orbit Satellites• Low Orbit Satellite Arrays• Microwaves• Infrared• Laser Lights

Page 7: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

Twisted Pair• Insulated Copper wires, about 1mm thick

Twisted, to avoid forming an antenna: reduces interference

• Two major kinds– Cat 3 (1988 and earlier)

• four pairs: (allows four telephone lines)– Cat 5: (new installations)

• more twists per centimeter, and Teflon insulation• more suitable for high speed networks.

• Shielded vs. Unshielded: – shielded twisted pair (STP)

• (shield serves as ground, some applications in business use this, but becoming more rare)

– unshielded twisted pair (telco local loop to home is usually UTP)

Page 8: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

COAXIAL CABLE

Page 9: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

More about Coaxial Cable

Coaxial cable typically transmits information in one of two modes: baseband or broadband mode.

• Baseband mode - the cable’s bandwidth is devoted to a single stream of data.

• Broadband mode - the bandwidth is divided into ranges. Each range typically carries separate coded information.

Page 10: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

Ethernet

• Transceiver: used to connect an Ethernet and a host.

host

transceiver

Page 11: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

Ethernet

Page 12: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.
Page 13: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.
Page 14: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.
Page 15: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.
Page 16: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

10/100 Ethernet

10 BASE T

10 Mbps baseband Twisted-pair

Page 17: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

Chapter 3Internet Architecture

• Repeater – extending a cable (UTP, STP, Optical Fiber).

• Bridge – interconnecting two LANs which operate in the data link layer. Example: 2 TCP/IP LANs.

• Router – interconnecting two WANs. e.g., the Internet, which operate on the network layer. Example: an Ethernet LAN and a Token Ring.

• Gateway – interconnecting different networks in the application layer. For example, one network implements OSI and another implements TCP/IP.

Page 18: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

Router

Page 19: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

Interconnect Through IP Routers

• In a TCP/IP internet, special computers called IP routers or IP gateways provide Interconnections among physical network.• Routers use the destination network, not the destination computer, when forwarding a packet.

Page 20: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.
Page 21: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

What is a Network?

• In a TCP/IP internet, TCP/IP can be built over various media-access sublayer.• If TCP/IP over Ethernet, it is the Internet architecture.• If TCP/IP over ring connection, it is the IBM Token Ring.• But, all are called TCP/IP networks from the router’s point-of-view. Thus, IP datagrams can be passed from Internet to Token Ring without going through application level gateway. • See Fig. 3.3

Page 22: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

A Virtual Network

Page 23: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

Unanswered Questions

• How does a router identify a computer? Chapters 4, 5, 6 cover this.

• How does an IP datagram look like? Chapter 7 introduce this.

• How does a TCP segment look like? Chapter 13 talks about this.

• How does an application use the services provided by TCP or UDP?

next topic. (Ch. 22)

Page 24: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

Chapter 21Client-Server Model

• A host will execute the server program which will always wait for requests for connection.

• Another host will execute a client program.• The client and the server will use 3-way

handshaking to initiate the communication.• After the connection is established, the client and

the sender can send/receive messages.• This model is called a connection-oriented model.

Page 25: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

Client-Server Model(cont’d)

• The previous model uses TCP/IP.• If UDP/IP is used, after the connection is

called, the client only receives the remote endpoint information.

• A client then uses the information to identify the destination address for a socket.

• This model is called a connectionless model.

Page 26: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

Chapter 22. Socket Interface

• Services provided by TCP and UDP to the application layer, called an Application Program Interface (API).

• There are many versions on various machines: BSD UNIX, Windows, Linux.

• TCP provides a connection-oriented service;

• UDP provides a connectionless service.

Page 27: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

Socket Interface

• The network interface is similar to other I/O system calls: OPEN, READ, WRITE, CLOSE.

• In addition, it also provides the following:– Create a socket

– Bind – specifying a local address

– Connect – connecting sockets to a destination

- Listen – a server waits for a connect request

- Accept – a server accepts the request

- Many others.

Page 28: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.
Page 29: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

Socket Address Structurestruct sockaddr_in

{

u_char sin_len;

u_short sin_family;

u_short sin_port;

struct in_addr sin_addr;

char sin_zero[8];

};

Page 30: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

Internal Socket Structurestruct {

int family;

int type;

int protocol,

struct sockaddr_in local_socket_addr;

struct sockaddr remote_socket_addr;

};

Page 31: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

Socket System CallsInt socket (int Family, int Type, int Protocol);

Family – defines the protocol group: IPv4, IPv6, UNIX domain

Type – stream socket, datagram socket, or raw socket

Protocol – usually is set to zero for TCP and UDP

Page 32: CSC 600 Internetworking with TCP/IP Unit 2: Client-Server Model and Sockets(Ch.2, 3, 21, 22) Dr. Cheer-Sun Yang Fall 2000.

Connection-Orientedsocket()

bind()

listen()

accept()

read()

write

close()close()

read()

write()

connect()

socket()

Blocks until server receivesa connect request from client

connectrequest

data

data

server client