CES 520 - WEEK 12 November 7, 2006 - Networks
Why use a network?
- To allow people to access the system remotely.
- Example: Home control/monitoring system similar to the class project.
- To allow communication with other systems.
- Example: Banking system. ATMs must communicate with a central server.
- Distributed processing: "A collection of spatially and functionally-distributed embedded nodes connected by a communication infrastructure."
- Example: Network of sensors and actuators in a factory.
- It often makes sense for sensors to include a microcontroller to do some processing locally.
- The network connects sensors and actuator nodes to controller nodes
- Allows easy upgrading of parts of the system
- Reduces cabling requirements
- Can provide redundancy for fault-tolerance
Network Types
- WAN - Wide Area Network
- Devices are far apart. Potentially world-side: The Internet is a WAN.
- Connects many LANs together.
- Typically uses leased lines.
- LAN - Local Area Network
- Devices are close together, normally in the same building or group of buildings.
- Typically faster data rate than a WAN.
- PAN - Personal Area Network
- Covers a small area close to a person (a few meters).
- Used for connecting computer devices (printers, PDAs, telephones, etc.)
- Can be a wired connection using computer bus such as USB or Firewire.
- Or wireless, using Bluetooth or infrared (IrDA).
- WLAN - Wireless Local Area Network
- An Access point is the interface between the wired and wireless LAN.
- Can also use peer-to-peer mode to connect directly between wireless terminals.
- Uses one or more of the "WiFi" (IEEE 802.11) standards
- 802.11 legacy - 2.4 GHz band - 1-2 Mbit/s
- 802.11b - 2.4 GHz band - 6.5-11 Mbit/s
- 802.11g - 2.4 GHz band - 11-108 Mbit/s
- 802.11a - 5 GHz band - 25-54 Mbit/s
- 802.11n - 2.4/5 GHz band - 200-540 Mbit/s (draft standard)
Example Networks
- Automobiles
- Hard real-time, fault-tolerant systems required for systems such as
- Engine and transmission control
- Suspension, steering and braking
- Airbags
- Soft real-time systems (telematics)
- Control of body devices (wipers, doors, seats, lights, windows, etc.)
- Multimedia systems
- Human-machine interface (HMI).
- ECU = "Electronic Control Unit"
- Mechatronic (mechanical/electronic) devices reduce cost, improve reliability and functionality
- Building automation
- Little need for real-time
- Low traffic volume
- Fault tolerant
- Network management is an issue
- Factory sensor networks
- Advantages:
- Flexible installation and maintenance
- Allows mobile operation (e.g. robots)
- Requirements:
- High reliability
- Low and predictable delay
- Support for large number of sensors/actuators
- Low power consumption
- Must withstand high electrical noise environment
- Data acquisition: Precision Agriculture and Habitat Monitoring
- Sensors deployed on animals and in the farm environment
- Uses wireless network
- Real-time not important
- Must be low power for long battery life
- Small size and weight for least impact on animals and environment
- Smart sensors allow local processing
- Data compression
- Complex filtering and triggering of data acquisition
- System health and status monitoring
- Nodes may be reprogrammed in the field
- Example: Seabird nesting environment on a small island off the coast of Maine, streaming on the web
- Healthcare monitoring
- Uses wireless network
- Monitor patient's condition both in hospital and at home
- Low-power, small size and weight
Communication techniques
- CSMA/CD - Carrier Sense Multiple Access/Collision Detect
- Collisions are detected and data re-sent after waiting a random time
- Used in Ethernet
- Not usable with wireless networks since the transmitter can't transmit and listen at the same time.
- CSMA/CA - CSMA/Collision Avoidance
- More deterministic than CSMA/CD, so more suitable for hard real-time systems
- When the channel becomes empty, the transmitting station waits a random time before transmitting.
- Another collision avoidance scheme is based on RTS/CTS (Request to send / clear to send)
- Transmitting node gets permission from receiver before transmitting.
- Helps avoid the hidden-transmitter problem on wireless networks.
- Used in CAN (automotive bus) and WiFi 802.11 (wireless LAN).
- TDMA - Time Division Multiple Access
- Each node gets predetermined time slots. Time slots are organized into frames.
- Very deterministic, perfect for hard teal-time systems
- Energy savings for wireless systems: Node turns off radio during time slots it is not using.
- Token-based networks
- Only the owner of the token is allowed to transmit
- Token ring was IBM's alternative to Ethernet. 4 or 16 Mbits/s.
- No collisions allowed. Each node can transmit only when it receives the token.
- Transmitting node captures the token, re-transmits the token when its frame comes back around the ring.
- FDDI (Fiber Distributed Data Interface) is a fiber optics network standard based on token ring.
- Master node technique
- The master decides which and when messages may be sent
- Mini slotting
- Each node has different wait time when the network becomes idle
Field Area Networks
- Before fieldbusses, a 4-20 mA analog loop was the common standard to transmit analog data.
- Compared to LANs (Local Area Networks), "Field Area Networks" typically
- Have lower data rates, smaller packet sizes.
- May have deterministic time requirements (control applications).
- "Fieldbus" is defined as a digital, two-way, multidrop communications network.
- A Programmable Logic Controller (PLC) typically controls each fieldbus.
- Often a central computer talks to each PLC over an Ethernet LAN.
- Each PLC talks to the hardware devices over the fieldbus.
- Some fieldbusses in common use:
- Automotive fieldbusses
- CAN - Controller Area Network
- Originally developed for automotive applications
- Up to 1 Mbps
- Event-triggered broadcast bus
- CSMA/CA
- Fixed priority arbitration - each node checks for higher-priority node before transmitting
- TT-CAN (Time-Triggered CAN)
- Session-layer extension to CAN
- All nodes follow predefined static schedule using a TDMA scheme
- Can also set aside time periods to support original event-triggered CAN traffic
- TTP/C - Time Triggered Protocol, class C
- Used for safety-critical automotive applications
- TDMA, for truly hard real-time communication
- Supports fault tolerance, fast error detection, and consistency checks
- Up to 25 Mbps
- LIN - Local Interconnect Network
- Cheaper, slower alternative to CAN
- Often several LIN networks interface to a CAN upper-layer network
- UART/SCI interface hardware
- Up to 20 kbps
- Master node controls bus synchronization for up to 16 slaves
- Traffic is time-triggered
- FlexRay
- Proposed in 1999 as next-generation fieldbus to replace CAN
- Up to 10 Mbps
- Synchronous (time-triggered) communication using TDMA
- Asynchronous communication using mini-slotting
- Supports redundant transmission channels and fast error detection
- Avionics/aerospace fieldbusses
- ARINC 629
- Multi-transmitter serial network, developed by Boeing
- Supports periodic and sporadic communication
- CSMA/CA using mini-slotting
- Up to 2 Mbps
- MIS-STD-1553
- Military variation of ARINC 629
- a.k.a. STANAG 3838AVS, STANAG 7155, DEF STAN 00-18, SAE AS15531
- 75-ohm twisted-pair differential signalling
- Half-duplex, 1 Mbit/s
- Dual-redundant interface
- IEEE 1393
- Spaceborne Fiber Optic Data Bus (SFODB)
- 1 Gbit/s
- AFDX - Avionics Full Duplex Switched Ethernet
- HDSB - High Speed Data Bus
- ASCB - Avionics Standard Communications bus
- IEC 61158, in 2000 combined several existing protocols into one standard:
- Foundation Fieldbus
- Intended for plant or factory automation
- Version H1: IEC 61158, type 1
- 31.25 kbit/s
- Intended to connect to field devices
- Uses twisted-pair cabling
- Version HSE: IEC 61158, type 5 - "High Speed Ethernet"
- 100 Mbit/s
- Intended for hosts, gateways, I/O subsystems, etc.
- Uses standard Ethernet cabling
- ControlNet - IEC 61158, type 2
- Milti-master system
- Up to 6 Mbit/s
- TDMA access allows deterministic real-time response for critical data.
- Uses RG-6 cable TV coaxial cable.
- Profibus - IEC 61158, type 3
- More than 14 million nodes worldwide.
- Profibus FMS - Client-server model, for automation devices
- Profibus DP - for sensors and actuators (e.g. robotics)
- Profibus PA - for process automation
- Master-slave with tokens
- Up to 12 Mbps
- P-Net - IEC 61158, type 4
- Launched in 1984
- Uses RS-485 shielded twisted pair. Up to 125 devices, up to 1200 meters.
- 76.8 kbit/s
- Multi-master. All communications initiated by the master.
- Interbus - IEC 61158, type 6
- Serial bus, available since 1987, to connect controllers to sensors and actuators
- WorldFIP - IEC 61158, type 8
- Used in train control systems
- Producer-Distributer-Consumers (PDC) communications model
- Up to 5 Mbps
- HART (Highway Addressable Remote Transducer Protocol)
- An early fieldbus that adds digital signalling to a legacy 4-20 mA analog current loop
- LonWorks
- ANSI/EIA 709.1
- Popular standard for building automation, train control, and industrial automation
- Transmission medium can be twisted-pair, power line, fiber optics, or RF
- Nodes can be implemented with custom ICs called "Neurons"
- DeviceNet
- Uses CAN for data link layer
- Up to 500 kbit/s
- Allows power and signal on the same twisted-pair line
- Modbus
- Open standard, available since 1979. Much free software exists.
- Serial and Ethernet versions. Wireless implementations also exist.
- Data may be binary (Modbus RTU) or human-readable (Modbus ASCII)
- One master polls up to 254 devices.
- TCN - Train Communication Network
- IEC 61375
- WTB (Wire Train Bus) connects all vehicles in the train. 1 Mbps
- MVB (Multifunction Vehicle Bus) within one vehicle. 1.5 Mbps
- Supports periodic and sporadic communication
- Industrial Ethernet
- Uses readily-available, low-cost, standard Ethernet hardware.
- However, Ethernet's standard CSMA/CD is not time deterministic.
- UDP can be made to have better real-time performance than TCP
- Some systems use only the two lower layers of the OSI model to obtain hard teal-time performance
- Use another standard's upper layers:
- Modbus, Profibus, DeviceNet, Foundation Fieldbus,
- Wireless standards
- Like Ethernet, WLAN (802.11) and Bluetooth are not real-time.
- No commercially-available real-time wireless protocols are currently available.
- This is an area of active research.
- USB, RS-232, RS-485, etc......
- Physical networks
- Twisted pair
- Fiber optic
- Power line
- Wireless
- Infrared
- Layer Mnemonic: "Please Do Not Teach Students Pointless Acronyms"
- Physical (electrical and physical specifications, hardware flow control) Examples:
- Cables and connector pinouts
- Voltage levels, data rates
- The "air interface" of a wireless network (modulation type, coding, etc.)
- Hubs and repeaters are specified at this level.
- Data link (packet-level error control, framing, physical addressing, medium access control (MAC))
- Examples: Ethernet, HDLC
- Bridges and switches operate at this level.
- Network (network routing, logical addressing, traffic management)
- Example: IP - Internet Protocol
- Routers operate at this level.
- Transport (data segmentation and reassembly, flow control, error checking) Examples:
- TCP - Transmission Control Protocol
- UDP - User Datagram Protocol
- Session (setup, coordination, and termination of connections between computers)
- Presentation (data transmission, compression, encryption) Examples:
- MIME encoding
- Data translation for XML
- Application (user interface, quality of service, authentication) Examples:
- Telnet: Terminal program
- FTP - File transfer
- HTTP - Internet transport language
- SMTP - Email
- A protocol stack is a communications protocol that uses two or more layers
- Each layer only uses services from the layer below it and only provides services to the layer above.
- The interfaces between layers are specified by the OSI standards.
- Very useful to partition complicated systems - each layer can be designed and understood separately.
- Layers 1 and 2 are typically implemented in hardware, the rest in software
- For simple real-time systems, there is little need for routing functionality or end-to-end control.
- Typically only use layers 1, 2 and 7 (including user layer).
- Layers 3/4 generally go to layers 2 or 7 and 5/6 always go to 7.
Ethernet
- IEEE 802.3
- Invented at Xerox in 1973, standardized by DEC, Intel and Xerox in 1979.
- Specifies the two lower layers of the 7-layer model, Physical and Data link (MAC)
- Uses so-called RJ-45 (actually 8P8C, 8-position/8-contact) connector and Cat5 cable.
- "10/100-baseT" means it can operate at the older 10 Mbit/s or newer 100 Mbit/s rate.
- 1000 Mbit/s is possible using Cat5e or Cat6 cable, and 10 Gbit/s or more with fiber optics.
- All devices (nodes) on a network communicate over a single cable.
- Any node can talk to any other node on the same network.
- Adding new devices does not require modifying the old ones.
- Ethernet is a LAN. Traditionally all devices must be within a few hundred meters.
- The Ethernet medium:
- Originally coaxial cable in a linear topology
- A failure anywhere in the cable takes out the entire segment
- Now usually twisted pair in a star configuration
- A Hub at the junction of the star retransmits the signals, electrically isolating each device.
- The hub includes the 100-ohm termininations, so only one device is allowed per port.
- Can also be fiber optic cable or wireless
- Each node has a unique 48-bit MAC address.
- 248 = 281,475 billion possible addresses
- Every device manufactured has its own address
- Broadcast frames have all-1 addresses. They are received by all nodes on the local network.
- Multicast frames go to a subset of addresses on the network.
- Each Ethernet frame includes source and destination address
- CSMA/CD limits the maximum practical number of devices on a network without excessive collisions.
- Bridges connect network segments, only allowing messages for the other segment to get through.
- Reduces collisions between nodes.
- Also allows different speed Ethernets on different segments
- A Switch is like a bridge, but with a dedicated segment for each node.
- Eliminates collisions between nodes.
- No collision detection is required.
- Allows full-duplex. (The node and switch can transmit at the same time.)
- A Router is like a bridge, but connecting entire networks rather than network segments.
- Does not forward broadcast messages. (Reduces traffic congestion)
- Allows connecting networks of different types (e.g. Ethernet and Token Ring)
- Routers are the backbone of the Internet
- A Gateway is a router that connects to the Internet.
- Often this is your home PC, with other PCs and peripherals on the LAN.
- Security issues
- Standard security protocols such as Secure Sockets Layer (SSL) and IP Security Protocol (IPSec) may demand excessive resources in an embedded system.
- SPINS (Security Protocols for Sensor Networks) is a proposed alternative.
The Internet
- The Internet Protocol or TCP/IP
- Has become the de-facto standard protocol suite.
- The protocol stack uses only 5 layers, with different names than the 7-layer OSI model.
- The IP layer translates data between different kinds of networks
- Also uses ARP (Address Resolution Protocol) to map IP addresses to MAC addresses.
- The IP layer is "unreliable" - data integrity is assured by higher layers.
- The Transport layer can use TCP or UDP to provide end-to-end services for applications.
- TCP - Transmission Control Protocol
- Used for browsing the Internet.
- Establishes a virtual circuit byte-pipe connection between applications.
- Assures data reliability and arranges packets in the proper order.
- UDP - User Datagram Protocol
- Unlike TCP, datagrams may get lost or arrive out of order.
- Because of the lower processing overhead, it is more efficient and closer to real-time than TCP.
- Used for broadcast and multicast messages, DNS, VoIP (Voice over IP), etc.
- Socket paradigm
- Each connection, or socket, is assigned a 16-bit port number from 1-65535 (0x01-0xFF)
- Some ports are "well known", i.e. assigned by IANA (Internet Assigned Number Authority)
- 80 - HTTP
- 21 - FTP
- 25 - SMTP (etc.)
- IP addresses are 32 bits, divided into four 8-bit octets
- Not to be confused with the 48-bit MAC address of a device on an Ethernet network
- DNS = Domain Name System
- Translates URLs to IP addresses
- Example: www.sonoma.edu ==> 130.157.5.73
- The DNS "hosts" file on a local PC is normally used only for local addresses
- Hierarchy of domain name servers. The highest level is on the right in the URL.
- Example: www.sonoma.edu - "edu" is the highest level, "sonoma" is the next level.
- The subnet mask restricts the range of the local subnet
- Logical AND of the mask and the IP address = Host ID
- The rest of the address is the Subnet ID
- Example: A mask of 255.255.255.0 restricts the range of sonoma.edu to 130.157.6.0 to 130.157.6.255
- All nodes on a network must be in the same subnet mask!
- Example: Your computer must be in the same subnet as your Internet service provider (ISP).
- A Broadcast Address has all 1's. An all-zero address also has special meaning.
- A mask of 255.255.255.0 only has 256-2 = 254 available addresses.
- DHCP - Dynamic Host Configuration Protocol
- The local node gets its IP address, subnet mask, and default router from a DHCP server.
- For example, your Internet connection uses a DHCP server at your ISP.
- Most home routers and firewalls can act as DHCP servers.
- DHCP is a broadcast-based protocol: Does not cross router boundaries.
Network programming using Dynamic C
- Most TCP/IP functions are in library DCRTCP.LIB
- Packets are processed each time tcp_tick() is called. - Should be called in the infinite loop.
- There must be a socket for each connection. Sockets may be opened passively or actively.
- Passive: tcp_listen() Wait for someone to contact your device.
- Active: tco_open() Force a connection with another device.
- Some good test programs in Samples\tcpip library: STATE.C, PING.C, NIST_TIME.C, ECHO.C
- If the Rabbit is connected directly to the Internet (through the SSU LAN), DHCP should be used.
- Macro USE_DHCP should be enabled.
- If using a direct Ethernet connection from PC to Rabbit board, DHCP should be turned off on the PC.
- To turn off DHCP and manually set the IP address and subnet mask: (Windows XP home edition)
- Start > Control Panel > Network Connections - Right-click on "Local Area Connection"
- Properties > General - Highlight "Internet Protocol" > Properties
- Follow instructions on page 32 of RCM3000 Getting Started manual
- Both the PC and Rabbit IP addresses must fit within the subnet mask.
- Double-click on "Local Area Connection" in the Network Connections window to enable Ethernet.
- To point the browser to the Rabbit: "http://10.10.6.100" (Or whatever IP address the Rabbit is using)
- If a direct connection is used, a crossover Ethernet cable is required.
Assignments:
- Read Embedded Systems Design, Chapter 9.
- Read An Introduction to TCP/IP For Embedded Systems Designers (in file "tcpintro.pdf" in Docs/Manuals/TCPIP/Introduction)
- Get familiar with the Dynamic C TCP/IP User's Manual. (in file "tcpipuser.pdf" on the disc in the back of the Embedded Systems Design book)
- Lab5 : Write a program that serves a web page to display temperature and date/time. (due in 2 weeks)