+---------------------------------------+
| CS 162 Lecture Notes
| Wednesday, 4 April 2007
| Jonathan Chung
+---------------------------------------+
+---------------------------------------+
| About
+---------------------------------------+
These notes correspond to lines 349 through 971 of smith7.txt and
cover his second lecture on Networking.
Topic-wise, it covers everything from WAN to Level 4 of TCP/IP.
+---------------------------------------+
| Announcements
+---------------------------------------+
Midterm on April 11th at 7 PM in 306 Soda.
+---------------------------------------+
| Topics
+---------------------------------------+
Wide Area Networks
Broadcast Networks
Aloha and Slotted Aloha
Ethernet
Ring Networks
Linking Networks
Names, Addresses, Routes
Problems
Guaranteeing Delivery and Order
TCP/IP
+---------------------------------------+
| Wide Area Networks
+---------------------------------------+
* Wide Area Networks (WAN) are typically built up using interconnected
Local Area Networks (LAN).
* LAN's are typically a type of broadcast network.
+---------------------------------------+
| Broadcast Networks
+---------------------------------------+
* Broadcast Network contain a single shared communication medium.
* There is no central controller to allocate access to it.
* The simplest example of such a network was Aloha.
+---------------------------------------+
| Aloha
+---------------------------------------+
* Premise: Blind broadcasting. Don't listen to see if others are broadcasting.
* Consists of a satellite. Agents broadcast up, and signals are beamed straight back down.
* If something fails, use a recovery protocol.
* Problem #1 - Stability - Systems sags under heavier loads and may not work at all past a certain limit.
Throughput (y-axis) vs. Offered Load (x-axis)
| _______
| _/ \_
| / \
| / \
| / \
| / \
| / \
|___________________________________________
As already stated, the system does poorly at high loads due to interference.
At that point, there are so many broadcasting users that they cancel each other out.
Peak optimality is somewhere in the middle.
Max Throughput = 1 / 2e or 18%
* Problem #2 - Listening for signals is no good due to delays of a quarter second.
Users are effectively hearin what was transmitted a quarter second ago, which is useless.
(Smith) Can we improve upon this?
(Student) Yes. We can restrict users to broadcast only at given times.
+---------------------------------------+
| Slotted Aloha
+---------------------------------------+
* Slotted Aloha is an improved version of Aloha that only lets users transmit
at certain times (slots).
* In practice, this effectively doubles throughput to 1/e or 36%.
* Why does this work? This boils down collisions to 100% overlap or none at all.
| --
| --
| --
| --
| --
-----------------------------------
Slotted Aloha
|----
| --------
|
| -------
| ------------
-----------------------------------
Aloha
+---------------------------------------+
| Ethernet
+---------------------------------------+
Ethernet (in coaxial cable form) adds two major features over Aloha.
1) Carrier Sense
2) Listening while broadcasting
Carrier Sense
-----------------------------------------
* Listen BEFORE broadcasting.
* Defer broadcasting until the channel is empty.
* Then broadcast.
Listen while Broadcasting
-----------------------------------------
* If there's an interruption, stop broadcasting to save bandwidth.
* Wait a random amount of time to restart.
* Why random? The collision will happen again if both wait the same time.
* If there happens to be a second collision, repeat again with a larger mean time.
* This is called CSMA/CD (carrier sense multiple access with collision detection).
Wikipedia has a great analogy for this mechanism.
"This can be likened to what happens at a dinner party, where all the guests talk to
each other through a common medium (the air). Before speaking, each guest politely
waits for the current speaker to finish. If two guests start speaking at the same time,
both stop and wait for short, random periods of time. The hope is that by each
choosing a random period of time, both guests will not choose the same time to try
to speak again, thus avoiding another collision. Exponentially increasing back-off times
are used when there is more than one failed attempt to transmit."
(Retrieved April 10th from http://en.wikipedia.org/wiki/Ethernet)
Physical Aspect
-----------------------------------------
Consists of switches, hubs and wires.
Protocol
-----------------------------------------
Destination address (6 bytes)
Source address (6 bytes)
Type (2 bytes)
Data (46 - 1500 bytes) - also known as the Payload
Frame check sequence (4 bytes) - also known as the Checksum
Problems
-----------------------------------------
1) Reliability
* If any station jams the network, the whole system is stuck.
* Worse yet, we can't figure out who's at fault.
2) Fairness
* Starvation is not guaranteed to never happen.
* In other words, starvation could happen.
3) Bandwidth
* 10 megabit limit
4) Physical Limit
* 4000 ft. cable limit
5) Security
* It's easy for anybody to tap into the network and listen.
This isn't actually the Ethernet that we know today, which uses the same protocol
but doesn't share the same problems mentioned.
+---------------------------------------+
| Modern Ethernet
+---------------------------------------+
* Modern Ethernet uses switches to route rather than shared cables.
* Rates can be 10 Mbit, 100 Mbit or 1 Gbit.
* Wireless Ethernet is standardized (802.11 a/b/g/n)
* Still uses most of the original protocol, so it's backwards compatible for the most part.
+---------------------------------------+
| Ring Networks
+---------------------------------------+
* A Ring Network is another type of broadcast network.
* RN's use an additional protocol built on top of a ring-structured set of point-to-point links.
* Each node in a Ring Network is connected to 2 other nodes.
o------------o
| |
| |
o------------o
A Ring Network with 4 points
How it Works
-----------------------------------------
* Ring Networks use a special packet called a token.
* When the token comes around to a point...
- If the point has something to transmit, drop it off (copy it off)
- The sender will swallow it when it returns.
- In this way, stuff circulates around the network quickly.
Problems
-----------------------------------------
1) If any station dies, the token dies
2) If a token goes missing, the whole system dies.
3) Starvation is possible.
4) If a second token is created, the system can become corrupted.
+---------------------------------------+
| Linking up Networks
+---------------------------------------+
* We can use Ethernet or Ring Network for local net, but we need
some way of constructing an "inter-network."
* There are 3 ways to achieve this.
1) Circuit Switching
Like telephones. There's a circuit between a source and destination.
2) Packet Switching
Communications are broken into packets and are sent piece by piece.
Note: Package Switching can emulate a circuit virtually. It looks like a
circuit but actually consists of packets on a shared medium.
3) Message Switching
Virtual circuit exists for long enough to complete a message, and then
the circuit is dropped. Can also be a physical link.
+---------------------------------------+
| Getting from A to B
+---------------------------------------+
* Packets must be forwarded from machine to machine until they reach
the destination machine.
* Machines that forward packets between networks are called gateways.
+-----------------------------------------------+
| Names vs. Addresses vs. Routes
+-----------------------------------------------+
* A Name is a symbolic term such as "ucbcory"
* An Address specifies where the destination is. Consists of...
- Number of Network
- Number of the site on the network
- ID of the host at the site
- Sometimes specific host (workstation)
* Route: Directions for how to get there from here
(a sequence of hosts and links to pass through to reach the destination).
Like looking up directions on MapQuest.
Big Point: Local Machine doesn't need to know the route. Why?
* The Route can change.
* There are far, far too many routes.
* This is what the Internet handles.
+-----------------------------------------------+
| Communication Problems
+-----------------------------------------------+
There are 3 major types of problems that can occur.
1) Lost Packets.
2) Packets arrive out of order.
3) Issues with datagram protocols.
Lost Packets
-----------------------------------------
* This leads to transmission errors.
- The address becomes corrupted, and the packet circulates forever.
- Contents could become corrupted.
* Packet buffers are full.
- Called network congestion.
- Happens when a fast network forwards packets to a slow network.
- Packets simply get dropped.
- Can also happen if the host can't process packets quickly enough.
Packets arrive out of order
-----------------------------------------
* If some hosts suddenly go down, or if routing tables change, packets
might wander off into the network and come back much later
* Solution - "Time to Live" - after a certain time, just kill the packets.
* Another Solution - Buffer the packets and reassemble them.
Datagram Protocols
-----------------------------------------
* Used for delivering individual packets.
* Much like a "note in a bottle" thrown into the ocean.
* No guarantee on order or even transmission.
+--------------------------------------------------+
| Guaranteeing Order and Delivery
+--------------------------------------------------+
Most programs would like a guarantee on delivery and ordering. How is this done?
Serial Number Ordering
-----------------------------------------
* Tack on a number to each packet.
* Increment number for each packet.
* Wait for acknowledgement.
* If there's no acknowledgement within a given time, retransmit using same numbers.
* This could lead to duplicate packets. Throw those away.
Negotiating
-----------------------------------------
* Sender and received must decide on how far ahead the sender can send.
* Flow Control Problem - Too much ahed and the receiver can't store all in
its buffer and will drop packets.
* Relevant for applications such as streaming video and audio.
+--------------------------------------------------+
| TCP/IP
+--------------------------------------------------+
* TCP/IP is collection of network protocols making up the Internet Protocol Suite.
* This is what the Internet uses.
* Consists of several layers. We'll focus on levels 3 and up.
Level 3 - Network Layer
-----------------------------------------
Purpose: Gets packets from host to host. Provides insulation from levels 1 & 2.
Consists of the following...
Version
Header length
Total length
ID (same for all fragments of datagram)
Time-to-live
Checksum
Source address
Destination address
Level 4 - Transport Layer
-----------------------------------------
Purpose: Provides a reliable byte-stream for transporting a packet from point A to point B.
Consists of the following...
Source port
Destination port
Sequence number (32 bits)
Acknowledgement number
Control flags
ACK
RST (reset)
FIN (end)
Window
Checksum
UDP is a connectionless datagram protocol. It's used primarily when time and performance are more important
than receiving things in order. Games are one application where UDP is common.
End Notes
------------------------------------