770 likes | 780 Views
Explore the complex world of modern control and communication in microprocessors, including PLC programming, networked video games, and parallel vs. serial communication.
E N D
Communications Most modern control involves interactions between many microprocessors Examples: PLC: Programming done on PC; uploaded to PLC Complex PLC control requires interaction between many PLC’s e.g. automation controls in an MTR station Microprocessor: Phone Phone (e.g. to exchange phone numbers) Phone PC (to upload address book) Networked video games with multiple players Computers: Internet, EDI
Communications For devices to exchange data, several things must work together: Assume: Data controlled change of voltage in a wire. Bit-Streams: Example: message = “Wow” ASCII V time W: least significant bit most significant bit
Communications For devices to exchange data, several things must work together: - A wire must connect the devices - The voltage levels must match: sender sets “voltage of 5V” ‘1’ => receiver must have a 5V sensor; (must interpret same way) - The duration for each bit (communication frequency, baud rate) - Start bit(s), stop bit(s) - Both must be using ASCII code …
Asynchronous vs Synchronous communications Why do we need start/stop bits ? Prepares the receiving device to start recording data communication is ASYNCHRONOUS asynchronous 7-bit character + parity bit Coordinated connection between the devices: SYNCHRONOUS communication - Receiver continually hunts for sync character (in ASCII: 1001 0110) - [Copies data into the data register; char available flag ON; data read] x CT - Check against CT; - end sync bit hunt mode. synchronous block of data
data Transmitter and Receiver Synchronization generator synchro data Transmitter Receiver synchro clock data + synchro Transmitter and Receiver Synchronization generator Synchronization of communication (a) Transmitter generates the synchronization reference (b) External synchronization clock unit (c) Transmitter superposes clock and data
Serial vs Parallel communication Serial: one signal carrying wire Parallel: 8, 16, or 32 signal carrying wires Parallel: faster, more expensive, used for short-distances only examples: Data bus, Control bus in a microprocessor; parallel port in PC
Bit coding NOT Good; constant HIGH voltage delays [due to Capacitance/Inductance] Signal during half-cycle then return to zero High-to-Low ‘1’ Low-to-High ‘0’ Very commonly used Voltage change at start of cycle ‘0’ No change at start of cycle ‘1’ Voltage flips at mid-cycle
Communication: Handling errors Problem: some data sent from A B may get ‘corrupted’ Why is this a big problem? - How will the receiver know they received ‘bad data’? Probability of communication error is reduced by: Error detection and Correction
Communications: Error detection and correction schemes Importance of EDC (error detection and correction): Assume error rate of 0.1% Average sentence of text: 125 characters = 125 x 8 = 1000 bits 0.1% error 1 error per sentence! Techniques for EDC: 1. IF receiver detects error requests sender to re-transmit 2. Receiver detects and corrects error without re-transmission
Error detection: Parity Error detection: some information is added to message, that allows checking for errors. PARITY 1 ASCII char = 7bits; 1 extra bit is added to each character, called parity bit: Even parity: value of parity bit is set to make total number of 1’s even. Odd parity: value of parity bit is set to make total number of 1’s odd. Example: (ASCII) W: 1010 111 (odd parity) W: 0 1010 111 (even parity) W: 1 1010 111
72 101 108 108 111 44 32 119 111 114 108 100 72 101 108 108 111 44 32 119 111 114 108 100 104 Error Detection: Checksums Let: message = “Hello, world” == 12 bytes == 128 bits (including parity bit) Hello, world *assuming: parity bit = 0 Sum = 72 + 101 + 108 + … + 100 = 1128 Checksum [8-bits] = 1128 mod 256 = 104 Checksum [16-bits] = 1128 Message: 1 checksum/12 bytes too much overhead typical use: 1 checksum byte per128 Bytes of data
Error Detection: Cyclic Redundancy Check(CRC) Basic idea of CRC: Pre-agreed between sender/receiver Number: 629 Divisor: 25 mod( Number, Divisor): mod(629, 25) = 4 Transmit: (629,4) Receiver: mod( 629, 25) == 4 ? Transmission probably OK
Error Detection: Cyclic Redundancy Check(CRC) Implementation of CRC: Number: Bitstream of 1 Block (e.g. 128 Bytes) Divisor: common CRC schemes are: CRC12 1100000001011 CRC16 11000000000000101 CRC-CCITT 10001000000100001 CRC32 100000100110000010001110110110111 M = mod( Number, Divisor): computed very efficiently with simple circuits FRAME: Number MOD Receiver: mod(Number MOD, CRC) = = M ? Yes Transmission probably OK
Error detection and Correction Parity, Checksum, CRC: detect error, request re-transmit on error Redundant data transmission: detect error, and correct automatically! Common methods: Repeating Hamming codes Reed-Muller codes, etc… Majority coding: Data: 010 Transmit: 000111000 Receive (with error): 001011000 select majority from each group of 3 0 1 0 Accepted data: 010
Hamming codes Problem of Majority coding: (1) too much redundancy (2) burst errors can’t be handled Hamming code: main idea of a (7, 4) Hamming code Data: 0011 Add 1-bit to each circle, total of each circle even
(7, 4) Hamming code transmit Data: 0011 Error must be in bit shared by red and green red-circle: parity ERROR green circle: parity ERROR blue circle: parity OK receiver
(7, 4) Hamming code… transmit Data: 0011 Error must be in unshared bit of Blue circle! red-circle: parity OK green circle: parity OK blue circle: parity ERROR receiver HW: verify that ALL 1-bit errors can be detected and corrected!
Hamming code… Data: bit-stream write data in particular sequence compute, add hamming code bits to data transmit receiver checks Hamming codes, corrects errors Corrected data Common Hamming code used: (12, 8) Hamming code
Extending Hamming code for longer bit-stream 1. All bit positions that are powers of two are used as parity bits. (positions 1, 2, 4, 8, 16, 32, 64, etc.) 2. All other bit positions are for the data to be encoded. (positions 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, etc.) 3. Each parity bit stores the parity for assigned bits in the code word: The position of the parity bit determines the sequence of bits that it alternately checks and skips. Position 1: skip 0 bits, check 1 bit, skip 1 bit, check 1 bit, skip 1 bit, … Position 2: skip 1 bit, check 2 bits, skip 2 bits, check 2 bits, skip 2 bits, … Position 4: skip 3 bits, check 4 bits, skip 4 bits, check 4 bits, skip 4 bits, … Position 8: skip 7 bits, check 8 bits, skip 8 bits, check 8 bits, skip 8 bits, … Position 16: skip 15 bits, check 16 bits, skip 16 bits, check 16 bits, skip 16 bits, … Position 32: skip 31 bits, check 32 bits, skip 32 bits, check 32 bits, skip 32 bits, …
Burst errors Problem with Hamming: burst errors: several contiguous data bits in error) Handling burst errors: - Interleaving - Reed-Solomon coding Examples of usage: storage media (CDROM’s), …
To address From address 1/3 data (part 1 of 3) EDC To address From address 2/3 data (part 2 of 3) EDC To address From address 3/3 data (part 3 of 3) EDC Packets Long message p(error) is high Need to re-transmit [part] of message Solution: Break message into small “packets” send packets 1-by-1 To address From address Long message part 1 of 3 part 2 of 3 part 3 of 3 packets transmit Receiver Re-constructs Message from three parts received Typical packet size: 2048 - 4096 Bytes Note: later we’ll see structure of packet in more detail Question: Why do some web pages load in non-sequential fashion (some pictures load first, others later)
Network terminology LAN: Local Area Network A network of communicating devices in a small area (e.g. a building, a factory, etc.) Common ways of physically connecting computers in a LAN: Cables (wires), Bluetooth, Wi-Fi… WAN: Wide Area Network Two or more LAN’s connected to each other, over a large area, e.g. international communication networks. Common ways of connecting between LAN’s in a WAN: Telephone networks, Long-distance cables, Satellites
Network topologies Suppose N computers need to communicate with each other Pairwise connections: How many ? Problems ?
Terminator Network topologies Network topology describes how different devices are (physically) connected to each other.
Network communication basics The following slides, based largely on the those provided by Kurose and Ross, will be used to get an introduction to real-world network communications. Computer Networking: A Top Down Approach Featuring the Internet, 3rd edition. Jim Kurose, Keith RossAddison-Wesley, July 2004.
millions of connected computing devices: hosts = end systems running network applications communication links fiber, copper, radio, satellite transmission rate = bandwidth routers: forward packets router workstation server mobile local ISP regional ISP UST network What’s the Internet ?
protocolscontrol sending, receiving of msgs e.g., TCP, IP, HTTP, FTP, PPP Internet: “network of networks” public: Internet private: Intranet Internet standards RFC: Request for comments IETF: Internet Engineering Task Force What’s the Internet.. router workstation server mobile local ISP regional ISP UST network
a human protocol and a computer network protocol: TCP connection response Get http://www.awl.com/kurose-ross What’s the time? 2pm <file> time What’s a protocol? protocols define format, order of msgs sent and received among network entities, and actions taken on msg transmission, receipt Hi TCP connection req Hi
network edge: applications and hosts network core: routers network of networks access networks, physical media: communication links A closer look at network structure
end systems (hosts): run application programs e.g. Web, email at “edge of network” client/server model client host requests, receives service from always-on server e.g. Web browser/server; email client/server The network edge
Goal: data transfer between end systems handshaking: setup (prepare for) data transfer ahead of time Hello, hello back human protocol set up “state” in two communicating hosts TCP service [RFC 793] reliable, in-order byte-stream data transfer loss: acknowledgements and retransmissions flow control: sender won’t overwhelm receiver congestion control: senders “slow down sending rate” when network congested Network edge: connection-oriented service e.g.
Goal: data transfer between end systems App’s using TCP: HTTP (Web), FTP (file transfer), Telnet (remote login), SMTP (email) App’s using UDP: streaming media, teleconferencing, DNS, Internet telephony Network edge: connectionless service e.g. • UDP - User Datagram Protocol: • connectionless • unreliable data transfer • no flow control • no congestion control
mesh of interconnected routers the fundamental question: how is data transferred through net? circuit switching: dedicated circuit per call: telephone net packet-switching: data sent through net in discrete “chunks” The Network Core
End-end resources reserved for “call” link bandwidth, switch capacity dedicated resources: no sharing circuit-like (guaranteed) performance call setup required Network Core: Circuit Switching
Each end-end data stream divided into packets user A, B packets share network resources each packet uses full link bandwidth resources used as needed Bandwidth division into “pieces” Dedicated allocation Resource reservation Network Core: Packet Switching Resource allocation: • total resource demand can exceed amount available • congestion: packets queue, wait for link use • store and forward: packets move one hop at a time • Node receives complete packet before forwarding
Packet Length: L bits Baud rate: R bps Time to push packet on link: L/R sec Entire packet must arrive at router before it can be transmitted on next link: store and forward delay = 3L/R Example: L = 7.5 Mbits R = 1.5 Mbps delay = 15 sec Packet-switching: store-and-forward L R R R
Q: How to connect end systems to edge router? residential access nets institutional access networks (school, company) mobile access networks Access networks and physical media
Phone modem up to 56Kbps direct access to router (often less) Can’t surf and phone at same time: can’t be “always on” Residential access: point to point access • ADSL: asymmetric digital subscriber line [similar to NOW Broadband] • up to 1 Mbps upstream • up to 8 Mbps downstream
Residential access… Cable modems cable headend home cable distribution network (simplified)
Residential access: cable modems Diagram: http://www.cabledatacomnews.com/cmic/diagram.html
company/univ local area network (LAN) connects end system to edge router Ethernet: shared or dedicated link connects end system and router 10 Mbs, 100Mbps, Gigabit Ethernet Company access: local area networks
shared wireless access network connects end system to router via base station aka “access point” wireless LANs: 802.11b (WiFi): 11 Mbps (good for networks) bluetooth: 720Kbps (good for device-to-device) router base station mobile hosts Wireless access networks
Typical home network components: ADSL or cable modem router/firewall/NAT Ethernet wireless access point Home networks wireless laptops to/from cable headend cable modem router/ firewall wireless access point Ethernet
a packet passes through many networks! Tier 3 ISP local ISP local ISP local ISP local ISP local ISP local ISP local ISP local ISP Network Access Point Tier-2 ISP Tier-2 ISP Tier-2 ISP Tier-2 ISP Tier-2 ISP Internet structure: network of networks Tier 1 ISP Tier 1 ISP Tier 1 ISP
Networks are complex! many “pieces”: hosts routers links of various media applications protocols hardware, software Protocol “Layers”
ticket (complain) baggage (claim) gates (unload) runway landing airplane routing ticket (purchase) baggage (check) gates (load) runway takeoff airplane routing airplane routing Analogy: Organization of air travel
ticket ticket (purchase) baggage (check) gates (load) runway (takeoff) airplane routing ticket (complain) baggage (claim gates (unload) runway (land) airplane routing baggage gate airplane routing airplane routing takeoff/landing airplane routing departure airport intermediate air-traffic control centers arrival airport Layering of airline functionality Layers: each layer implements a service • via its own internal-layer actions • relying on services provided by layer below
Why layering? Dealing with complex systems: • explicit structure allows identification, relationship of complex system’s pieces • layered reference model for discussion • modularization eases maintenance, updating of system • change of implementation of layer’s service transparent to rest of system • e.g., change in gate procedure doesn’t affect rest of system • layering considered harmful?
application: supporting network applications FTP, SMTP, STTP transport: host-host data transfer TCP, UDP network: routing of datagrams from source to destination IP, routing protocols link: data transfer between neighboring network elements PPP, Ethernet physical: bits “on the wire” application transport network link physical Internet protocol stack
network link physical link physical M M Ht Ht M M Hn Hn Hn Hn Ht Ht Ht Ht M M M M Hl Hl Hl Hl Hl Hl Hn Hn Hn Hn Hn Hn Ht Ht Ht Ht Ht Ht M M M M M M source Encapsulation message application transport network link physical segment datagram frame switch destination application transport network link physical router