CS422
CLASS NOTES
10/23
Two types of
Network
-
Connectionless (IP, UDP)
-
Connection oriented (TCP)
Connectionless
Networks (CL)
-
No setup is required before
transmitting data
-
Each packet is handled independently
-
No clean up is necessary after
sending data
-
Think of 'postcard'
Connection Oriented
(CO)
-
It leaves the connection open
while sending data
-
It terninates connection when
there is no more data to transmit
-
Think of 'telephone calls'
CO vs CL
-
CO has a setup overhead
-
CO is reliable
-
CO can reserve bandwidth in
some networks (phone line, ATM)
-
Example for CO: TCP, Telephone
system, ATM
-
CL has less overhead
-
In CL, application has more
control in message retransmission error handling, etc...
-
CL allows broadcasts and multicasts
-
Example for CL: UDP, IP
When to use TCP
or UDP
-
TCP: used in applications that
need high (complete) reliability: e-mail, file transfer, ...
-
UDP: (1). used in applications
that do not need a high degree of reliability but require high response:
voice over internet; (2). used in applications that want to have more control
in the delivery of messages. This application has to implement reliability
on top of UDP (Danger of using UDP: application may try to "invent" TCP);
(3). used in application that need broadcast or multicast.
Take-home message:
when in doubt,
use TCP instead of UDP except for broadcast and multicast.
Network Performance
Measurement
-
Delay: time taken for a packet
to arrive at its destination. it likes the "length of a pipe". Caused by:
-
Propagation delay (intrinsic
to network media, fixed)
-
Switching delay (hardware related,
fixed)
-
Queuing delay (time a packet
stay in a buffer waiting to be delivered, variable)
-
Throughput: capacity in bits/sec.
width of a pipe
-
Relationship between delay and
throughput
-
when network is idle, queue
is empty and queuing delay is 0;
-
when load increases, queuing
delay increases;
-
load is defined as the ratio
between throughput to capacity
D
= D0/(1-U)
where
D is total delay; D0 is delay when network is idle; U is the
utilization (load) 0<=U<=1
-
possible consequence: any network
that operates with utilization close to 100% of capacity is doomed.

10/25
Delay Throughput
Product
-
Delay: time to cross the network
in second
-
Throughput: capacity in bits
per second
-
Delay X Throughput: D (sec)
X T (bits/sec) = D X T bits
Net
bits in transit
| 0 |
1 |
0 |
1 |
........................ |
1 |
0 |
Delay = 0.5 secs Throughput
= 128 Kbps
# bits in transit = 0.5 X 128 = 64 Kbits
Protocols
-
Agreement about communication
-
Necessary for interoperation
among different hardware and softwares
-
Specifies
-
format of messages
-
rules of exchange
-
handling problems
-
Family of Protocols
-
Designed to work together
-
each protocol in the family
solves a different communication problem
-
it is also called "protocol
suite" or "protocol family"
-
Designed by layers
-
ISO: 7 layer reference model,
intended for protocol designers
| Application |
| Presentation |
| Session |
| transport |
| network |
| datalink |
| physical |
|
| ---individual application |
| ---data presentation |
| ---login and password |
| ---reliablility |
| ---packet forwarding |
| ---hardware and frame definition |
| ---underlying hardware |
|
-
outdated
-
it was designed when networking
was mostly used to commect terninals to mainframes
-
it does not include "internet"
layer
Internetworking
-
Heterogeneity is inevitable,
no single network technology is best for all need
-
Internet goal: connects physical
networks and creats a software that makes the resulting system appear homogeneous
Router
A device used in the internet
to connect heterogeneous networks. It is also called
- internet router
- internet gateway
- the router eill have one
interface per network
A router can connect networks
that have different
-
technologies
-
media
-
addressing schemes
-
frame format
The internet is
a collection of
-
networks
-
routers that interconnect networks
-
hosts connected to networks
Goal of Internet
-
to hide heterogeneity to the
users
-
the internet is a virtual network
that runs on top of other metworks and that has its own addressing and
name schemes.
10/27
Debuging a
Server
-
Disable fork(), so that the
master server is going to crash if there is a problem
ss = accept(...);
#if defined (DEBUG)
// iterative
processHTTPRequest(ss);
close(ss);
#else
// concurrent
int pid
= fork();
if (pid
== 0) {
processHTTPRequest(ss);
exit(1);
}
close(ss);
#endif
-
Debugging a "core" file
-
when process creah, it writes
a "core" file
-
gdb myserver core
-
gdb > where
/* print stacktrace */
strcpy
processHTTPRequest line 160 server.cc
main
line 1001 server.cc
-
gdb> up
-
gdb> down
-
gdb> print <var>
-
Runing gdb on a program
-
gdb myserver
-
gdb> run
-
to stop a program, using ctrl-c
-
gdb> where
-
gdb> break file:line
/* stop program when it reach this line */
-
gdb> cont
/* continue */
-
gdb> help
-
gdb> next
/* execute a function if any */
-
gdb> step
/* step into a function */
cgi-bin
If a request has the form:
GET /cgi-bin/<prog>?a=b&c=d
then:
processHTTPRequest(ss) /* in a child process */
{
.
.
.
if /cgi-bin as prefix in a request
get <prog>
get <query> /* query is a=b&c=d in this case */
set env vars
// buid the string using malloc and sprintf()
s1 = QUERY_STRING = <query>
s2 = REQUEST_METHOD = GET
putenv(s1);
putenv(s2); /* set up env vars */
.
.
.
}
Write header just before
content-type
Redirect stdout to slave
socket ss
Execvp for http-root-dir/cgi-bin/<prog>