IoT 시대, Network 어디까지해봤니? 2015.12. 3 김우열 Blog : http://midnightcow.tistory.com
WIZnet Social Family Site http://wiznetmuseum.com http://wiznetian.com http://wiznetacademy.com http://wizwiki.net http://wizwiki.net/forum
3 / 8 목차 Network 개념따라잡기 - Network 통신 - Ethernet 통신 - TCP/IP 통신 - Socket 통신 WIZnet Chips - Features - Diagram - Socket Status vs Socket API(Command) Packet Sniffing - WireShark
Network 개념따라잡기 Network 통신 -Network 란? - 통신의기본조건 -Network 의발달 -Packet Switched -Network 의구성 (Topology) -OSI 7 Layer -Protocol -Interworking Device
Network 통신 - Network 란? Net + Work => 그물망처럼얽혀서공유하고협업한다 소리로시작하여각종정보까지 Computer Networking : Internet, Web IoT(M2M, IoE, IoW) : Internet Of Thing(Everything,Web), Machine2Machine
Network 통신 기본조건 송신부 : 입 수신부 : 귀 전달매체 (Media) Language (Air) 수신부 : 귀 송신부 : 입 The same Physical Hardware & Address & Protocol
Network 통신 Network 발달 Circuit Switched - PSTN Packet Switched TDMA,CSMA/CD, Token 1 : 1 => 자원독점 1 : N => 자원공유, 충돌회피
Network 통신 Packet Switched - TDMA : Time Division Multiple Access 시분할다중화 - CSMA/CD : Carries Sense Multiple Access/Collision Detect - Token
Network 통신 - Topology
Network 통신 OSI 7 layer(1)
Network 통신 OSI 7 layer(2)
Network 통신 Protocol 언제무엇을어떻게통신할것인가에대한규약, 쌍방간의약속
Network 통신 Interworking Device(1)
Network 통신 Interworking Device(2) Hub Switch
Network 통신 tracert
Network 개념따라잡기 Ethernet 통신 -Ethernet이란? -UTP & MDI, MDIX -Ethernet PHY (MDI to MII) -Ethernet Frame -MAC address
Ethernet 통신 Ethernet 이란? Ether + Network = Ethernet 1972 년제록스에의해개발 Ether ( 에테르 ) : 빛이나전기가전달될수있는가상의매체, 빛처럼빠르다 (2.9Mbsp)? 해서 Ethernet 으로명명 1980 년제록스, DEC, Intel 에의해표준화진행 이후 IEEE 802.3 표준화 LAN 상에서의 CSMA/CD Packet Switched 방식의통신
Ethernet 통신 UTP & MDI,MDIX Un-shield Twisted Pair Media Depend Interface Media Depend Interface Cross(X) Shield Twisted Pair LAN : 길이 100m 까지 Auto MDI-X
Ethernet 통신 Ethernet PHY TX+ PHY TXEN TXC TXD[3:0] TXEN TXC TXD[3:0] MAC UTP XFRM RX+ TX- RX- RXDV RXC RXD[3:0] CRS RXDV RXC RXD[3:0] CRS Any I/F HOST COL COL MII Media Independent Interface
Ethernet 통신 Ethernet Frame Ether Type => 0x0800 : IPv4 0x0806 : ARP 0x86DD : IPv6
Ethernet 통신 MAC address - Media Access Control, EUI-48-48bit (6bytes) 의 Network Interface 의고유한 ID(Physical Address) - IEEE 에서할당 - ARP : Address Resolution Protocol (IP -> MAC) - RARP : Reverse ARP (MAC -> IP) - Broadcast : FF:FF:FF:FF:FF:FF - Multicast : 01:00:5E: 0 +(IP address 하위 20 비트 ) 00 08 DC http://standards-oui.ieee.org/oui.txt
Ethernet 통신 ARP 00 08 DC
Network 개념따라잡기 TCP/IP 통신 -TCP/P 4 Layer -IP -IP address -Domain name -TCP -UDP -TCP vs UDP
TCP/IP 통신 4 Layer
TCP/IP 통신 IP (Internet Protocol) - Internet 접속을위한 Protocol - 비연결성 (Datagram) 통신을지원 No 오류검출, 비신뢰성 - ICMP, IGMP
TCP/IP 통신 IP Address(1) IANA 에서할당및관리
TCP/IP 통신 IP Address(2) 주소체계 : Classful Addressing, Network ID + Host ID cf> CIDR Classless Inter Domain Routing 203.255.208.222/23 Prefix : 13 ~ 27 Host 수 : 32 ~ 50000 - Reserved IP Address 0.0.0.0 : Not allocated 255.255.255.255 : Broadcasting 169.254.0.0 : Zero config Etc : https://ko.wikipedia.org/wiki/ipv4 - Subnet : Network ID 구분같은망이냐외부망이냐? 255.0.0.0 255.255.0.0 255.255.255.0
TCP/IP 통신 ipconfig
TCP/IP 통신 Domain Name Host 식별명 Host IP address DNS Inverse Domain 1.0.0.127.in-addr.arpa
TCP/IP 통신 DNS with ping Host 식별명 DNS
TCP/IP 통신 TCP(1) - Transfer Control Protocol - Stateful : 연결지향성, 신뢰성, 흐름제어기능을갖는 Transport layer
TCP/IP 통신 TCP(2) - Server/Client 통신 - Interactive 통신 : 3 way Handshaking 통신복잡도및유지비용증가
TCP/IP 통신 UDP(1) - User Datagram Protocol - Stateless : 비연결성, 비신뢰성, 흐름제어기능이없는 Transport layer - Unicasting(1:1), Multicasting(1:N), Broadcasting(1:ALL) 지원 Multicasting IP address : 224.0.0.0 ~ 239.255.255.255 Broadcasting IP address : 255.255.255.255, NetID.255(192.168.0.255) Ex) DHCP, DNS, NTP
TCP/IP 통신 TCP vs UDP
Network 개념따라잡기 SOCKET 통신 - Socket 이란 - Socket API - iolibrary
SOCKET 통신 Socket 이란? - 통신에필요한모든제원 (Resource => IP & Port) cf> Channel : 통신을위한가상의통로 SOCKET (192.168.0.100, TCP:2000) SOCKET (192.168.0.200, TCP:3000)
SOCKET 통신 Socket API?(1) - Berkelery Socket API : Bible of Socket API TCP =>
SOCKET 통신 Socket API?(2) UDP =>
SOCKET 통신 WIZnet Socket API? - iolibrary : Officail WIZnet Socket API for W5100,W5200,W5300,W5500, https://github.com/wiznet/iolibrary_driver https://github.com/wiznet/w7500 - Arduino Library : Arudino Shield for W5100,W5200, W5500 https://github.com/wiznet/wiz_ethernet_library - WIZnetInterface : ARMmbed for W5500, W7500 https://developer.mbed.org/teams/wiznet/code/wiznetinterface/
SOCKET 통신 iolibrary(1) API WIZnet Berkeley socket() O O bind() No need O listen() O O connect() O O accept() No need O recv() O O send() O O recvfrom() O O sendto() O O closesocket() O close() & disconnect() O Refer to SOCKET APIs.chm (http://wizwiki.net/wiki/doku.php?id=products:w5500:driver)
SOCKET 통신 iolibrary(2)
WIZnet Chips Features Block Diagram Socket Status vs Socket APIs(Command)
Features Fully Hardwired TCP/IP 이더넷솔루션 - TCP/IP Ethernet Chips : W3100(A+)<W3150<W5100<W5300<W5200<W5500 - Integrated MCU : 8051, CortexM3, M0) : W7100, W7200, W7500(P) - TCP, UDP, ICMP, IPv4, ARP, IGMP, PPPoE - 4 or 8 SOCKETs - Integrated Ethernet PHY - BUS or SPI Mode 0/3 (Up to 80MHz) - LQFP or QFN
Block Diagram 8051, CortexM W7xxx W3xxx W5xxx
Socket Status vs Socket Command
Packet Sniffing Wireshark
Q&A 감사합니다 How a packet moves through network: https://www.youtube.com/watch?v=o7cuflm4v54
ARM mbed WIZwiki- W7500 으로 IoT Developer 되기 Roy Kim 2015.12.03 Network 기초
Contents 1. ARM mbed 2. HDK: WIZwiki-W7500 3. SDK: mbed, WIZnetInterface 4. Networking (Lab1) 5. Protocol: DHCP (Lab2) 6. Protocol: DNS Web (HTTP) Client (Lab3) 7. Demo: IoT Cloud 연동 (data.sparkfun.com)
1. ARM mbed
ARM mbed ARM? a British company that designs the ARM computer processors ARM architecture ARM SoC Samsung Exynos
ARM mbed mbed.org IoT Device Platform 을위해구성되는 Silicon, Cloud, Device Partner 들의 Community
ARM mbed mbedos
ARM mbed Cortex Microcontroller Software Interface Standard
ARM mbed mbed Device Server
ARM mbed Web-IDE
ARM mbed Site-Map: mbed.com Click to developer.mbed.com site map for mbed.com
ARM mbed Site-Map: developer.mbed.com
ARM mbed https://developer.mbed.org/platforms/
ARM mbed https://developer.mbed.org/components/
ARM mbed https://developer.mbed.org/components/adjd-s311-i2c-color-sensor/ *Color Sensor =components *Hello World =example code *Library =driver code
ARM mbed https://developer.mbed.org/handbook/homepage mbed libraries (APIs, user s guide) Analog I/O Digital I/O Timers Digital Interface Real-Time Operating System File System Networking
ARM mbed https://developer.mbed.org/cookbook/homepage mbed libraries (APIs, user s guide) Components and Libraries How to components
ARM mbed https://developer.mbed.org/code/ Version management Mercurial 연동 Reference Codes User s codes
ARM mbed https://developer.mbed.org/compile/ Web- IDE Editing & Compile Download/ Program
2. mbed HDK: WIZwiki-W7500 mbed Hardware Development Kit
WIZwiki-W7500 W7500(Cortex-M0+TOE) + PHY for Ethernet + CMSIS-DAP Arduino Pins Arduino Pins Refer to wizwiki.net for more detail (schemetic/driver/user s guide)
WIZwiki-W7500 Block diagram
WIZwiki-W7500 Call-out
WIZwiki-W7500 Pin-map
What is TOE
TOE Implementation for W7500
Firewall SoC with TCP/IP Offload Engine for Internet of Things
3. mbed SDK: WIZwiki-W7500 mbed Software Development Kit
WIZwiki-W7500 for mbed library on WEB-IDE
WIZwiki-W7500 for WIZnetInterface on WEB-IDE EthernetInterface EthernetInterface EthernetInterface Socket TCP/IP Protocols Ethernet WIZnetInterface Socket TCP/IP Protocols Ethernet
WIZwiki-W7500 for WIZnetInterface on WEB-IDE (1) HTTP FTP Telnet NTP SNTP Applications DHCP DNS * TOE Driver mbed Ethernet Interface TCP UDP IP Ethernet WIZnet Interface
WIZwiki-W7500 Where is WIZnetInterface 2 4 1 3 5 6
4. Lab1 Configure local Network
1. C Class IP address 사용 2. Local:@Hub 와 PC 사용 Ping test Lab1 Make Local Networking 3. WAN:@ 공유기사용 ping www.naver.com
5. Lab2 Dynamic Host Configuration Protocol Client with WIZwiki-W7500
Lab2: DHCP Client (1) 2 1 EthernetInterface class type 으로 eth 라는 instance 를생성 MAC Address 를 HEX TYPE 의배열로생성
Lab2: DHCP Client (2) 3 3 4 DHCP 사용시 DHCP 설정을위해 #define _DHCP_ 을선언하고 eth.init(mac_addr) 을호출, eth_init() 호출된다고 DHCP Client 가실행되지않음을유의 Fixed IP address 를사용할경우코드와같이 IP, Gateway, Subnet Mask 는 string type 으로정의하여 eth.init() 을호출한다.
Lab2: DHCP Client (3) Application( 예 :DHCP Client) 의시작전 PHY 의연결이준비되었는지 link() 함수를이용하여체크한다. 5
Lab2: DHCP Client (4) eth.connect 설정한 IP addresse 들을 W7500 의 Register 에 Write 한다. 6 DHCP 로설정한경우이함수에서 DHCP Client 가수행된다. DHCPClient 의성공유무는 connect() 함수의리턴값으로알수있다. 성공이면양수, 실패면음수가리턴된다. DHCP Server 로부터동일하게설정된 IP Address 들은 W7500 의 Register 에 Write 된다.
Lab2 : step1 - Create New Program as DHCPAddressPrinter
Lab2 : step2 - Import WIZnetInterface by using Import Wizard
Lab2 : step3 - Configure DHCP Client 1. WIZnetInterface lib 사용위해 2. MAC address 선언 3. init() 로 MAC address 초기화및 DHCPClient 사용셋팅 4. Ethernet PHY Link 상태확인 5. Connect() DHCP 실행 : DHCP 성공시, Fix-IP address 사용시, 설정 IP addres 를 W7500 Register 에 Writing 6. 할당받은 IP address 들을출력
Lab2 : step4 - Setting Serial (Com) port https://developer.mbed.org/handbook/windows-serial-configuration
Lab2 : step5 - Setting Serial Program Download: http://logmett.com/index.php?/download/free-downloads.html
Lab2 : step6 - Compile & Download (Program)
Lab2 : step7 - Serial Terminal Output
6. Lab3 DNS Web(HTTP) Client with WIZwiki-W7500
DNS Web(HTTP) Client https://www.igvita.com/2008/09/22/high-performance-dns-for-the-cloud/ 1. DNS Client : Domain => IP address 2. Web (HTTP) Client: Request *.htm to Web Server over HTTP
DNS Web(HTTP) Client Domain Name Service over UDP UDP Header http://www.firewall.cx/networking-topics/protocols/domain-name-system-dns/160-protocols-dns-query.html WIZInterface Lib 에포함되어있는 Protocol 로 sendto() 또는 connect() 시 Destination IP address 가 Domain Name 일경우자동으로실행된다.
DNS Web(HTTP) Client Hyper Text Transfer Protocol over TCP http://www.lgosys.com/products/frameseerhelp/ovw20.html http://www.digikey.com/en/articles/techzone/2011/apr/coldfire-ethernet-for-diverse-applications
DNS Web(HTTP) Client HTTP Request Message Format - Request: Client 가 server 로전송하는 Message ex.) Get ( 요청 ), Post ( 실행 ), put( 생성 ),Delete( 삭제 ) - Response: Request 에대한 Server 의 Message
DNS Web(HTTP) Client HTTP Response Message Format value 1XX 2XX 3XX 4XX 5XX Description Information Successful Redirection Client Error Server Error
Lab3: DNS Web Client (1) - Create program and Import WIZnetInterface
Lab3: DNS HTTP Client (2) 1. Set Destination port 2. Set Destination Domain Name 3 4 5 6 7 3. Set the Request Message GET( 요청 ) /(Root page) 4. MAC address 선언 5. init() 로 MAC address 초기화및 DHCPClient 사용셋팅 6. Ethernet PHY Link 상태확인 7. Connect() DHCP 실행 : DHCP 성공시, Fix-IP address 사용시, 설정 IP addres 를 W7500 Register 에 Writing
Lab3: DNS HTTP Client (3) 1 1. Connect(DomainName, ServerPort) TCP connection 시도 3 2 2. send(httpreqmessage, HTTPReqMesageSize) HTTPRequestMessage 전송 3. recv(httpresmessage, HTTPResMesageSize) HTTPResponseMessage 수신 4 4. Output Response Message over Serial port
Lab3: DNS HTTP Client (3)
Lab3: DNS HTTP Client (4)
Blog: embeddist.blogspot.com wizwiki.net mbed.org Thanks