200 likes | 374 Views
OpenH323 and IPv6 support. K. Stamos Computer Engineer , University of Patras Research Engineer , RU 6/ RACTI. Contents. IPv6 changes at the way network applications are developed socket API changes Developing IP-independent applications Activities on porting applications to IPv6
E N D
OpenH323 and IPv6 support K. Stamos Computer Engineer, University of Patras Research Engineer, RU6/RACTI
Contents • IPv6 changes at the way network applications are developed • socket API changes • Developing IP-independent applications • Activities on porting applications to IPv6 • Examples – case study (OpenH323)
IPv4server IPv6server IPv4 client IPv4 communication IPv4 communication, server sees the IPv4-mapped IPv6 address IPv6client May communicate if the IPv6 client uses an IPv4-mapped IPv6 address IPv6 communication IPv4 - IPv6 Interoperability atdual stackmachines
Basic address differences • IPv4: • 32 bits long • decimal • Comprise of 4 numbers in[0…255] • No short notation • Lastsubnet ΙΡ is the broadcast • Loopback 127.0.0.1 • IPv6: • 128bits long • hexadecimal • Short notation (e.g. 3FFE:B00::1) • Nobroadcast addresses • Loopback ::1 • Several scopes (link-local, site-local, global)
Basic socket usage • Server: • socket • bind • listen • accept • read/write/recvfrom/sendto… • Client • socket • connect • read/write/recvfrom/sendto… • Same basic procedure for both ΙΡ protocols
socket API changes – IPv4 struct in_addr { unsigned int s_addr; /* IPv4 address */ }; struct sockaddr_in { sa_family_t sin_family; /* AF_INET */ in_port_t sin_port; /* Port */ struct in_addr sin_addr; /* Internet address */ /* Padding*/ unsigned char sin_zero[sizeof (struct sockaddr) - sizeof (sa_family_t) - sizeof (in_port_t) - sizeof (struct in_addr)]; };
socket API changes – IPv6 struct in6_addr { union { uint8_t u6_addr8[16]; uint16_t u6_addr16[8]; uint32_t u6_addr32[4]; } in6_u; }; struct sockaddr_in6 { sa_family_t sin6_family; /* AF_INET6 */ in_port_t sin6_port; /* Transport layer port # */ struct in6_addr sin6_addr; /* IPv6 address */ uint32_t sin6_flowinfo; /* IPv6 flow info */ uint32_t sin6_scope_id; /* IPv6 scope-id */ };
ΙΡ independent structure Large enough to store any type of address, 128 bytes are reserved #if ULONG_MAX > 0xffffffff # define __ss_aligntype __uint64_t #else # define __ss_aligntype __uint32_t #endif #define _SS_SIZE 128 #define _SS_PADSIZE (_SS_SIZE - (2 * sizeof (__ss_aligntype))) struct sockaddr_storage { sa_family_t ss_family; /* Protocol family */ __ss_aligntype __ss_align; /* Desired alignment */ char __ss_padding[_SS_PADSIZE]; };
BackwardsIPv4 compatibility • 2 separate source code versions, 2 executables (IPv4-only, IPv6-only) • 1 source code version, 2 executables (using macros to produce different executables at compilation) • 1 source code version, 1 IP-independent executable • Take appropriate action using run-time checks • Use IPv6 protocol, and support IPv4 interoperability with IPv4-mapped IPv6 addresses (will not work on IPv4-only machines)
Main modifications • Change GUI where address is presented • Change data structures(sockaddr_in) • Change constants(INADDR_ANY, AF_INET, etc.) • Change functions(e.g. inet_ntoa, gethostbyname) • Hard-coded addresses • Comparing addresses (IPv6 are not single numbers) • Functions that take address parameters / return addresses • Replace / removeIPv4-specific options, e.g.TOS • RFC 2732 (URL addresses in [])
Code changes • Create socket socket(PF_INET6, SOCK_STREAM, 0); /* TCP socket */ socket(PF_INET6, SOCK_DGRAM, 0); /* UDP socket */ • Passingsocketto thekernel struct sockaddr_in6 addr; socklen_t addrlen = sizeof(addr); /* Fill addr struct with IPv6 address before calling bind */ bind(sockfd,(struct sockaddr *)&addr, addrlen); • Passingsocketfrom thekernelto the application struct sockaddr_in6 addr; socklen_t addrlen = sizeof(addr); accept(sockfd,(struct sockaddr *)&addr, &addrlen); /* addr structure an IPv6 address*/
Address conversion functions IPv4 /* IPv4 address conversionfrom printable to binary */ int inet_aton (const char *cp, struct in_addr *inp); in_addr_t inet_addr( const char *cp); /* IPv4 address conversionfrom binary to printable form*/ char *inet_ntoa(struct in_addr in); IPv6 /* IPv4/IPv6address conversionfrom printable to binary */ int inet_pton(int family, const char *src, void *dst); /* IPv4/IPv6address conversionfrom binary to printable form*/ const char *inet_ntop(int family, const void *src,char *dst, size_t cnt);
Using DNS service struct addrinfo { int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ int ai_family; /* AF_UNSPEC, AF_INET, AF_INET6 */ int ai_socktype; /* SOCK_STREAM, SOCK_DGRAM ... */ int ai_protocol; /* IPPROTO_IP, IPPROTO_IPV6 */ size_t ai_addrlen; /* ai_addr length */ struct sockaddr ai_addr; /* socket structure for the address */ char ai_canonname; /* cannonical name */ struct addrinfo ai_next; /* next addrinfo structure */ }; int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res); void freeaddrinfo(struct addrinfo *res);
Automated tools • Available for several platforms: • Checkv4 for Windows (Microsoft) • Socket Scrubber for Solaris (Sun) • IPv6 Porting Assistant for Tru64 Unix (Compaq) • Mainly suitable for C\C++ code • Useful forlargesource code bases • They are usually not sufficient
Case Study – OpenH323 • Open-sourceprojectthat aims at producing a library for implementing H.323 applications • OpenH323 library:rapid development of applications using the H.323 protocol, takes over low-level details and leaves high-level logic for the programmer • PWLib: open-source library, deals with providing basic functionalities of the operating system (sockets, threads, I/O, GUIetc.) • Supports multiple OS (Windows,Unix)
OpenH323 structure • A total of about 400 classes and ~1/2Μ C++ lines of code • Porting and testing activities in the framework of6NET
Main obstacles • ImplicitIPv4 references (e.g.loops, address comparisons7) • Linux-Windows IPv6 implementations compatibility problems • Windows experimental stack (Win 2000) does not fully support RFCs • in Windows XP most problems have been solved • Code size
Completion verification • High-level testing • Low-level testing • Comparative (back-to-back) testing • IPv6 trials for OpenMCU / OpenPhone / GnomeMeeting
Conclusions • Porting to IPv6 is a vital step in the adoption of the new Internet Protocol • The degree of effort required varies in each case • Large source code bases with a lot of low-levelfunctions (like OpenH323) are amongst the most difficult • Further development of automated tools will be useful • Already, a very large number of applications are available for IPv6
Thank you • Questions