TDC561 Network Programming Camelia Zlatea, PhD Week 9: IPv6 IPv6 Client-Server Programming.

Slides:



Advertisements
Similar presentations
Introduction to IPv6 Presented by: Minal Mishra. Agenda IP Network Addressing IP Network Addressing Classful IP addressing Classful IP addressing Techniques.
Advertisements

Introduction to IPv6 Network & Application Passakon Prathombutr Next Generation Internet (NGI) National Electronics and Computer Technology Center.
Future Directions For IP Architectures Ipv6 Cs686 Sadik Gokhan Caglar.
IPv6 The New Internet Protocol Integrated Network Services Almerindo Graziano.
CPSC Network Layer4-1 IP addresses: how to get one? Q: How does a host get IP address? r hard-coded by system admin in a file m Windows: control-panel->network->configuration-
Transitioning to IPv6 April 15,2005 Presented By: Richard Moore PBS Enterprise Technology.
1 Features of IPv6 Larger Address Extended Address Hierarchy Flexible Header Format Improved Options Provision For Protocol Extension Support for Auto-configuration.
Netprog: IPv61 IPv6 Refs: Chapter 10, Appendix A.
1 May, 2007: American Registry for Internet Numbers (ARIN) “advises the Internet community that migration to IPv6 numbering resources is necessary for.
IPv6 Overview Brent Frye EECS710. Overview Google Drive Microsoft Cloud Drive Dropbox Paid-for alternatives 2.
Computer Networks20-1 Chapter 20. Network Layer: Internet Protocol 20.1 Internetworking 20.2 IPv IPv6.
1 IPv6. 2 Problem: 32-bit address space will be completely allocated by Solution: Design a new IP with a larger address space, called the IP version.
IPv6 Victor T. Norman.
Socket Programming with IPv6. Why IPv6? Addressing and routing scalability Address space exhaustion Host autoconfiguration QoS of flow using flowlabel.
CSE 333 – SECTION 8 Networking and sockets. Overview Network Sockets IP addresses and IP address structures in C/C++ DNS – Resolving DNS names Demos.
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public 1 Addressing the Network – IPv4 Network Fundamentals – Chapter 6.
CS 457 – Lecture 16 Global Internet - BGP Spring 2012.
IPv4 and IPv6 Interoperability Chap 12. IPv6 Objectives  Expanded Addressing Capabilities  Header Format Simplification  Improved Support for Extensions.
1 Internet Protocol Version 6 (IPv6) What the caterpillar calls the end of the world, nature calls a butterfly. - Anonymous.
IP Version 6 Next generation IP Prof. P Venkataram ECE Dept. IISc.
IP Version 6 (IPv6) Dr. Adil Yousif. Why IPv6?  Deficiency of IPv4  Address space exhaustion  New types of service  Integration  Multicast  Quality.
Chapter 5 The Network Layer.
LANMAR for IPv6 Jason Chen Teresa Breyer Yeng-Zhong Lee.
11- IP Network Layer4-1. Network Layer4-2 The Internet Network layer forwarding table Host, router network layer functions: Routing protocols path selection.
Transition Mechanisms for Ipv6 Hosts and Routers RFC2893 By Michael Pfeiffer.
CS 6401 IPv6 Outline Background Structure Deployment.
1 IPv6 Address Management Rajiv Kumar. 2 Lecture Overview Introduction to IP Address Management Rationale for IPv6 IPv6 Addressing IPv6 Policies & Procedures.
1 IPv6 Refs: Chapter 10, Appendix A. 2 IPv6 availability Generally not part of O.S. Available in beta for many operating systems. 6-Bone is experimental.
1 Chapter Overview IP (v4) Address IPv6. 2 IPv4 Addresses Internet Protocol (IP) is the only network layer protocol with its own addressing system and.
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public 1 Addressing the Network – IPv4 Network Fundamentals – Chapter 6.
Client-Side Network Programming
© 2006 Cisco Systems, Inc. All rights reserved.Cisco Public BSCI Module 8 Lessons 1 and 2 1 BSCI Module 8 Lessons 1 and 2 Introducing IPv6 and Defining.
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. © The McGraw-Hill Companies, Inc. IP version 6 Asst. Prof. Chaiporn Jaikaeo,
Fall 2005Computer Networks20-1 Chapter 20. Network Layer Protocols: ARP, IPv4, ICMPv4, IPv6, and ICMPv ARP 20.2 IP 20.3 ICMP 20.4 IPv6.
SYSTEM ADMINISTRATION Chapter 8 Internet Protocol (IP) Addressing.
Universal, Ubiquitous, Unfettered Internet © ui.com Pte Ltd Mobile Internet Protocol under IPv6 Amlan Saha 3UI.COM Global IPv6 Summit,
1 Network Layer Lecture 15 Imran Ahmed University of Management & Technology.
1 Network Layer Lecture 16 Imran Ahmed University of Management & Technology.
Network Layer4-1 IP: Internet Protocol r Datagram format r IPv4 addressing r DHCP: Dynamic Host Configuration Protocol r NAT: Network Address Translation.
IP Version 6 ITL. © 2003 Hans Kruse & Shawn Ostermann, Ohio University 2 Information Sources Christian Huitema, “IPv6, The New Internet Protocol”,
IPv4 to IPv6 Group A2 - Roland Hollis - EJ Chambers - Rachit Gupta.
Page 1 Network Addressing CS.457 Network Design And Management.
Transport Layer3-1 Chapter 4: Network Layer r 4. 1 Introduction r 4.2 Virtual circuit and datagram networks r 4.3 What’s inside a router r 4.4 IP: Internet.
Introduction to IPv6 ECE4110. Problems with IPv4 32-bit addresses give about 4,000,000 addresses IPv4 Addresses WILL run out at some point – Some predicted.
TELE 402 Lecture 6: Name and address conversions 1 Overview Last Lecture –Socket Options and elementary UDP sockets This Lecture –Name and address conversions.
1/28/2010 Network Plus IP Addressing Review. IP Address Classes.
Bjorn Landfeldt, The University of Sydney 1 NETS 3303 IPv6 and migration methods.
Sockets Introduction Socket address structures Value-result arguments
CSCI 330 UNIX and Network Programming Unit XIV: User Datagram Protocol.
1 Chapter 4: Internetworking (Internet Protocol) Dr. Rocky K. C. Chang 16 March 2004.
CSE5803 Advanced Internet Protocols and Applications (13) Introduction Existing IP (v4) was developed in late 1970’s, when computer memory was about.
IP Protocol CSE TCP/IP Concepts Connectionless Operation Internetworking involves connectionless operation at the level of the Internet Protocol.
Lecture 15 Socket Programming CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
Network Layer Protocols COMP 3270 Computer Networks Computing Science Thompson Rivers University.
1 COMP 431 Internet Services & Protocols The IP Internet Protocol Jasleen Kaur April 21, 2016.
Network Layer IP Address.
Socket Programming(1/2). Outline  1. Introduction to Network Programming  2. Network Architecture – Client/Server Model  3. TCP Socket Programming.
Lecture 13 IP V4 & IP V6. Figure Protocols at network layer.
CSE 333 – SECTION 8 Client-Side Network Programming.
IPv6 Internet Protocol, Version 6 Yen-Cheng Chen NCNU
Next Generation: Internet Protocol, Version 6 (IPv6) RFC 2460
The New Internet Protocol
The New Internet Protocol
Name and Address Conversions Part I
CSCI {4,6}900: Ubiquitous Computing
Refs: Chapter 10, Appendix A
DHCP: Dynamic Host Configuration Protocol
Computer Networks Protocols
Internet Protocol version 6 (IPv6)
Chapter 4: outline 4.1 Overview of Network layer data plane
Presentation transcript:

TDC561 Network Programming Camelia Zlatea, PhD Week 9: IPv6 IPv6 Client-Server Programming

Page 2 Network Programming (TDC561) Winter 2003 References  W. Richard Stevens, Network Programming : Networking API: Sockets and XTI, Volume 1, 2nd edition, 1998 (ISBN X) –Chap. 7, 11, 19, 21, 22

Page 3 Network Programming (TDC561) Winter 2003 Motivation for IPv6 Total Datagram Length Datagram ID Checksum 32 bit source address 32 bit destination address 4 bytes (32 bits) Header Length Flags Fragment Offset Ver TOS TTLProtocol IP Options Payload (data portion) Basic Header IPv4 Header Format IPv4 - Variable Header, 32-bit addresses 4 for IPv4

Page 4 Network Programming (TDC561) Winter 2003 Motivation for IPv6 Payload Length 128 bit source address 4 bytes (32 bits) Next Header Hop Limit Ver Payload (includes optional headers & data portion) Basic Header Traffic Class Flow Label 128 bit destination address IPv6 Header Format IPv6 - Fixed Header, 128-bit addresses, Flow label 6 for IPv6

Page 5 Network Programming (TDC561) Winter 2003 Motivation for IPv6  IPv6 supports very large address space –No shortage of IPv4 addresses within organizations  Showcase a variety of applications –Support for hand-held devices –IPv6 adopted as standard for 3G mobile networks  Support for IPv6 in Win2000 –Microsoft has technical preview of IPv6 with APIs and SDKs available for Win2000

Page 6 Network Programming (TDC561) Winter 2003 IPv6 Headers  Simpler header - faster processing by routers. –No optional fields - fixed size (40 bytes) –No fragmentation fields. –No checksum  Support for multiple headers –more flexible than simple “protocol” field.

Page 7 Network Programming (TDC561) Winter 2003 IPv6 Header Fields  VERS: 6 (IP version number)  Priority(Traffic Class): will be used in congestion control  Flow Label: experimental - sender can label a sequence of packets as being in the same flow.  Payload Length: number of bytes in everything following the 40 byte header, or 0 for a Jumbogram.  Next Header is similar to the IPv4 “protocol” field - indicates what type of header follows the IPv6 header.  Hop Limit is similar to the IPv4 TTL field (but now it really means hops, not time).

Page 8 Network Programming (TDC561) Winter 2003 Extension Headers  Routing Header - source routing  Fragmentation Header - supports fragmentation of IPv6 datagrams.  Authentication Header  Encapsulating Security Payload Header

Page 9 Network Programming (TDC561) Winter 2003 IPv6 availability  Generally available with (new) versions of most operating systems. –BSD, Linux, Solaris 8  An option with Windows 2000/NT  Most routers can support IPV6

Page 10 Network Programming (TDC561) Winter 2003 IPv6 Design Issues  Overcome IPv4 scaling problem –lack of address space.  Flexible transition mechanism.  New routing capabilities.  Quality of service.  Security.  Ability to add features in the future.

Page 11 Network Programming (TDC561) Winter 2003 IPv6 Addresses  128 bits - written as eight 16-bit hex numbers. 5f1b:df00:ce3e:e200:0020:0800:2078:e3e3  High order bits determine the type of address.

Page 12 Network Programming (TDC561) Winter 2003 Motivation for IPv6  Structured IPv6 header formats lead to design of fast and efficient routers –All headers (including optional headers) are 40 bytes long »In IPv4, header length varies from 20 to 60 bytes –Intermediate routers cannot fragment packet »Fragmentation is possible only at the source »Reduces routing overhead – No checksum performed on the header »Optional IPSEC header authentication can be used  Efficient address management in IPv6  Relaxed schedules for Router upgrades

Page 13 Network Programming (TDC561) Winter 2003 Motivation for IPv6  IPv6 Address assignment designed to support address aggregation –Smaller routing tables, easier to manage, more scalable, faster and efficient routers  Support for multicast addresses –Various standard multicast addresses are pre-defined »Useful for dynamically changing information on a given subset of routers/servers e.g., Lease time for addresses assigned by DHCP servers can be easily modified with a controlled multicast sent to all-DHCP servers multicast address (useful for renumbering IP addresses)

Page 14 Network Programming (TDC561) Winter 2003 IPv6 Unicast Address Types  Link-local unicast addresses –Automatically assigned and used for localized communication –Pertinent only to routers and end-hosts on the local subnet  Site-local unicast address –Similar to IPv4 private addresses –Has relevance only within the given site »Site could refer to a given enterprise or a given geographic location »Packets bearing this address are not routed outside the scope of the site. continued...

Page 15 Network Programming (TDC561) Winter 2003 IPv6 Unicast Address Types  Aggregation of global unicast address –Unique address across all IP networks –Assigned by the Internet Service Provider »ISP gets the bundle of addresses from Regional Registries for Internet Numbers »Helps in address aggregation and smaller Internet routing tables »IPv4 addresses are not dependent on the ISP. Results in large Internet routing tables.  IP address aggregation is crucial for scaling

Page 16 Network Programming (TDC561) Winter 2003 IPv6 - Aggregate Global Unicast Address 001TLA IDNLA IDSLA IDInterface ID TLA: top-level aggregation NLA: next-level SLA: site-level Interface ID is (typically) based on hardware MAC address

Page 17 Network Programming (TDC561) Winter 2003 IPv4-Mapped IPv6 Address  IPv4-Mapped addresses allow a host that support both IPv4 and IPv6 to communicate with a host that supports only IPv4.  The IPv6 address is based completely on the IPv4 address.  80 bits of 0s followed by 16 bits of ones, followed by a 32 bit IPv4 Address: 80 bits32 bits16 bits IPv4 AddressFFFF

Page 18 Network Programming (TDC561) Winter 2003 Works with DNS  An IPv6 application asks DNS for the address of a host, but the host only has an IPv4 address.  DNS creates the IPv4-Mapped IPv6 address automatically.  Kernel understands this is a special address and really uses IPv4 communication.

Page 19 Network Programming (TDC561) Winter 2003 IPv4-Compatible IPv6 Address  An IPv4 compatible address allows a host supporting IPv6 to talk IPv6 even if the local router(s) don’t talk IPv6.  IPv4 compatible addresses tell endpoint software to create a tunnel by encapsulating the IPv6 packet in an IPv4 packet.  80 bits of 0s followed by 16 bits of 0s, followed by a 32 bit IPv4 Address: IPv4 Address bits32 bits16 bits

Page 20 Network Programming (TDC561) Winter 2003 Tunneling IPv6 Host IPv6 Host IPv4 Routers IPv6 Datagram IPv4 Datagram  done automatically by kernel when IPv4-Compatible IPv6 addresses are used

Page 21 Network Programming (TDC561) Winter 2003 Dual Server  Server that handle both IPv4 and IPv6.  The work is handled by the O.S. (which contains protocol stacks for both v4 and v6): –automatic creation of IPv6 address from an IPv4 client (IPv4- mapped IPv6 address).

Page 22 Network Programming (TDC561) Winter 2003 IPv4 client IPv4 client TCP IPv4 Datalink IPv6 client IPv6 client TCP IPv6 Datalink IPv6 server IPv6 server TCP Datalink IPv4 IPv6 IPv4-mapped IPv6 address IPv4-mapped IPv6 address Dual Server

Page 23 Network Programming (TDC561) Winter 2003 IPv6 Clients  If an IPv6 client specifies an IPv4 address for the server, the kernel detects and talks IPv4 to the server.  DNS support for IPv6 addresses can make everything work. –getaddrinfo() returns an IPv4 mapped IPv6 address for hosts that only support IPv4.

Page 24 Network Programming (TDC561) Winter 2003 IPv6 - IPv4 Programming  The kernel does the work, we can assume we are talking IPv6 to everyone!  In case we really want to know, there are some macros that determine the type of an IPv6 address. –We can find out if we are talking to an IPv4 client or server by checking whether the address is an IPv4 mapped address.

Page 25 Network Programming (TDC561) Winter 2003 IPv6 Sockets programming  New address family: AF_INET6  New address data type: in6_addr  New address structure: sockaddr_in6  IPv6-based client/server applications

Page 26 Network Programming (TDC561) Winter 2003 in6_addr struct in6_addr { uint8_t s6_addr[16]; };

Page 27 Network Programming (TDC561) Winter 2003 sockaddr_in6 struct sockaddr_in6 { uint8_tsin6_len; sa_family_tsin6_family; in_port_tsin6_port; uint32_tsin6_flowinfo; struct in6_addrsin6_addr; };

Page 28 Network Programming (TDC561) Winter 2003 getaddrinfo()  used both to look up hostnames, and to look up service names (port numbers)  does not use perror() to report errors, but its own function gai_strerror(). #include int getaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res); IPv4IPv6 gethostbyname() getaddrinfo() getservicebyname()

Page 29 Network Programming (TDC561) Winter 2003 getnameinfo()  Extracting info about a connection is placed in getnameinfo()  Corresponding to getpeername/getsockname. #include int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags); IPv4IPv6 getservbyport() getnameinfo() getservbyname() getpeername()

Page 30 Network Programming (TDC561) Winter 2003 Operating Systems - IPv6 Support  Some operating systems do not conform to the standard interfaces.  OpenBSD does not map IPv4 addresses to IPv6 ranges.  Windows winsock, –reported issues in supporting inet_ptoa. –alternative: getaddrinfo can be used to get around this (more expensive).  Standard way to find out interface configuration information about the ipv6 addresses –ifconfig/ipconfig. (SunOS, HP-UX, Linux versions,..) –Example: % ifconfig le0 inet6 le0: flags=

Page 31 Network Programming (TDC561) Winter 2003 Example: Mixing IPv4 and IPv6 // Server.c #include #define bufsize 20 #define queuesize 5 #define true 1 #define false 0 main () { struct sockaddr_in6 cin; char buffer[bufsize]; int sd, sd_client, addrlen, yes=1,err; struct addrinfo query,*response,*ap; bzero(&query,sizeof(struct addrinfo)); query.ai_flags = AI_PASSIVE; query.ai_family = AF_UNSPEC; query.ai_socktype = SOCK_STREAM; if ((err = getaddrinfo(NULL,"servicename",&query,&response)) != 0) { printf("%s",gai_strerror(err)); return; }

Page 32 Network Programming (TDC561) Winter 2003 Mixing IPv4 and IPv6 sd = -1; for (ap = response ; ap != NULL; ap=ap->ai_next) { if ((sd = socket(ap->ai_family,ap->ai_socktype,ap->ai_protocol)) == -1) { continue; } if (bind(sd,ap->ai_addr,ap->ai_addrlen) == 0) { break; // success } perror("bind"); close(sd); sd = -1; } freeaddrinfo(response); if (sd < 0) { printf("Couldn't open bind an open socket\n"); exit(1); } if (listen(sd,queuesize) == -1) { perror("listen"); exit(1); }

Page 33 Network Programming (TDC561) Winter 2003 Mixing IPv4 and IPv6 while (true) { char hostname[100],service[100]; bzero(hostname,100); bzero(service,100); if ((sd_client = accept(sd,(struct sockaddr *)&cin,&addrlen)) == -1) { perror("accept"); exit(1); } if (getnameinfo((struct sockaddr *)&cin,addrlen,hostname,100,service,100,0) != 0) { perror("getnameinfo"); } printf("Connection received from host (%s) on remote port (%s)\n",hostname,service); bzero(buffer,20); if (recv(sd_client,buffer,sizeof(buffer),0) == -1) { perror("recv"); exit(1); }

Page 34 Network Programming (TDC561) Winter 2003 Mixing IPv4 and IPv6 // doWork(buffer) here if (send(sd_client,buffer,strlen(buffer),0) == -1) { perror("send"); exit(1); } close (sd_client); } close (sd); printf("Server closing down...\n"); }

Page 35 Network Programming (TDC561) Winter 2003 Mixing IPv4 and IPv6 // Client.c char *sockaddr_ntop(struct sockaddr *sa); main (argc,argv) int argc; char *argv[]; { struct sockaddr_in6 cin,cin2; struct addrinfo req, *ans, *ap; char buffer[bufsize],ip6str[INET6_ADDRSTRLEN]; int sd,err,connected = false; bzero(&req,sizeof(struct addrinfo)); req.ai_family = AF_UNSPEC; req.ai_socktype = SOCK_STREAM; // This port name has to exist, otherwise getaddrinfo fails if ((err = getaddrinfo(HOST,"servicename",&req,&ans)) != 0) { printf("Lookup error: %s\n",gai_strerror(err)); exit(0); } #include #define HOST “hawk.depaul.edu" #define bufsize 20 #define false 0 #define true 1

Page 36 Network Programming (TDC561) Winter 2003 Mixing IPv4 and IPv6 for (ap = ans; ap != NULL; ap = ap->ai_next) { printf("Trying to connect to %s = %s\n",HOST,sockaddr_ntop(ap->ai_addr)); if ((sd = socket(ap->ai_family,ap->ai_socktype,ap->ai_protocol)) == -1) { perror("socket"); exit(1); } if (connect(sd, ap->ai_addr, ap->ai_addrlen) >= 0) { connected = true; break; } freeaddrinfo(ans); if (connected) { sprintf(buffer,"%s + %s",argv[1],argv[3]); if (send(sd,buffer,strlen(buffer),0) == -1) { perror ("send"); exit(1); }

Page 37 Network Programming (TDC561) Winter 2003 Mixing IPv4 and IPv6 bzero(buffer,bufsize); if (recv(sd,buffer,bufsize,0) == -1) { perror("recv"); exit (1); } printf ("Server responded with %s\n",buffer); close (sd); } char *sockaddr_ntop(struct sockaddr *sa)

Page 38 Network Programming (TDC561) Winter 2003 Mixing IPv4 and IPv6 char *sockaddr_ntop(struct sockaddr *sa) { void *addr; static char addrbuf[INET6_ADDRSTRLEN]; switch (sa->sa_family) { case AF_INET: addr = &((struct sockaddr_in *)sa)->sin_addr; break; case AF_INET6: addr = &((struct sockaddr_in6 *)sa)->sin6_addr; break; default: /* terminate the process abnormally */ abort(); } inet_ntop(sa->sa_family, addr, addrbuf, sizeof(addrbuf)); / * The inet_ntop() routine converts a numeric address into a string suitable for presentation. Can manipulate both IPv4 and IPv6 addresses */ return addrbuf; }