Ch 7. Network Interface

Similar documents
Chapter 2 - Part 1. The TCP/IP Protocol: The Language of the Internet

ECE4110 Internetwork Programming. Introduction and Overview

A Client-Server Exchange

Context. Distributed Systems: Sockets Programming. Alberto Bosio, Associate Professor UM Microelectronic Departement

CS 416: Operating Systems Design April 11, 2011

Concept Questions Demonstrate your knowledge of these concepts by answering the following questions in the space that is provided.

Significance of TCP/IP Model Divya Shree Assistant Professor (Resource Person), Department of computer science and engineering, UIET, MDU, Rohtak

The Internet Protocol (IP)

UNIT 1 TCP/IP PROGRAMMING CONCEPTS

ROYAL INSTITUTE OF INFORMATION & MANAGEMENT

Distributed Systems. 02. Networking. Paul Krzyzanowski. Rutgers University. Fall 2017

5105: BHARATHIDASAN ENGINEERING COLLEGE NATTARMPALLI UNIT I FUNDAMENTALS AND LINK LAYER PART A

Lecture 17 Overview. Last Lecture. Wide Area Networking (2) This Lecture. Internet Protocol (1) Source: chapters 2.2, 2.3,18.4, 19.1, 9.

Socket Programming. Dr. -Ing. Abdalkarim Awad. Informatik 7 Rechnernetze und Kommunikationssysteme

CS61C Machine Structures Lecture 37 Networks. No Machine is an Island!

Socket Programming. CSIS0234A Computer and Communication Networks. Socket Programming in C

Internetwork Protocols

Defining Networks with the OSI Model. Module 2

Ports under 1024 are often considered special, and usually require special OS privileges to use.

Introduction to Internetworking

OSI Reference Model. Computer Networks lab ECOM Prepared By : Eng. Motaz Murtaja Eng. Ola Abd Elatief

Lecture 11: Networks & Networking

Types (Protocols) Associated functions Styles We will look at using sockets in C Java sockets are conceptually quite similar

CompSci 356: Computer Network Architectures. Lecture 8: Spanning Tree Algorithm and Basic Internetworking Ch & 3.2. Xiaowei Yang

Review of Important Networking Concepts

PART X. Internetworking Part 1. (Concept, IP Addressing, IP Routing, IP Datagrams, Address Resolution)

Layering in Networked computing. OSI Model TCP/IP Model Protocols at each layer

EE 610 Part 2: Encapsulation and network utilities

Copyleft 2005, Binnur Kurt. Objectives

Agenda. Before we start: Assignment #1. Routing in a wide area network. Protocols more concepts. Internetworking. Congestion control

Link Layer and Ethernet

Interconnecting Networks with TCP/IP

Internet. Organization Addresses TCP/IP Protocol stack Forwarding. 1. Use of a globally unique address space based on Internet Addresses

TCP/IP Networking. Training Details. About Training. About Training. What You'll Learn. Training Time : 9 Hours. Capacity : 12

OSI and TCP/IP Models

TCP/IP Overview. Basic Networking Concepts. 09/14/11 Basic TCP/IP Networking 1

ET4254 Communications and Networking 1

Position of IP and other network-layer protocols in TCP/IP protocol suite

Link Layer and Ethernet

Network Model. Why a Layered Model? All People Seem To Need Data Processing

OSI Network Layer. Network Fundamentals Chapter 5. Version Cisco Systems, Inc. All rights reserved. Cisco Public 1

1: Review Of Semester Provide an overview of encapsulation.

TERM EXAMS CS610- COMPUTER NETWORKS

CS 43: Computer Networks Switches and LANs. Kevin Webb Swarthmore College December 5, 2017

CHAPTER-2 IP CONCEPTS

Chapter 5 Network Layer

IP Protocols. ALTTC/Oct

Session NM056. Programming TCP/IP with Sockets. Geoff Bryant Process software

SOCKET PROGRAMMING. What is a socket? Using sockets Types (Protocols) Associated functions Styles

Data Communication Prof. A. Pal Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture 34 TCP/ IP I

VU Mobile Powered by S NO Group All Rights Reserved S NO Group 2012

TCP /IP Fundamentals Mr. Cantu

Summary of MAC protocols

OSI Model. Teran Subasinghe MBCS, Bsc.(Hons) in Computer Science - University of Greenwich, UK

Guide to Networking Essentials, 6 th Edition. Chapter 5: Network Protocols

What is a Network? TCP / IP. The ISO OSI Model. Protocols. The TCP/IP Protocol Suite. The TCP/IP Protocol Suite. Computer network.

Introduction... xiii Chapter 1: Introduction to Computer Networks and Internet Computer Networks Uses of Computer Networks...

Ch.7 Internet Protocol: Connectionless Datagram Delivery (IPv4, IPv6)

Computer Networks Medium Access Control. Mostafa Salehi Fall 2008

cs144 Midterm Review Fall 2010

Oral. Total. Dated Sign (2) (5) (3) (2)

CLIENT-SIDE PROGRAMMING

TCP/IP THE TCP/IP ARCHITECTURE

The Internetworking Problem. Internetworking. A Translation-based Solution

Chapter 9 Ethernet Part 1

Communicating over the Network

The TCP Protocol Stack

Networking Fundamentals

Chapter 7. Local Area Network Communications Protocols

Layer 4: UDP, TCP, and others. based on Chapter 9 of CompTIA Network+ Exam Guide, 4th ed., Mike Meyers

CSCI Networking Name:

Tutorial on Socket Programming

CS610 Computer Network Final Term Papers Solved MCQs with reference by Virtualians Social Network

Communication Networks

Need For Protocol Architecture

Unix Network Programming

Interconnecting Networks with TCP/IP. 2000, Cisco Systems, Inc. 8-1

IP : Internet Protocol

Data & Computer Communication

Need For Protocol Architecture

Hybrid of client-server and P2P. Pure P2P Architecture. App-layer Protocols. Communicating Processes. Transport Service Requirements

( A ) 1. WAP is a (A) protocol (B) hardware (C) software (D) network architecture

CHAPTER 2 SINGLE SEGMENT NETWORKS

EITF25 Internet Techniques and Applications L7: Internet. Stefan Höst

Part3. Local Area Networks (LAN)

Solved MCQ of Computer networking. Set-1

TCP/IP Networking. Part 4: Network and Transport Layer Protocols

IP - The Internet Protocol. Based on the slides of Dr. Jorg Liebeherr, University of Virginia

ELC 537 Communication Networks

Chapter 2 Network Models 2.1

Medium Access Protocols

Introduction to TCP/IP networking

Interprocess Communication Mechanisms

shared storage These mechanisms have already been covered. examples: shared virtual memory message based signals

THE OSI MODEL. Application Presentation Session Transport Network Data-Link Physical. OSI Model. Chapter 1 Review.

ARP, IP. Chong-Kwon Kim. Each station (or network interface) should be uniquely identified Use 6 byte long address

CC231 Introduction to Networks Dr. Ayman A. Abdel-Hamid. Internet Protocol Suite

Network Architecture Models

Raj Jain. The Ohio State University Columbus, OH

TSIN02 - Internetworking

Transcription:

EE414 Embedded Systems Ch 7. Network Interface Part 2/2 Byung Kook Kim School of Electrical Engineering Korea Advanced Institute of Science and Technology

Overview 7.1 Advanced Communication Principles 7.2 Parallel Protocols 7.3 Wireless Protocols 7.4 Serial Protocols 7.5 Controller Area Network 7.6 CAN Protocol 7.7 Ethernet Hardware 7.8 Ethernet Protocol 7.9 Socket Programming Embedded Systems, KAIST 2

7.7 Ethernet Hardware Ethernet Developed at Xerox PARC in 70s Local area networking (LAN) standard Wireless networks (802.11) to gigabit Ethernet Capabilities of Ethernet Gain access to a network Send data to a host computer Access printers, file servers, databases, and Internet Monitor and control embedded system Weather station: Sensor, ADC, AT90S8515 AVR, and Ethernet interface Gateway, firewall, bridge, switch, etc. Embedded Systems, KAIST 3

Ethernet (II) Adding an Ethernet interface CS8900A Single-chip 10 Mbps Ethernet controller by Cirrus Logic (http://www.cirrus.com), formerly Crystal Semiconductor. Supports 10BASE-2, 10-BASET, and AUI (Attachment Unit Interface) Ethernet ports. Pin Signal name Purpose [Gbps extension] 1 TD+ Transmitted data TX+-D1 2 TD- Transmitted data TX-_D1 3 RD+ Received data RX+_D2 Wire color White/or ange Orange White green 4 NC BI+_D3 Blue RJ-45 connector Uses UTP (Unshielded Twisted Pair) category 5 cable (CAT5) Four wires are used: Tx pair, Rx pair. Pinouts 5 NC BI-_D3 White/ blue 6 RD- Received data RX-_D2 Green 7 NC BI+-D4 White/br own 8 NC BI-_D4 Brown Embedded Systems, KAIST 4

Ethernet (III) Block diagram of a CS9800A implementation Embedded Systems, KAIST 5

Ethernet (V) 10-BaseT interface with clock wiring Embedded Systems, KAIST 6

Ethernet (VI) Host interface of CS8900 Supports 16-bit ISA bus architecture Easily adapted to work with non-isa processors Set SHBEb high Also supports 8-bit data bus Tie SHBEb to ground Little-endian operation Big-endian processors (Motorola, DSP56805) Byte-swap in software Byte-swap in hardware Embedded Systems, KAIST 7

Ethernet (VII) Host interface of CS8900 (Cont d) 20 address inputs ISA-bus device Supports separate memory and I/O address spaces CHIPSELb low: memory-mapped device Controlled by MEMRb and MEMWb CHIPSELb high: I/O space device Expected to do their own address decoding Default to I/O address 0x00300 Controlled by IORb and IOWb Address remapping in hardware CPU address 0x8300 to I/O address 0x0300 Embedded Systems, KAIST 8

Ethernet (VIII) Serial EEPROM Used to store CS8900A configuration information and Physical Ethernet address Optional: The host processor can store this data elsewhere in the system. Standard SPI interface Unused pins Should be tied inactive (tied to Vcc/ground) Embedded Systems, KAIST 9

7.8 Ethernet Protocol Goal of Ethernet Reliable communication over an unreliable medium. Ethernet technology Wire: thick coaxial, thin coaxial, twisted pair, optical fiber. Connector: BNC for thinnet, AUI connector for thicknet, RJ45 for 10Base-T. [Wikipedia] Ethernet Properties: Broadcast bus technology: all tranceivers receive every transmission. Best effort delivery: message may be lost. Distributed access control: Carrier Sense Multiple Access with Collision Detect (CSMA/CD). Collision: binary exponential back-off policy. Embedded Systems, KAIST 10

A. Physical Layer of Ethernet CSMA/CD (Carrier Sense Multiple Access with Collision Detection): sense collisions; exponentially back off in time; retransmit. Ethernet performance 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. Embedded Systems, KAIST 11

B. Data Link Layer of Ethernet Ethernet Frames (Packets) Format Variable length: min 64 octets (bytes), max 1518 octets, excluding preamble. Destination Source Frame [Preamble] Address Address Type Frame Data CRC 8 octets 6 octets 6 octets 2 46-1500 octets 4 Frame Type: 0x806 ARP/RARP 0x800 IP Or Data length 0x0 0x600 Embedded Systems, KAIST 12

C. Network Layer of Ethernet 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. application presentation session transport network data link physical IP network data link physical application presentation session transport network data link physical node A router node B Embedded Systems, KAIST 13

IP Packet IP packet includes: version, service type, length time to live, protocol source and destination address data payload (65,535 bytes max.) IP routing Best effort routing: doesn t guarantee data delivery at IP layer. Routing can vary: session to session; packet to packet. Embedded Systems, KAIST 14

IP Address IP (Internet Protocol) v4 address A connection to a network. Not a host. 32 bit for IPv4. 128 bit for IPv6. Dotted decimal notation: 143.248.150.1 Names (foo.baz.com) translated to IP address by domain name server (DNS). Embedded Systems, KAIST 15

Ethernet Address Resolution Address Resolution Protocol (ARP) Allow a host to find the physical address of a target host, given only the target s IP address. Hardware type: 1 for Ethernet. Protocol type: 0x0800 HLEN 6 (Hardware Address Length); PLEN 4 Protocol Address Length) Operation: 1 ARP request, 2 ARP reply, 3 RARP request, 4 RARP reply. Sender supplies Sender Hardware Address, Sender IP, and Target IP. ARP/RARP message format: Embedded Systems, KAIST 16

IP Datagram IP (Internet Protocol) Datagram Format VERS: 4 (IPv4). HLEN: Header length in 32-bit words (min 5). Type of Service: Precedence (3 bits: 0 to 7), D (low delay), T (high throughput), R( high reliability), 2 unused bits. TOTAL LENGTH: Length of IP datagram in bytes (65536 max). Embedded Systems, KAIST 17

IP Datagram (II) IP Datagram Format (Cont d) Identification: Identification number FLAGS: Bit 1: Do not fragment Bit3: More fragments Fragment Offset: Offset for fragmented data. Protocol: Specifies high-level protocol. 0 RAW, 1 ICMP, 2 IGMP, 6 TCP, 8 EGP, 11 UDP, 59 OSPF. Time-to-Live: How long the datagram is allowed to remain (in seconds). Discard the datagram if the TTL field becomes zero. Header Checksum: Checksum of header (not data) as 16-bit integers. Adding using 1 s complement arithmetic. One s complement of the sum. Embedded Systems, KAIST 18

D. Transport Layer of Ethernet Higher-level Internet services Transmission Control Protocol (TCP) provides connection-oriented service. User Datagram Protocol (UDP): connectionless delivery Quality-of-service (QoS) guaranteed services are under development. FTP HTTP SMTP telnet SNMP DNS TCP UDP IP Embedded Systems, KAIST 19

Transport Layer (II) UDP (User Datagram Protocol) Format Provide an unreliable connectionless delivery service. Uses IP to carry messages, but adds the ability to distinguish among multiple destinations within a given computer. 4 16-bit fields. Source Port: 16-bit UDP protocol source port number. Destination Port: 16-bit UDP protocol destination port number. UDP Message Length: Count of octets in the UDP datagram including header and data. UDP checksum: Optional (0: checksum not computed). Only way to guarantee that data has arrived (No IP data checksum). Embedded Systems, KAIST 20

Transport Layer (III) TCP (Transmission Control Protocol) Format Provide stream oriented, connection oriented, buffered data transfer with acknowledge, time-out, and retransmission. Embedded Systems, KAIST 21

Transport Layer (IV) TCP Finite State Machine Embedded Systems, KAIST 22

E. Ethernet Protocol Hierarchy Embedded Systems, KAIST 23

Ethernet (II) Data Encapsulation TCP Header >=20B UDP Header 8B TCP Data Area UDP Data Area IP Header >=20B IP Data Area Frame Header 22B Frame Data Area 48-1500B. ARP etc. CRC 4B Embedded Systems, KAIST 24

Ethernet (III) ISO 7-Layer Reference Model Layer ISO-7 TCP/IP 7 Application Application 6 Presentation Message or streams 5 Session 4 Transport Transport 3 Network Internet 2 Data Link Network Interface 1 Physical Hardware Connection Hardware Transport Protocol Packets IP Datagrams Network-Specific Frames Embedded Systems, KAIST 25

7.9 Socket Programming What is a socket? A way to speak to other programs using standard Unix file descriptors. A file descriptor is simply an integer associated with an open file. But that file can be a network connection, a FIFO, a pipe, a terminal, a real on-the-disk file, or just about anything else. Make a call to the socket() system routine. Returns the socket descriptor, and you communicate through it using the specialized send() and recv() socket calls. You can use normal read() and write(), but send() and recv() offer much greater control over your data transmission. Embedded Systems, KAIST 26

Socket Programming (II) Two types of internet sockets Stream sockets Reliable two-way connected communication streams. Ordered Error-free telnet uses stream sockets. All the characters you type need to arrive in the same order you type them, Web browsers use the HTTP protocol which uses stream sockets to get pages. Use a protocol called "TCP" (see RFC-793 for extremely detailed info on TCP.) TCP makes sure your data arrives sequentially and error-free. Embedded Systems, KAIST 27

Socket Progrmming (III) Two types of internet sockets (Cont d) Datagram sockets Connectionless if you send a datagram, it may arrive. It may arrive out of order. If it arrives, the data within the packet will be error-free. Use the "UDP" (see RFC-768.) You don't have to maintain an open connection as you do with stream sockets. You just build a packet, slap an IP header on it with destination information, and send it out. No connection needed. They are generally used for packet-by-packet transfers of information. Sample applications: tftp, bootp, etc. Embedded Systems, KAIST 28

Socket Programming (IV) Structs 1. a socket descriptor. int (Just a regular int). 2. Struct sockaddr. Holds socket address information for many types of sockets: struct sockaddr { unsigned short sa_family; // address family, AF_xxx char sa_data[14]; // 14 bytes of protocol address }; sa_family can be a variety of things, but it'll be AF_INET. sa_data contains a destination address and port number for the socket. 3. A parallel structure: struct sockaddr_in ("in" for "Internet".) struct sockaddr_in { short int sin_family; // Address family unsigned short int sin_port; // Port number struct in_addr sin_addr; // Internet address unsigned char sin_zero[8]; // Same size as struct sockaddr }; This structure makes it easy to reference elements of the socket address. 4. Internet address (a structure for historical reasons) struct in_addr { unsigned long s_addr; // that's a 32-bit long, or 4 bytes }; Embedded Systems, KAIST 29

Socket Programming (V) System Calls socket()--get the File Descriptor! bind()--what port am I on? connect()--hey, you! listen()--will somebody please call me? accept()--"thank you for calling port 3490." send() and recv()--talk to me, baby! sendto() and recvfrom()--talk to me, DGRAM-style close() and shutdown()--get outta my face! getpeername()--who are you? gethostname()--who am I? Embedded Systems, KAIST 30

Socket Programming (VI) A simple stream server Open stream socket Set socket option Bind socket_id to socket structure Listen Loop Accept incoming connection request Child process: Send a message to the socket A simple stream client Get the host information Open stream socket Connect to the server Receive a message from the socket Print it Close the socket Embedded Systems, KAIST 31

References Ethernet Protocol & Socket programming Douglas Comer, Internetworking with TCP/IP. Volume 1: Principles, Protocols, and Architecture, Third Ed., Prentice Hall, 1995. Search Internet. Embedded Systems, KAIST 32