Outline - University of ConnecticutISO/OSI REFERENCE MODEL application presentation session...
Transcript of Outline - University of ConnecticutISO/OSI REFERENCE MODEL application presentation session...
Outline
• Introduction to Networked Embedded Systems- Embedded systems ➜ Networked embedded systems ➜ Embedded Internet
- Network properties
• Layered Network Architectures- OSI framework – descriptions of layers
- Internet protocol stack
• Physical Layer Options- Guided transmission media
- Wireless transmission media
• Data Link Layer Services and MAC Protocols
• Embedded System Communication Protocols- Wired protocols: Ethernet, CAN, TTP, BACnet
- Wireless protocols: Wi-Fi, ZigBee, WirelessHART
• TCP/IP Stack and 6LoWPAN Stack
• Modeling and Analysis of Communication Protocols
NETWORKS FOR ALL SIZES AND SCALES
• NoCs – connecting processors inside MPSoCs
• SPI, I2C, UART... – connecting discrete components inside boards
• USB, FireWire... – connecting peripherals around a PC
• Bluetooth, RFID, NFC... – connecting peripherals or sensors in small areas (BANs,
PANs ...)
• CAN, fieldbuses... – connecting sensors, actuators and controlling equipment in a
monitoring or control system (DCS)
• Zigbee, WirelessHART... – connection of self-organized wireless sensors (WSNs)
• Ethernet, WiFi... – connection of PCs and equipment in local areas (LANs)
• 10G Ethernet, ATM... – connection of large systems in large areas (MANs, WANs)
• GSM, LTE, WiMax… – wide area communications (MANs,WANs)
WHY NETWORKED AND DISTRIBUTED ARCHITECTURE
• Processing closer to data source / sink- Intelligent sensors and actuators
- Reduce the computational overhead on the central processing node
• Dependability- Error-containment within nodes
• Composability- System composition by integrating components and subsystems
• Scalability- Easy addition of new nodes with new or replicated functionality
- Especially for wireless
• Maintainability- Modularity and easy node replacement
- Simplification of the cabling, especially for wireless
DISTRIBUTED VS. NETWORKED EMBEDDED SYSTEMS
Distributed Embedded Systems
• System-centered (designed as a whole)- Confined in space (despite possibly large)
- Normally fixed set of components
- Preference for wired networks w/ fixed topology
• Most common non-functional requirements- Real-time
- End-to-end constraints on response to stimuli
- Jitter constraints on periodic activities
- Dependability- Ultra high reliability and safety, high availability
- Composability
- Maintainability
DISTRIBUTED VS. NETWORKED EMBEDDED SYSTEMS
Networked Embedded Systems
• Interconnected stand-alone equipment or systems for extra functionality
(communication-centered)- Fuzzy notion of global system
- Variable set of components
- A combination of wireless/wired networks- Structured / Ad-hoc connections
- Varying topology
- Multi-hop communication
• Most common non-functional requirements- Scalability
- Heterogeneity
- Self-configuration
- (Soft) real-time
NETWORK PROPERTIES
• Supported topologies
- star, line, tree, mesh, bus, ring…
• Media access mechanisms
- controlled access vs. uncontrolled access
• Network performance metrics
- Bandwidth, throughput and goodput
• Network real-time performance
- latency, jitter, coherent notion of time
• Network Security
- Cryptosecurity, Emission, Transmission and Physical security
Outline
• Introduction to Networked Embedded Systems- Embedded systems ➜ Networked embedded systems ➜ Embedded Internet
- Network properties
• Layered Network Architectures- OSI framework – descriptions of layers
- Internet protocol stack
• Physical Layer Options- Guided transmission media
- Wireless transmission media
• Data Link Layer Services and MAC Protocols
• Embedded System Communication Protocols- Wired protocols: Ethernet, CAN, TTP, BACnet
- Wireless protocols: Wi-Fi, ZigBee, WirelessHART
• TCP/IP Stack and 6LoWPAN Stack
• Modeling and Analysis of Communication Protocols
LAYER ARCHITECTURE
• Layer architecture simplifies the network design.
- Explicit structure allows identification, relationship of complex system’s pieces.
- Modularization eases maintenance, updating of system.
- Change of implementation of layer’s service transparent to rest of system.
• It is easy to debug network applications with a layered architecture.
• The network management is easier due to the layered architecture.
• Network layers follow a set of rules, called protocol.
• The protocol defines the format of the data being exchanged, and thecontrol and timing for the handshake between layers.
WHY LAYERING CONSIDERED HARMFUL?
Structured layering implies that the functions of each layer are carried
out completely before the protocol data unit is passed to the next layer.
This means that the optimization of each layer has to be done
separately.
Such ordering constraints are in conflict with efficient implementation of
data manipulation functions.
ISO/OSI REFERENCE MODEL
application
presentation
session
transport
network
link
physical
• Application: Network processes to applications
- FTP, SMTP, HTTP…
• Presentation: Data representation
- encryption, compression, machine-specific conventions
• Session: Interhost communication
- synchronization, checkpointing, recovery of data exchange
• Transport: End-to-end connections
- TCP, UDP
• Network: Addressing and routing
- IP, routing protocols
• Link: Access to media
- Ethernet, 802.111 (WiFi), PPP
• Physical: bits “on the wire”
INTERNET PROTOCOL STACK
• Internet stack “missing” presentation and session layers.
- These services, if needed, must be implemented in applications.
• Application: supporting network applications
- FTP, SMTP, HTTP
• Transport: process data transfer
- TCP, UDP
• Network: routing of datagrams from source to destination
- IP, routing protocols
• Link: data transfer between neighboring network elements
- Ethernet, 802.111 (WiFi), PPP
• Physical: bits “on the wire”
application
transport
network
link
physical
EMBEDDED / REAL-TIME PROTOCOL STACK
• The OSI 7 layers impose a considerable overhead- Time to execute the protocol stack
- Time to transmit protocol control information
- Memory requirements (for all intermediate protocol invocations)
• Many embedded / real-time networks- are dedicated to a well defined application
- use single broadcast domain (no need for routing)
- use short messages (no need to fragment/reassemble)
Figure from Dr. Luis Almeida
Outline
• Introduction to Networked Embedded Systems- Embedded systems ➜ Networked embedded systems ➜ Embedded Internet
- Network properties
• Layered Network Architectures- OSI framework – descriptions of layers
- Internet protocol stack
• Physical Layer Options- Guided transmission media
- Wireless transmission media
• Data Link Layer Services and MAC Protocols
• Embedded System Communication Protocols- Wired protocols: Ethernet, CAN, TTP, BACnet
- Wireless protocols: Wi-Fi, ZigBee, WirelessHART
• TCP/IP Stack and 6LoWPAN Stack
• Modeling and Analysis of Communication Protocols
GUIDED TRANSMISSION MEDIA
Magnetic Media
• HP Ultrium tape =100GB. A box 60x60x60 holds 2000 tapes =>200 Tera
bytes=1600 Tbits.
• A box can be delivered in 24 hours anywhere in USA => throughput: 1600
Tbits/86400 sec = 19 Gbps!
Twisted Pair/ Unshielded TP (UTP)
• Classic telephone lines- Category 3 (a) – 16MHz
- Category 5 (b) – 100 MHz
- Category 6 – 250 MHz
- Category 7 – 600 MHz
• Throughput : a few Mbit/sec – Gbits/sec.
• Works up to 100m, afterwards repeaters needed.
GUIDED TRANSMISSION MEDIA (CONT.)
Coaxial Cable
• Bandwidth ~ 1 GHz (better shielding)
• Up to 200m
Fiber Optics
• Rather used at higher bandwidths
• Invulnerable to electric and
electromagnetic signals
• Could be very long
• Hard to tamper with -> Security
• Usually simplex transmission
THE ELECTROMAGNETIC SPECTRUM
VLF = Very Low Frequency UHF = Ultra High Frequency
LF = Low Frequency SHF = Super High Frequency
MF = Medium Frequency EHF = Extra High Frequency
HF = High Frequency UV = Ultraviolet Light
VHF = Very High Frequency
• Frequency and wave length: = c/f , wave length , speed of light c 3x108m/s,
frequency f
• Radio spectrum is part of the electromagnetic spectrum from 1Hz to 3THz:
http://en.wikipedia.org/wiki/Radio_spectrum
1 Mm
300 Hz
10 km
30 kHz
100 m
3 MHz
1 m
300 MHz
10 mm
30 GHz
100 m
3 THz
1 m
300 THz
visible lightVLF LF MF HF VHF UHF SHF EHF infrared UV
optical transmission
DATA LINK LAYER SERVICES
• Framing, link access:
- encapsulate datagram into frame, adding header, tailer
- channel access if shared medium
- “MAC” addresses used in frame headers to identify source, destination
• Reliable delivery between adjacent nodes- Seldom used on low bit-error link (fiber, some twisted pair)
- wireless links: high error rates
• Flow control:
- Pacing between adjacent sending and receiving nodes
• Error detection:
- Errors caused by signal attenuation, noise.
- Receiver detects presence of errors: signals sender for retransmission or drops frame
• Error correction:
- Receiver identifies and corrects bit error(s) without resorting to retransmission
• Half-duplex and full-duplex
- with half duplex, nodes at both ends of link can transmit, but not at same time
MULTIPLE ACCESS PROTOCOLS
• Single shared broadcast channel
• Two or more simultaneous transmissions by nodes: interference
- Collision if node receives two or more signals at the same time
Multiple Access Protocol
• distributed algorithm that determines how nodes share channel, i.e.,
determine when node can transmit.
• communication about channel sharing must use channel itself.
- no out-of-band channel for coordination
AN IDEAL MULTIPLE ACCESS PROTOCOL
given: broadcast channel of rate R bps
desiderata:
1. when one node wants to transmit, it can send at rate R.
2. when M nodes want to transmit, each can send at average rate
R/M
3. fully decentralized:
• no special node to coordinate transmissions
• no synchronization of clocks, slots
4. simple
MAC PROTOCOLS: TAXONOMY
Three broad classes:
• Channel partitioning
- divide channel into smaller “pieces” (time slots, frequency, code)
- allocate piece to node for exclusive use
• Random access
- channel not divided, allow collisions
- “recover” from collisions
• “Taking turns”
- nodes take turns, but nodes with more to send can take longer turns
RANDOM ACCESS PROTOCOLS
• When node has packet to send:
- Transmit at full channel data rate R.
- No a priori coordination among nodes
- Two or more transmitting nodes ➜ “collision”
• Random access MAC protocol specifies:
- How to detect collisions
- How to recover from collisions (e.g., via delayed retransmissions)
• Examples of random access MAC protocols:
- Slotted ALOHA
- ALOHA
- CSMA, CSMA/CD, CSMA/CA
Pros:
• Single active node can
continuously transmit at full rate
of channel
• Highly decentralized: only slots in
nodes need to be in sync
• Simple
Cons:
• Collisions, wasting slots
• Idle slots
• Nodes may be able to detect collision in less than time to transmit packet
• Clock synchronization
SLOTTED ALOHA
1 1 1 1
2
3
2 2
3 3
node 1
node 2
node 3
C C CS S SE E E
• suppose: N nodes with many
frames to send, each transmits
in slot with probability p
• prob that given node has
success in a slot = p(1-p)N-1
• prob that any node has a
success = Np(1-p)N-1
• max efficiency: find p* that
maximizes
Np(1-p)N-1
• for many nodes, take limit of
Np*(1-p*)N-1 as N goes to
infinity, gives:
max efficiency = 1/e = .37
efficiency: long-run fraction of successful slots (many nodes, all with many
frames to send)
at best: channelused for useful
transmissions 37%of time!
SLOTTED ALOHA: EFFICIENCY
PURE (UNSLOTTED) ALOHA
• Unslotted Aloha: simpler, no synchronization
• When frame first arrives:
- transmit immediately
• Collision probability increases:
- frame sent at t0 collides with other frames sent in [t0-1,t0+1]
PURE ALOHA EFFICIENCY
P(success by given node) = P(node transmits) .
P(no other node transmits in [t0-1,t0] .
P(no other node transmits in [t0,t0+1]
= p . (1-p)N-1 . (1-p)N-1
= p . (1-p)2(N-1)
… choosing optimum p and then letting n
= 1/(2e) = .18
even worse than slotted Aloha!
CSMA (CARRIER SENSE MULTIPLE ACCESS)
CSMA: listen before transmit
• If channel sensed idle: transmit entire frame
• If channel sensed busy: defer transmission
• Human analogy: don’t interrupt others!
CSMA/CD (COLLISION DETECTION)
CSMA/CD: carrier sensing, deferral as in CSMA
• collisions detected within short time
• colliding transmissions aborted, reducing channel wastage
• Collision detection:
- easy in wired media: measure signal strengths, compare transmitted,
received signals
- difficult in wireless media: received signal strength overwhelmed by local
transmission strength
• Human analogy: the polite conversationalist
CSMA/CA (COLLISION AVOIDANCE)
• CSMA/CA:
- Wireless MAC protocols often use collision avoidance techniques, in conjunction with a
(physical or virtual) carrier sense mechanism
- To be discussed more in WiFi and ZigBee protocols
• Collision avoidance
- Nodes hearing RTS or CTS stay silent for the duration of the corresponding
transmission.
- Once channel becomes idle, the node waits for a randomly chosen duration before
attempting to transmit.
• Carrier sense
- Nodes stay silent when carrier sensed (physical/virtual)
- Physical carrier sense: carrier sense threshold
- Virtual carrier sense using Network Allocation Vector (NAV): NAV is updated based on
overheard RTS/CTS/DATA/ACK packets
“TAKING TURNS” MAC PROTOCOLS
Channel partitioning MAC protocols:
• Share channel efficiently and fairly at high load
• Inefficient at low load: delay in channel access, 1/N bandwidth
allocated even if only 1 active node!
Random access MAC protocols
• Efficient at low load: single node can fully utilize channel
• High load: collision overhead
“taking turns” protocols
• Look for best of both worlds.
SUMMARY OF MAC PROTOCOLS
• Channel partitioning, by time, frequency or code
- Time Division, Frequency Division
• Random access (dynamic)
- ALOHA, S-ALOHA, CSMA, CSMA/CD
- Carrier sensing: easy in some technologies (wire), hard in others
(wireless)
- CSMA/CD used in Ethernet
- CSMA/CA used in 802.11
• Taking turns
- Polling from central site, token passing
- Bluetooth, FDDI, token ring
Outline
• Introduction to Networked Embedded Systems- Embedded systems ➜ Networked embedded systems ➜ Embedded Internet
- Network properties
• Layered Network Architectures- OSI framework – descriptions of layers
- Internet protocol stack
• Physical Layer Options- Guided transmission media
- Wireless transmission media
• Data Link Layer Services and MAC Protocols
• Embedded System Communication Protocols- Wired protocols: Ethernet, CAN, TTP, BACnet
- Wireless protocols: Wi-Fi, ZigBee, WirelessHART
• TCP/IP Stack and 6LoWPAN Stack
• Modeling and Analysis of Communication Protocols
EMBEDDED SYSTEM COMMUNICATION PROTOCOLS
Wired communication protocol examples:
• Ethernet (802.3)
• CAN
• TTP
• BACnet
Wireless communication protocol examples:
• Wi-Fi (802.11)
• ZigBee (based on 802.15.4 PHY and MAC)
• WirelessHART (Not discussed in this lecture)
INFRASTRUCTURE VS. AD-HOC NETWORKS
infrastructure
network
ad-hoc network
APAP
AP
wired network
AP: Access Point
802.11: INFRASTRUCTURE
• Station (STA)
- terminal with access mechanisms to
the wireless medium and radio contact
to the access point
• Access Point
- station integrated into the wireless
LAN and the distribution system
• Basic Service Set (BSS)
- group of stations using the same AP
• Portal
- bridge to other (wired) networks
• Distribution System
- interconnection network to form one
logical network (EES: Extended
Service Set) based on several BSS
Distribution System
Portal
802.x LAN
Access
Point
802.11 LAN
BSS2
802.11 LAN
BSS1
Access
Point
STA1
STA2 STA3
ESS
802.11: AD HOC MODE
Direct communication within a
limited range
• Station (STA): terminal with
access mechanisms to the
wireless medium
• Independent Basic Service Set
(IBSS): group of stations using
the same network
802.11 LAN
IBSS2
802.11 LAN
IBSS1
STA1
STA4
STA5
STA2
STA3
WLAN: IEEE 802.11B
• Data rate
- 1, 2, 5.5, 11 Mbit/s, depending on
SNR
- User data rate max. approx. 6
Mbit/s
• Transmission range
- 300m outdoor, 30m indoor
- Max. data rate ~10m indoor
• Frequency
- Free 2.4 GHz ISM-band
• Availability
- Many products and vendors
• Quality of Service
- Best effort, no guarantees (unless polling is used, limited support in products)
• Pros
- Many installed systems and vendors
- Available worldwide
- Free ISM-band
• Cons
- Heavy interference on ISM-band
- No service guarantees
- Relatively low data rate
WLAN: IEEE 802.11A
• Data rate
- 6, 9, 12, 18, 24, 36, 48, 54 Mbit/s, depending on SNR
- User throughput (1500 byte packets): 5.3 (6), 18 (24), 24 (36), 32 (54)
- 6, 12, 24 Mbit/s mandatory
• Transmission range
- 100m outdoor, 10m indoor
- E.g., 54 Mbit/s up to 5 m, 48 up to 12 m, 36 up to 25 m, 24 up to 30m, 18 up to 40 m, 12 up to 60 m
• Frequency
- Free 5.15-5.25, 5.25-5.35, 5.725-5.825 GHz ISM-band
• Availability
- Some products, some vendors
• Quality of Service
- Best effort, no guarantees (same
as all 802.11 products)
• Pros
- Fits into 802.x standards
- Free ISM-band
- Available, simple system
- Uses less crowded 5 GHz band
- Higher data rates
• Cons
- Shorter range
WLAN: IEEE 802.11N
• Data rate
- 7.2, 14.4, 21.7, 28.9, …, 72.2 Mbit/s, depending on SNR
• Multiple input multiple output (MIMO)
• 20MHz and 40MHz bands
• Transmission range
- Increase range by several factors due to MIMO
• Frequency
- Free 2.4GHz ISM-band
- Free 5.15-5.25, 5.25-5.35, 5.725-5.825 GHz ISM-band
• Availability
- Some products, some vendors
• Quality of Service
- Best effort, no guarantees (same
as all 802.11 products)
• Pros
- Fits into 802.x standards
- Free ISM-band
- Available, simple system
- Uses dual band
- Higher data rates
• Cons
- Interference on ISM-band
802.11 MAC LAYER
Distributed and centralized access methods
• DCF CSMA/CA (mandatory)
• Collision avoidance via randomized “back-off“ mechanism
• Minimum distance between consecutive packets
• ACK packet for acknowledgements (not for broadcasts)
• DCF w/ RTS/CTS (optional)
• Distributed Foundation Wireless MAC
• Avoids hidden terminal problem
• PCF (optional)
• Access point polls terminals according to a list
DCF ILLUSTRATION
• Before a node transmits, it listens for activity on the network
• If medium is busy, node waits to transmit
• After medium is clear, don't immediately start transmitting...
• Otherwise all nodes would start talking at the same time!
• Instead, delay a random amount of time (random backoff)
Interframe space (IFS)
Sender
Receiver
Time
802.11 - MAC LAYER (CONT.)
Priorities defined through different inter frame spaces
• No guarantee, hard priorities
• SIFS (Short Inter Frame Spacing)
• Highest priority, for ACK, CTS, polling response
• PIFS (PCF IFS)
• Medium priority, for time-bounded service using PCF
• DIFS (DCF, Distributed Coordination Function IFS)
• Lowest priority, for asynchronous data service
t
medium busySIFS
PIFS
DIFSDIFS
next framecontention
A B C
HIDDEN TERMINAL PROBLEM
• B can communicate with both A and C
• A and C cannot hear each other
• Problem
• When A transmits to B, C cannot detect the transmission using the carrier
sense mechanism
• If C transmits, collision will occur at node B
• Solution
• Hidden sender C needs to defer
A B C
SOLUTION FOR HIDDEN TERMINAL PROBLEM: MACA
• When A wants to send a packet to B, A first sends a Request-to-Send
(RTS) to B
• On receiving RTS, B responds by sending Clear-to-Send (CTS),
provided that A is able to receive the packet
• When C overhears a CTS, it keeps quiet for the duration of the transfer
- Transfer duration is included in both RTS and CTS
BACKOFF INTERVAL
• Collision avoidance
- Backoff intervals used to reduce collision probability
• When transmitting a packet, choose a backoff interval in the range [0, CW]
- CW is contention window
• Count down the backoff interval when medium is idle
- Count-down is suspended if medium becomes busy
• Transmit when backoff interval reaches 0
BACKOFF INTERVAL
• The time spent counting down backoff intervals is a part of MAC
overhead
• Important to choose CW appropriately
- large CW large overhead
- small CW may lead to many collisions (when two nodes count down to 0
simultaneously)
• How to choose an appropriate CW?
802.11 - FRAME FORMAT
• Types
- control frames, management frames, data frames
• Sequence numbers
- important against duplicated frames due to lost ACKs
• Addresses
- Sender, receiver, BSS identifier
• Miscellaneous
- sending time, checksum, frame control, data
Frame
Control
Duration/
ID
Address
1
Address
2
Address
3
Sequence
Control
Address
4Data CRC
2 2 6 6 6 62 40-2312bytes
Protocol
versionType Subtype
To
DS
More
FragRetry
Power
Mgmt
More
DataWEP
2 2 4 1
From
DS
1
Order
bits 1 1 1 1 1 1
IEEE 802.15.4 MAC
Upper Layers
IEEE 802.15.4 Service
Specific Convergence Sub
Layer (SSCS)
IEEE 802.2
LLC, Type I
IEEE 802.15.4
2400 MHz
PHY
IEEE 802.15.4
868/915 MHz
PHY
802.15.4 ARCHITECTURE
DEVICE ADDRESSING
• Two or more devices communicating on the same physical channel
constitute a WPAN which includes at least one FFD (PAN
coordinator).
• Each independent PAN will select a unique PAN identifier.
• All devices operating on a network shall have unique 64-bit
extended address. This address can be used for direct
communication in the PAN.
• An associated device can use a 16-bit short address, which is
allocated by the PAN coordinator when the device associates.
IEEE 802.15.4 SUPPORTED TOPOLOGIES
• MAC supports 2 topologies: star and peer-to-peer
• Star topology supports beacon and no-beacon structure
- All communication done through PAN coordinator
PHYSICAL FREQUENCIES AND CHANNELS
868MHz / 915MHz
PHY
2.4 GHz
868.3 MHz
Channel 0 Channels 1-10
Channels 11-26
2.4835 GHz
928 MHz902 MHz
5 MHz
2 MHz
2.4 GHz
PHY
IEEE 802.15.4 MAC OVERVIEW
• Star networks: devices are associated with coordinators
• Forming a PAN, identified by a PAN identifier
• Coordinator
• Bookkeeping of devices, address assignment, generate beacons
• Talks to devices and peer coordinators
• Beacon-mode superframe structure
• GTS assigned to devices upon request
Active period Inactive period
Contention
access
period
Guaranteed time
slots (GTS)Beacon
Coordinator Device
Beacon
Data
request
Acknowledgement
Data
Acknowledgement
IEEE 802.15.4 GENERAL FRAME STRUCTURE
Payload
PH
Y L
ayer
MA
C
Layer
MAC Header
(MHR)
MAC Footer
(MFR)
MAC Protocol Data Unit (MPDU)
MAC Service Data Unit
(MSDU)
PHY Header
(PHR)
Synch. Header
(SHR)PHY Service Data Unit (PSDU)
Four Types of MAC Frames:
• Data Frame
• Beacon Frame
• Acknowledgment Frame
• MAC Command Frame
EMBEDDED SYSTEM COMMUNICATION PROTOCOLS
Wired communication protocol examples:
• Ethernet (802.3)
• CAN
• TTP
• BACnet
Wireless communication protocol examples:
• Wi-Fi (802.11)
• ZigBee (based on 802.15.4 PHY and MAC)
• WirelessHART (Not discussed in this lecture)
EMBEDDED SYSTEM COMMUNICATION PROTOCOL: ETHERNET
“dominant” wired LAN technology:
• cheap $20 for NIC
• first widely used LAN technology
• simpler, cheaper than token LANs and
ATM
• kept up with speed race: 10 Mbps – 10
Gbps
An example avionics communication network:
AFDX network (Avionics Full Duplex Ethernet
(Figure from Airbus, more details can be found
at: http://www.artist-
embedded.org/docs/Events/2007/IMA/Slides/AR
TIST2_IMA_Itier.pdf)
ETHERNET: PHYSICAL TOPOLOGY
• Bus: traditional topology
- All workstations are connected on a single cable.
- All transmissions go to all the connected workstation.
• Star: the most common solution today
- Active switch in center
- Each “spoke” runs a (separate) Ethernet protocol
bus: coaxial cable star TTEthernet
ETHERNET FRAME STRUCTURE
Sending adapter encapsulates IP datagram (or other network layer protocol
packet) in Ethernet frame
Preamble:
• 7 bytes with pattern 10101010 followed by one byte with pattern
10101011
• Used to synchronize receiver, sender clock rates
dest.address
sourceaddress
data (payload) CRCpreamble
type
ETHERNET: UNRELIABLE, CONNECTIONLESS
• Connectionless: no handshaking between sending and receiving NICs
• Unreliable: receiving NIC doesn’t send ACKs or NACKs to sending
NIC
- data in dropped frames recovered only if initial sender uses higher layer
reliable data transfer (e.g., TCP), otherwise dropped data lost
• Ethernet’s MAC protocol: unslotted CSMA/CD with binary backoff
802.3 ETHERNET STANDARDS: LINK & PHYSICAL LAYERS
Many different Ethernet standards
• Common MAC protocol and frame format
• Different speeds: 2 Mbps, 10 Mbps, 100 Mbps, 1Gbps, 10G bps
• Different physical layer media: fiber, cable
application
transport
network
link
physical
MAC protocol
and frame format
100BASE-TX
100BASE-T4
100BASE-FX100BASE-T2
100BASE-SX 100BASE-BX
fiber physical layercopper (twister
pair) physical layer
https://en.wikipedia.org/wiki/Ethernet_physical_layer
Link Layer 5-20
Ethernet switch link-layer device: takes an active role store, forward Ethernet frames examine incoming frame’s MAC address,
selectively forward frame to one-or-more outgoing links when frame is to be forwarded on segment, uses CSMA/CD to access segment
transparent hosts are unaware of presence of switches
plug-and-play, self-learning switches do not need to be configured
Link Layer 5-24
Switch: frame filtering/forwarding
when frame received at switch:
1. record incoming link, MAC address of sending host2. index switch table using MAC destination address3. if entry found for destination
then {if destination on segment from which frame arrived
then drop frameelse forward frame on interface indicated by entry
}else flood /* forward on all interfaces except arriving
interface */
Link Layer 5-26
Interconnecting switches
switches can be connected together
Q: sending from A to G - how does S1 know to forward frame destined to F via S4 and S3? A: self learning! (works exactly the same as in
single-switch case!)
A
B
S1
C D
E
FS2
S4
S3
H
I
G
Link Layer 5-28
Switches vs. routers
both are store-and-forward: routers: network-layer devices (examine network-layer headers)switches: link-layer devices (examine link-layer headers)
both have forwarding tables:routers: compute tables using routing algorithms, IP addressesswitches: learn forwarding table using flooding, learning, MAC addresses
applicationtransportnetwork
linkphysical
networklink
physical
linkphysical
switch
datagram
applicationtransportnetwork
linkphysical
frame
frame
frame
datagram
CONTROLLER AREA NETWORK (CAN)
• A multi-master bus created in early 90s by Bosch,
GmbH, for use in automotive industry.
- An open, linear structure with one logic bus line and equal nodes
- The number of nodes is not limited by the protocol
• Source-addressing (message identifiers) with 11 bits
in version A and 29 bits in version B
• Asynchronous bus access with Arbitration on
Message Priority (CSMA-CD w/ AMP)
• Max payload of 8 bytes and Max data rate of 1Mbps
- At a maximum bus length of 40m when using a twisted wire pair
CAN BUS CHARACTERISTICS: WIRED-AND
• There are two bus states, called "dominant" and "recessive".
• The bus logic uses a "Wired-AND" mechanism, that is, "dominant bits“
(equivalent to the logic level "Zero") overwrite the "recessive" bits
(equivalent to the logic level "One" ).
(Figure is from Siemens Microelectronics, Inc.)
BUS ACCESS AND ARBITRATION: CSMA/CD W/ AMP
• At each CAN device, the start of frame bit notifies a transmission is being sent.
• The identifier bit shows the priority of the message along with determining which device the data belongs to.
• It is not permitted for different nodes to send messages with the same identifier
as arbitration could fail leading to collisions and errors.
(Figure is from Siemens Microelectronics, Inc.)
ERROR DETECTION MECHANISMS IN THE CAN PROTOCOL
• Cyclic Redundancy Check (CRC)
- An Error Frame to request retransmission of the garbled frame.
• Acknowledge Check
• An Acknowledge Error occurred when no other nodes on the bus received the frame correctly
• Frame Check
- A Form Error occurred is a transmitter detects a dominant bit in one of the four segments: CRC
Delimiter, Acknowledge Delimiter, End of Frame or Interframe Space.
• Bit Monitoring
- All nodes perform Bit Monitoring: A Bit Error occurs if a transmitter 1) sends a D bit but detects a R bit on the bus line or, 2) sends a R bit but detects a D bit on the bus line.
• Bit Stuffing Check- If six consecutive bits with the same polarity are detected between Start of Frame and the CRC
Delimiter, the bit stuffing rule has been violated.
Error Handling: detected errors are made public to all other nodes via Error Frames. The TX of the erroneous message is aborted and the frame is repeated ASAP.
v6.12.2009 6LoWPAN: The Wireless Embedded Internet, Shelby & Bormann 6
Benefits of 6LoWPAN Technology
• Low‐power RF + IPv6 = The Wireless Embedded Internet
• 6LoWPAN makes this possible• The benefits of 6LoWPAN include:
– Open, long‐lived, reliable standards– Easy learning‐curve– Transparent Internet integration– Network maintainability– Global scalability– End‐to‐end data flows
What is 6LoWPAN?
14
• IPv6 over Low‐Power Wireless Area Networks• Defined by IETF standards
– RFC 4919, 4944 – draft‐ietf‐6lowpan‐hc and ‐nd– draft‐ietf‐roll‐rpl
• Stateless header compression• Enables a standard socket API• Minimal use of code and memory• Direct end‐to‐end Internet integration
– Multiple topology options
IPv6
Protocol Stack
15
Features
16
• Support for 64‐bit and 16‐bit 802.15.4 addressing• Useful with low‐power link layers such as IEEE 802.15.4,
narrowband ISM and power‐line communications• Efficient header compression
• IPv6 base and extension headers, UDP header
• Network autoconfiguration using neighbor discovery (ND)• Unicast, multicast and broadcast support
– Multicast is compressed and mapped to broadcast
• Fragmentation– 1280 byte IPv6 MTU ‐> 127 byte 802.15.4 frames
• Support for IP routing (e.g. IETF RPL)
6LoWPAN Architecture
17
Single Edge Router Multiple Edge Routers with common backbone link
No route outside the LoWPAN
v6.12.2009 6LoWPAN: The Wireless Embedded Internet, Shelby & Bormann 18
Internet Protocol v6
• IPv6 (RFC 2460) = the next generation Internet Protocol– Complete redesign of IP addressing– Hierarchical 128‐bit address with decoupled host identifier– Stateless auto‐configuration– Simple routing and address management
• Majority of traffic not yet IPv6 but...– Most PC operating systems already have IPv6– Governments are starting to require IPv6– Most routers already have IPv6 support– So the IPv6 transition is coming
v6.12.2009 6LoWPAN: The Wireless Embedded Internet, Shelby & Bormann 19
IPv4 vs. IPv6 Addressing
v6.12.2009 6LoWPAN: The Wireless Embedded Internet, Shelby & Bormann 21
IPv4 vs. IPv6 Header
6LoWPAN Format
22
• 6LoWPAN is an adaptation header format– Enables the use of IPv6 over low‐power wireless links – IPv6 header compression and UDP header compression
IPv6 Addressing
23
• 128‐bit IPv6 address = 64‐bit prefix + 64‐bit Interface ID (IID)
• The 64‐bit prefix is hierarchical – Identifies the network you are on and where it is globally
• The 64‐bit IID identifies the network interface – Must be unique for that network– Typically is formed statelessly from the interface MAC address– Called Stateless Address Autoconfiguration (RFC2462)
• There are different kinds of IPv6 addresses
6LoWPAN Addressing
24
• IPv6 addresses are compressed in 6LoWPAN• A LoWPAN works on the principle of
– flat address spaces (wireless network is one IPv6 subnet)– with unique MAC addresses (e.g. 64‐bit or 16‐bit)
• 6LoWPAN compresses IPv6 addresses by– Eliding the IPv6 prefix
• Global prefix known by all nodes in network• Link‐local prefix indicated by header compression format
– Compressing the IID• Elided for link‐local communication• Compressed for multihop dst/src addresses
Header Comparison
27
v6.12.2009 6LoWPAN: The Wireless Embedded Internet, Shelby & Bormann 28
6LoWPAN Stateless Header Compression
v6.12.2009 6LoWPAN: The Wireless Embedded Internet, Shelby & Bormann 29
6LoWPAN Stateless Header Compression
Fragmentation
30
• IPv6 requires underlying links to support Minimum Transmission Units (MTUs) of at least 1280 bytes
• IEEE 802.15.4 leaves approximately 80‐100 bytes of payload!• RFC4944 defines fragmentation and reassembly of IPv6• The performance of large IPv6 packets fragmented over low‐
power wireless mesh networks is poor!– Lost fragments cause whole packet to be retransmitted– Low‐bandwidth and delay of the wireless channel– 6LoWPAN application protocols should avoid fragmentation– Compression should be used on existing IP application protocols when
used over 6LoWPAN if possible
• Fragment recovery is currently under IETF consideration
v6.12.2009 6LoWPAN: The Wireless Embedded Internet, Shelby & Bormann 31
FragmentationInitial 6LoWPAN fragment
Non-initial 6LoWPAN fragment
Application Protocols
• The processes of applications communicate over IP using an Internet Socket approach
• 6LoWPAN also uses the Internet Socket paradigm
• Application protocols used with 6LoWPAN however have special design and performance requirements
Application Protocols (Cont.)
INTRODUCTION TO REAL-TIME SYSTEMS
• A real-time system is a system whose specification includes both
logical and temporal correctness requirements.
• Logical correctness (“the results are correct”)
- Requires functional analysis
• Temporal correctness (“the results are delivered in/on time”)
- Requires non-functional analysis
• High reactivity and high dependability are more important than
performance
• In these four lectures, we focus on techniques and technologies for
achieving and checking temporal correctness.
INTRODUCTION TO REAL-TIME SYSTEMS
• Examples for Real-Time Systems
- Chemical & Nuclear Power Plants
- Railway Switching Systems
- Flight Control Systems
- Space Mission Control
- Automotive Systems
- Healthcare Systems
- Robotics
- Telecommunications Systems
- Stock Market and Trading System
- Multimedia Systems
- Virtual Reality
. . .
Hard Real-Time Systems
Catastrophic results if some deadlines
are missed
Firm Real-Time Systems
The results are useless if the
deadlines are missed
Soft Real-Time Systems
The results are not very useful if the
deadlines are missed
FUNDAMENTALS
• Algorithm:
- It is the logical procedure to solve a certain problem
- It is informally specified a sequence of elementary steps that an “execution
machine” must follow to solve the problem
- It is not necessarily (and usually not) expressed in a formal programming language
• Program:
- It is the implementation of an algorithm in a programming language
- It can be executed several times with different inputs
• Process/job/task:
- An instance of a program that given a sequence of inputs produces a set of outputs
TIMING PARAMETERS OF A JOB JJ
• Arrival time (aj) or release time (rj) is the time at which the job becomes ready
for execution
• Computation (execution) time (Cj) is the time necessary to the processor for
executing the job without interruption.
• Absolute deadline (dj) is the time at which the job should be completed.
• Relative deadline (Dj) is the time length between the arrival time and the
absolute deadline.
• Start time (sj) is the time at which the job starts its execution.
• Finishing time (fj) is the time at which the job finishes its execution.
• Response time (Rj) is the time length at which the job finishes its execution
after its arrival, which is fj - aj.
SCHEDULES FOR A SET OF JOBS {J1, J2, . . . , JN}
• A schedule is an assignment of jobs to the processor, such that each
job is executed until completion.
• A schedule can be defined as an integer step function σ: R -> N,
where σ(t) = j denotes job Jj is executed at time t, and σ(t) = 0 denotes
the system is idle at time t.
• If σ(t) changes its value at some time t, then the processor performs a
context switch at time t.
• Non-preemptive scheduling: there is only one interval with σ(t) = j for
every Jj , where t is covered by the interval.
• Preemptive scheduling: there could be more than one interval with
σ(t) = j.
FEASIBILITY OF SCHEDULES AND SCHEDULABILITY
• A schedule is feasible if all jobs can be completed according to a set
of specified constraints.
• A set of jobs is schedulable if there exists a feasible schedule for the
set of jobs.
• A scheduling algorithm is optimal if it always produces a feasible
schedule when one exists (under any scheduling algorithm).
SCHEDULING ALGORITHMS
• Preemptive vs. Non-preemptive
• Guarantee-Based vs. Best-Effort
EVALUATING A SCHEDULE
• For a job Jj:
• Lateness Lj: delay of job completion with respect to its deadline.
Lj = fj - dj
• Tardiness Ej: the time that a job stays active after its deadline.
Ej = max{0, Lj}
• Laxity (or Slack Time)(Xj): The maximum time that a job can be
delayed and still meet its deadline.
Xj = dj - aj - Cj
METRICS OF SCHEDULING ALGORITHMS (FOR JOBS)
• Given a set J of n jobs, the common metrics are to minimize:
- Average response time:
- Makespan (total completion time):
- Total weighted response time:
- Maximum latency:
- Number of late jobs: where miss(Jj) = 0 if fj <= dj,
and miss(Jj) = 1 otherwise.
AN EXAMPLE: SHORTEST-JOB-FIRST (SJF)
• At any moment, the system executes the job with the shortest remaining
time among the jobs in the ready queue.
AN EXAMPLE: EARLIEST-DEADLINE-FIRST (EDF)
• At any moment, the system executes the job with the earliest absolute
deadline among the jobs in the ready queue.
RECURRENT TASK MODELS
• When jobs (usually with the same computation requirement) are released
recurrently, they can be modeled by a recurrent task
• Periodic Task ti:- A job is released exactly and periodically by a period Ti
- A phase φi indicates when the first job is released
- A relative deadline Di for each job from task ti- (φi, Ci , Ti, Di) is the specification of periodic task ti, where Ci is the worst-case
execution time.
• Sporadic Task ti:- Ti is the minimal time between any two consecutive job releases
- A relative deadline Di for each job from task ti- (Ci, Ti, Di) is the specification of sporadic task ti , where Ci is the worst-case
execution time.
• Aperiodic Task: Identical jobs released arbitrarily.
EVALUATING A SCHEDULE FOR TASKS
• For a job Jj:
- Lateness Lj: delay of job completion with respect to its deadline.
Lj = fj - dj
- Tardiness Ej: the time that a job stays active after its deadline.
Ej = max{0, Lj}
- Laxity (or Slack Time)(Xj): The maximum time that a job can be delayed
and still meet its deadline.
Xj = dj - aj – Cj
• For a task tj:
- Lateness Li: maximum lateness of jobs released by task ti- Tardiness Ei: maximum tardiness of jobs released by task ti- Laxity Xi: Di - Ci;
RELATIVE DEADLINE <=> PERIOD
• For a task set, we say that the task set is with
- implicit deadline when the relative deadline Di is equal to the period Ti , i.e., Di= Ti, for every task ti,
- constrained deadline when the relative deadline Di is no more than the period
Ti, i.e., Di <= Ti, for every task ti, or
- arbitrary deadline when the relative deadline Di could be larger than the
period Ti for some task ti.
FEASIBILITY AND SCHEDULABILITY FOR RECURRENT TASKS
• A schedule is feasible if all the jobs of all tasks can be completed
according to a set of specified constraints.
• A set of tasks is schedulable if there exists a feasible schedule for the
set of tasks.
• A scheduling algorithm is optimal if it always produces a feasible
schedule when one exists (under any scheduling algorithm).
SCHEDULABILITY ANALYSIS
• Schedulability for Static-Priority Scheduling
- Utilization-Based Analysis (Relative Deadline = Period)
- Demand-Based Analysis
• Schedulability for Dynamic-Priority Scheduling
RATE-MONOTONIC (RM) SCHEDULING
• Priority Definition: A task with a smaller period has higher priority, in
which ties are broken arbitrarily.
• Example Schedule: t1 = (1, 6, 6), t2 = (2, 8, 8), t3 = (4, 12, 12). [(Ci, Ti, Di)]
DEADLINE-MONOTONIC (DM) SCHEDULING
• Priority Definition: A task with a smaller relative deadline has higher
priority, in which ties are broken arbitrarily.
• Example Schedule: t1 = (2, 8, 4), t2 = (1, 6, 6), t3 = (4, 12, 12). [(Ci, Ti, Di )]
OPTIMALITY (OR NOT) OF RM AND DM
• Example Schedule: t1 = (2, 4, 4), t2 = (5, 10, 10)
• The above system is schedulable.
• No static-priority scheme is optimal for scheduling periodic tasks:
However, a deadline will be missed, regardless of how we choose to
(statically) prioritize t1 and t2.
• Corollary: Neither RM nor DM is optimal
OPTIMALITY AMONG STATIC-PRIORITY ALGORITHMS
• Theorem: A system of T independent, preemptable, synchronous
periodic tasks that have relative deadlines equal to their respective
periods can be feasibly scheduled on one processor according to the
RM algorithm whenever it can be feasibly scheduled according to any
static priority algorithm.
• Note: When Di <= Ti for all tasks, DM can be shown to be an optimal
static-priority algorithm using similar argument. Proof left as an exercise.
UTILIZATION-BASED SCHEDULABILITY TEST
• Task utilization:
• System (total) utilization:
• A task system T fully utilizes the processor under scheduling algorithm
A if any increase in execution time (of any task) causes A to miss a
deadline. In this case, U(T) is a upper bound on utilization for A,
denoted Uub(T, A).
• Ulub(A) is the least upper bound for algorithm A:
WHAT IS ULUB(A) FOR?
LIU AND LAYLAND BOUND
• Theorem: [Liu and Layland] A set of n independent, preemptable
periodic tasks with relative deadlines equal to their respective periods
can be scheduled on a processor according to the RM algorithm if its
total utilization U is at most n(21/n - 1). In other words, Ulub(RM, n) = n(21/n - 1) >= 0.693.
SCHEDULABILITY ANALYSIS
• Schedulability for Static-Priority Scheduling
- Utilization-Based Analysis (Relative Deadline = Period)
- Demand-Based Analysis
• Schedulability for Dynamic-Priority Scheduling
UTILIZATION-BASED TEST FOR EDF SCHEDULING
• Theorem: A task set T of independent, preemptable, periodic tasks
with relative deadlines equal to their periods can be feasibly
scheduled (under EDF) on one processor if and only if its total
utilization U is at most one.
RELATIVE DEADLINES LESS THAN PERIODS
• Theorem: A task set T of independent, preemptable, periodic tasks
with relative deadlines equal to or less than their periods can be
feasibly scheduled (under EDF) on one processor if:
• Note: This theorem only gives sufficient condition.
COMPARISON BETWEEN RM AND EDF (IMPLICIT DEADLINES)
RM• Low run-time overhead: O(1)
with priority sorting in advance
• Optimal for static-priority
• Schedulability test is NP-hard
(even if the relative deadline =
period)
• Least upper bound: 0.693
• In general, more preemption
EDF• High run-time overhead: O(log
n) with balanced binary tree
• Optimal for dynamic-priority
• Schedulability test is easy
(when the relative deadline =
period)
• Least upper bound: 1
• In general, less preemption
WirelessHART: Applying Wireless Technology in Real‐Time Industrial
Process Control
PropertiesReal‐Time
– TDMA Technology– Centralized Network Management
Reliability– Channel Hopping and Channel Blacklisting– Mesh Networking
Security– Data Integrity on MAC Layer– Data Confidentiality on the Network Layer
2
WirelessHART Architecture
3
Data Link Layer
4
• Time is sliced into time slots (10 ms)• Stringent timing requirements in a time slot• Clock synchronization is critical
Data Link Layer
5
Link scheduler determines the next slot to be serviced
Data Link Layer
6
When it is time to service the given time slot decided by the link scheduler, execute the associated transaction (SEND/RECV)
Data Link Layer
7
• Link represents the activity in a time slot: Neighbor, Transmit / Receive, Communication Channel
• Superframe: a group of links repeats itself infinitely
TDMA‐based Data Link Layer
8
10ms
• Link: activity in a time slot– Neighbor– Send/Receive– Communication channel
• Superframe: a group of links– Repeat itself infinitely– A device can support several superframes
TDMA‐based Data Link Layer
9
10ms
Send link
Receive link
Idle link
Link Scheduler
Priority queues for data link layer packets
Channel Hopping and Blacklisting
10
• Channel Hopping– Spread WirelessHART communication in all active physical
channels in 802.15.4 (up to 16 channels)– ActiveChannel = (ChannelOffset + ASN) % number of Active
Channels
• Channel Blacklisting– Restrict channel hopping to selected channels in the RF band.– protect a wireless service that uses a fixed portion of the RF
band.
MAC State Machine
11
Network and Transport Layer
12
A routing module to decide which neighbor the packet will be forwarded to.
Graph and Source Routing
13
• Graph Routing– A graph is a collection of paths that connect devices.– Network Manager creates and downloads them to devices. – Strict reliability requirements
• Source Routing– Aims at network diagnostics.– The path is explicitly included in the header
• Proxy Routing and Superframe Routing
Application Layer
14
• Three classes of Commands– Universal Commands– Common Practice Commands– Wireless Commands
Commend‐oriented: communications between peers are represented as command requests and responses.
Application Layer
15
Reliable Graph Routing
• Reliable Broadcast Graph (GB)– GB is a graph connecting Gateway (GW) downward to all DEVs– Broadcasts common configuration and control messages– Each DEV has at least two parents in GB
16
Reliable Graph Routing (Cont.)• Reliable Uplink Graph (GU)
– GU is a graph connecting all DEVs upward to the Gateway– DEVs propagate periodic process data– Each DEV has at least two children in GU
– Both GB and GU have no fewer than 2 Access Points
17
Reliable Graph Routing (Cont.)• Reliable Downlink Graph (Gv)
– The graph from the Gateway to DEV v– Transmit unicast messages from the GW and NM to v– Each intermediate DEV has at least two children in Gv
– There exists at least one directed cycle in Gv
18
To avoid infinite forwarding loop:1) Only one cycle of length 2 in Gv2) Each DEV on the cycle has direct edges to v
Construct Gv
19
• More complicated than GB and GU:– Only involves part of the nodes in G– The existence of cycle– Restrictions: One cycle (length 2) between the parents of
destination node v
• Standard Reliable Downlink Graph– Construct a completely new graph from GW to DEV v– Configuration in intermediate nodes cannot be reused– High configuration cost and poor scalability
Sequential Reliable Downlink Routing (SRDR)
• Key Principles– Each node only keep a small local graph– Local graphs are reusable building blocks for constructing reliable downlink graph for multiple destinations
20
Low configuration cost
High Scalability
High Reliability
Sequential Reliable Downlink Routing (SRDR) Extensions
• Network layer header extension:
21
SRDR Extensions
• Routing module extension:
– retrieve the earliest graph ID in the graph list and route the packet on this graph
– If current node is the sink of the graph, remove this graph ID and route the packet on the next earliest graph.
– If routing is failed, remove this graph ID and try the next earliest graph ID if it has the corresponding edges.
22
Optimization on SRDR
23
• In SRDR, routing is performed strictly according to the sequence in the ordered graph list.
• SRDR‐OPT– Observation: each node can keep graph info to multiple destination.
– Have chance to take the “shortcut”– Principle: Search the ordered graph list backward and route the packet on the first graph ID that is stored in its table
WirelessHART Prototype System
24
Major Components in the prototype :
• Network Manager• Gateway• Host Application• Access Point• Device• Sniffer
PC Side
Embedded Side
System Design, Implementation and Deployment
25
Design of the Network Manager
26
Functionalities in Network Manager
27
• Location Manager
• Security Manager and Access Control
• Maintaining Reliable Routing Graphs
• Maintaining Communication Schedule
• Friendly GUI
Design of the Gateway
28
Functionalities in Gateway
29
• Processing Queries from Host Applications
• Data Caching for devices
• Multiple Access Points support
• Communication between GW and NM, AP and Host Applications
• Control in the Gateway
Design of the Access Point
30
Forward messages destinated to NM and GW to the Gateway