unit2 - WCU Computer Science
Download
Report
Transcript unit2 - WCU Computer Science
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.
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.
Sample Data Representation
• 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…)
voltage
+1
0
-1
1
0
1
0
0
1
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.
Chapter 2
Transmission Media
•
•
•
•
•
•
•
•
•
•
Copper Wires
Glass Fibers
Radio
Satellites
Geosynchronous Satellites
Low Orbit Satellites
Low Orbit Satellite Arrays
Microwaves
Infrared
Laser Lights
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)
COAXIAL CABLE
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.
Ethernet
• Transceiver: used to connect an Ethernet
and a host.
transceiver
host
Ethernet
10/100 Ethernet
10
10 Mbps
BASE
baseband
T
Twisted-pair
Chapter 3
Internet 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.
Router
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.
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
A Virtual Network
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)
Chapter 21
Client-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.
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.
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.
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.
Socket Address Structure
struct sockaddr_in
{
u_char sin_len;
u_short sin_family;
u_short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
Internal Socket Structure
struct {
int family;
int type;
int protocol,
struct sockaddr_in local_socket_addr;
struct sockaddr remote_socket_addr;
};
Socket System Calls
Int 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
socket()
bind()
Connection-Oriented
client
server
listen()
accept()
socket()
connect
request
connect()
Blocks until server receives
a connect request from client
data
write()
data
read()
read()
write
close()
close()