9/11/00, Monday
LAB: TCP/UDP data .....
If ascii value is less than 32, print a '.'
When printing data :
     if data[j] < 32) {
        printf(".");
     }
     else
        printf("%c", data[j]);
Control character (characters < 32) are printed as "."
The structure of a packet depends on the hardware.
     -Caracteristics:
         :minimum/maximum length
         :format
The structure of a packet is also called "the frame" of the packet.
Frame format for RS232
     - RS 232 transmissions consist of sequences of characters.
     - The following is the RS 232 packet frame:

soh-> start of header and signal the beginning of the packet
eot-> end of transmission and signals end of packet
Problem: if the data contains special characters like soh or eot, the receiver will confuse them as start or end of transmission.
Solution: Use a different representation for soh and eot when they are part of data. This is called "byte stuffing."
"byte stuffing" = substitute special characters with an escape sequence.
| character in data | character sen |
| soh | esc x |
| eot | esc y |
| esc | esc c |
- The receiver translates the message back to the original message.
- The stuffed frame is longer than original.
Handling Errors
- Data sent can be corrupted during transmission.
    - Bits can be lost or changed.
- The frame includes additional information to detect & sometimes correct errors
     : This info is set by sender.
     : This info is checked by receiver.
- There is always a -very- small probability of having undetected errors, but error detection works -very well- in practice.
Error Detection and Recovery Techniques
Parity bit = One additional bit per character. It tells if the number of bits in the character is even or odd.
-even parity
     - Total # bits(include parity bits) is even.
even parity example: 1 parity bit 0010101 data bits
-odd parity
     - total # bits(include parity bit) is odd.
odd parity example: 0 parity bit 0010101 data bits
-The main disadvantage for parity is party bits cannot detect errors that change an even number of bits.
Checksum - treat data as a sequence of numbers. Compute and send the arithmetic sum. The receiver computes the same sum and compares it with the received sum. If they are different, the packet is dropped.
     - checksum handles multiple bit errors, but there is a possibility that some errors will remain undectected.
9-13-00, Wednesday
Checksum Example
Orginal Data
| 0001 = 1 |
| 0010 = 2 |
| 0110 = 6 |
| 0001 = 1 |
| checksum 1010 = 10 |
It is possible to have an error in the orignal data and still have the same checksum
| 0000 = 0 |
| 0011 = 3 |
| 0110 = 6 |
| 0001 = 1 |
| checksum 1010 = 10 |
The same as the previous checksum
-Checksums do not detect some "positional errors" errors that happen at the same bit position.
-Hardware tend to have "positional errors", errors that happen in the same bit.
-CRC's detect positional errors.(Cyclic Redundancy Check). To compute CRC we need two bit operations:
    

Example of CRC hardware
-For a 16 bit CRC

initially all will be 0
-Problem in software. It will be very slow.
-Bits of the data are shifted into the input one by one
-CRC is found in the registers once the entire data has been shifted.
-Transmitter includes the CRC in the packet.
-The receiver also computes the CRC and compares its own CRC with the one in packet
-If they are different the packet is dropped.
Example
     Insert an input of all 1's into the CRC hardware:

-Feedback affects the entire CRC
-CRC detects "positional errors."
Summary
-Packets
    - Provide fair access to a shared network.
    - Sender divides large data into small packets.
RS 232 with packet switching
    - Special character at the beginning and end of the packet
    - Byte stuffing is needed when data contains special characters(soh,eot).
- To detect data corruption
    - Sender adds redundant information to packet(parity bit, checksum, CRC)
    - Receives verifies that redundant info is consistant with data. If it is not then it drops the packet
     This provides statistical guarantee that the accepted packet was not corrupted.(Very unlikely that a corrputed packet is not detected.)
9-15-00, Friday
Part4 Local Area Networks
Three categories of Networks
    Local Area Networks(LAN)
    Metropolitan Area Network(MAN)
    Wide Are Network(WAN)
LAN - room or building
MAN - City
WAN - Group of cities
LAN and WAN are the most common.
LANs are more popular.
    - Many technologies exist.
        - Ethernet
        - Token Ring, Apple Talk, etc.
    - Advantages of LAN
        - High throughput
        - Relativily low cost
    -Disadvantage of LAN
        - Short distances
        - Often use shared Media
Justification for LANs (why LANs work well in practice)
- A computer is more likely to communicate with computers that are nearby than with computers that are distance
-This is known as "the locality principle."
Netowrk Topology
Topology in mathematical terms describes the Geometry of curved surfaces
Network Topology
    - describes the shape of a network.
    - How computers are interconnected.
Star Topology

- Central component called "hub"
- Each computer has a seperate connection to the hub
Ring Topology

-No central facility
-Connected goes from one computer to the other
Bus Topology

-Shared meduim connects all the computers
Ethernet
-Bus Network
-IEEE standard 802.3
-It has evolved but it is still the same "core" technology
    -Frame format is still the same.
    -Different rates 10 Mbs, 100 Mbs, 1 Gbs
    -Different wiring schemes
-Shared Mediums used for all transmission.
-Computers take turns to communicate
-Only on station transmits at any time
-A media access control policy (MAC) ensures fairness
Ethernet Transmiision

-Only one signal transmits at any time
-Signal propagates across the entire cable
-All stations receive transmitted packets
-the ethernet interface will filter the packets and will pass to the OS only packets destined to the machine or broadcast packets.
-In the ethernet a technique called CSMA/CD is used to control the access to the shared medium
CSMA/CD
    -Carrier Sense Multiple Access/Collision Dection
    - Multiple Access(MA)
        -Multiple computers share medium
        -All the computers run the same access algorithm
    -Carrier Sense(CS)
        -Wait until media is idle to begin transmission