570 likes | 662 Views
application. application. presentation. presentation. session. session. transport. transport. IP. network. network. network. data link. data link. data link. physical. physical. physical. Big Picture: Lab 3. Networks Csaba Andras Moritz. Readings. Textbook Chapter 8.
E N D
application application presentation presentation session session transport transport IP network network network data link data link data link physical physical physical Big Picture: Lab 3 Networks Csaba Andras Moritz
Readings • Textbook Chapter 8
Outline - Networking for Embedded Systems • Why we use networks. • Network abstractions. • Embedded Networks and TCP/IP. • Example networks. • Networks programming with sockets.
Technical background • Moore: number of transistors/mm2 doubles every 18 months • processing power and memory capacity become abundant • Metcalfe: the “value” of a network is proportional to the square of the number of nodes • adding a node benefits existing nodes • the larger the network the larger the benefit • Gilder: Internet bandwidth triples every 18 months
Embedded Systems evolution • Hardware replaces software • functionality • features • Digitization and manipulation of signals • Configuration/programming of systems from outside • Completely networked systems increase in networking
Network aware: Information retrieval • from the system in a rudimentary fashion • Status information: errors, wear, use • Using existing connections and resources already available within the system • Off-line analysis of data • Transport: telephone, Internet • Advantage: • remote diagnosis • Network central: Adapt product design with • respect to the network connection • Integrate network functions with embedded hardware and software • Standardisation of connections, protocols • Advantage: • service: access to embedded software: debugging, replacement, sell features • owner: standardisation, new software • Network connected: On-line connection with • the system • Put control hardware/software next to the embedded system • Interaction! • http://aquarium.eesi.tue.nl • Advantage: • service: diagnostics, leasing of appliances • owner: remote monitor & control, security, production-control, fleet maintenance • Fully networked: the functionality is defined • by the network • Devices controlling each other • Intelligent environments, all equipment in the background (Philips: “ambient intelligence”) • Advantage: http://www.research.philips.com/generalinfo/special/ambintel/index.html • service: new markets • owner: ease of use, comfort, integration • Standalone: embedded • hardware and software: • invisible • are, in fact, an implementation aspect of the product network central network central network aware network aware time standalone standalone network connected network connected fully networked fully networked Evolution of embedded networking
initial processing more processing Networks in embedded systems PE sensor PE PE actuator
Networking for Embedded Systems • Why we use networks. • Network abstractions. • Embedded Networks and TCP/IP. • Example networks. • Networks programming with sockets
Network abstractions • International Standards Organization (ISO) developed the Open Systems Interconnection (OSI) model to describe networks: • 7-layer model. • Provides a standard way to classify network components and operations.
application end-user interface presentation data format session application dialog control transport connections network end-to-end service data link reliable data transport physical mechanical, electrical OSI model
Hardware architectures • Many different types of networks: • topology; • scheduling of communication; • routing.
Point-to-point networks • One source, one or more destinations, no data switching (serial port): PE 3 PE 1 PE 2 link 1 link 2
header address data ECC packet format Bus networks • Common physical connection: PE 1 PE 2 PE 3 PE 4
Bus arbitration • Fixed: Same order of resolution every time. • Fair: every PE has same access over long periods. • round-robin: rotate top priority among PEs. A B C A B C fixed round-robin A B C B C A A,B,C A,B,C
Ethernet • Dominant non-telephone LAN. • Versions: 10 Mb/s, 100 Mb/s, 1 Gb/s, 10Gb/s. • Goal: reliable communication over an unreliable medium.
Ethernet topology • Bus-based system, several possible physical layers: A B C
Ethernet packet format preamble start frame source adrs dest adrs length data payload padding CRC
Ethernet performance • Carrier sense multiple access with collision detection (CSMA-CD) • sense collisions; • exponentially back off in time; • retransmit. • Quality-of-service tends to non-linearly decrease at high load levels. • Can’t guarantee real-time deadlines. However, may provide very good service at proper load levels.
Networking for Embedded Systems • Why we use networks. • Network abstractions. • Embedded Networks and TCP/IP. • Example networks. • Networks programming with sockets
Internet Protocol • Internet Protocol (IP) is basis for Internet. • Provides an internetworking standard: between two Ethernets, Ethernet and token ring, etc. • Higher-level services are built on top of IP.
IP in communication application application presentation presentation session session IP transport transport network network network data link data link data link physical physical physical router node A node B
OSI Model Layers TCP/IP Layers TCP/IP Protocol Suite Application Layer Presentation Layer Application Layer Telnet FTP SMTP DNS POP3 SNMP Session Layer Transport Layer TCP UDP Transport Layer Network Layer Internet Layer IP Data Link Layer Link Layer 802.2 LLC PPP SLIP Physical Layer Physical Layer Ethernet Serial Port Another look at TCP/IP for Embedded Devices
TCP/IP Basics : Data Encapsulation Application Data App Header Application Data TCP Header App Header Application Data IP Header TCP Header App Header Application Data Ethernet Header IP Header TCP Header App Header Application Data Ethernet Trailer
IP addresses • 32 bits in early IP, 128 bits in IPv6. • Typically written in form xxx.xxx.xxx.xxx. • Each group ranges from 0 to 255 • Names (foo.baz.com) translated to IP address by domain name server (DNS).
Networking for Embedded Systems • Why we use networks. • Network abstractions. • Embedded Networks and TCP/IP. • Example networks. • Networks programming with sockets
Request connection Program code Embedded protocols and software Remote user sensors UDP actuators Applet ES-Server HTTP (applet code) HTTP server HTML browser
Components • HTTP server: • standardized access: URL • code download: Java applet • ES server: provide “driver interface” for embedded system • HTTP browser (client): • setup contact • run machine-independent code • “programmable interactive remote control” • Applet: • interface to user
Networking for Embedded Systems • Why we use networks. • Network abstractions. • Embedded Networks and TCP/IP. • Example networks. • Networks programming with sockets
Networked systems programming • Distributed systems programming is needed in many of today’s applications • Web servers, web caches, client-server applications, network devices, … • From low level to services • Sockets (low-level API) • RPC, RMI (higher-level API) • CORBA (also adds services, component model) LATER! • EJB, J2EE, (Java version); .net (Microsoft) • Jini (Java’s answer to networked services and devices)
Sockets • Low-level communication interface (API) • Network Programming • Defined 1981Bolt, Beranek and Newman (BBN) • Originally developed for the C language • TCP/IP version with Unix called BSD sockets • To some extent similar to file IO
Sockets • What is a socket? • It is a peer-to-peer communication “endpoint” abstraction • Hides details of network for programming communication situations • Interfaces to some common network protocols (e.g. TCP, UDP, XNS, NetBIOS, IP, etc.) • Many high level APIs are based on sockets • 1985 Sun introduced RPC and NFS (Network File System) over sockets.
Socket Ports • On TCP/IP networks: • Socket = Internet Address(IP) + Port Address • Port is an “entry point” to an application that resides on a host.
Socket Ports cont. • Typically a communication is assigned to a port, a process can request/assign to access a port-number. • TCP and UDP protocols (most common TCP/IP transport protocols) use port numbers 1-1023 that are reserved. • Standard Internet apps (FTP, TELNET, TFTP, SMTP, SNMP,..) use ports between 1-255. • > 1023 can be used for new user-level servers
Socket types • Three types: • Stream (e.g. interface to TCP), • session based reliable service that takes care of connection maintenance, packet reassembly, etc. • Mimics UNIX file system semantics • Datagram (e.g. interface to UDP, NetBIOS), • handles independent packets. • Unreliable; 5% of datagrams don’t make it. • Needs higher level acknowledgement service. • Raw (e.g. interface to IP, etc.), • Programming interface to lower-level protocols
Sockets • To initiate a connection one must fix the roles: client or server • A network connection can be connection-oriented or connectionless • With a connectionless protocol there is nothing like an “Open” communication; every network IO operation can be with different process/host • In a connection based operation a peer-to-peer channel is opened
Connection-oriented use • Connection is first established between client and server • System Calls at server side • socket() // creates endpoint, specify protocol (TCP, UDP, XNS, etc.), specify type (i.e. stream, datagram, etc.) Returns a small integer similar to file descriptor. • bind() // register and bound network address to socket • listen() // signal willingness to receive connections • accept() // accept a connection • read(), write() // transfer data
Connection-oriented protocol • Client side • socket() // same meaning as in server • connect() //establish contact between local-remote site • read() write() //transfer data
Example, connection-oriented sequence socket() bind() SERVER CLIENT listen() accept() socket() Blocks Until connect Connection establishment connect() Data(request) write() read() Data (reply) write() read()
System calls connectionless case • sendto(addr,) // send datagrams (data packets) • recvfrom(addr,..) // receive datagrams • Compared to the connection-oriented read() and write()these calls have arguments for remote protocol-specific addresses.
Example 2, connectionless sequence of calls socket() bind() SERVER CLIENT recvfrom(addr1,…) socket() Blocks Until data received from client bind() Data(request) sendto(addr1,…) Data (reply) sendto(addr2,…) recvfrom(addr2,…)
Summary Sockets • Abstraction for network programming. • Advantage: • Best performance in distributed embedded applications, fine-tuning opportunities. • Many known high-level protocols use sockets as underlying communication mechanisms. • Disadvantages: • lots of details to address, many parameters to control. • Requires understanding of system issues and network protocols.
What's next ? • Lab 3 details by TA
Internet-enabled embedded system • Internet-enabled embedded system: any embedded system that includes an Internet interface (e.g., burglar alarm system). • Internet appliance: embedded system designed for a particular Internet task (e.g. email). • UMASS ECE SDP Internet-connect Refrigerator • Laser printer. • Personal digital assistant (PDA). • Home automation system.
network central network central network aware network aware time standalone standalone network connected network connected fully networked fully networked The effect of Internet • ..... + information exchange!! • Data transport (large distance) • Standards: ftp, email, ... • Distributed access • Interoperability • Standards for offering services: Jini, UPnP, OSGi • Platform for • data exchange • integration • Standards for • software architectures • communication: HTTP, Java, TCP, UDP, .... • visualisation: browsers • Global addressing
Request connection Program code Example: A coffee maker Switch and heat control not networked individually Remote user
Example: Javacam • Hardware platform: • parallel-port camera; • National Semi NS486SXF; • 1.5 Mbytes memory. • Uses memory-efficient Java Nanokernel.
Javacam architecture Web browser QuickCam applet HTTP Quickcam server QuickCam Java VM Java nanokernel 486
Fully networked devices • Separate user interface and driver functions • It must be simple to attach to the network • lightweight • easy to handle • Zero configuration connection • builds a logical network automatically • peer to peer in absence of server • Zero configuration interoperable • service publication and discovery • devices control each other • no fixed identification
Differences connectionless vs. connection-oriented • Connection establishing not required • Blocks until data is received as opposed until connection is established • Note: Client could also use connect() and read() write() in the connectionless case, but not “real connect” as it returns immediately, i.e. does not block as there is no connection established. • Use of the sendto() and recvfrom() as opposed to the read() and write() system calls • The client registers an address for itself with the bind() to be able to receive messages back (this address is sent with data automatically)