1 / 18

Chapter 3

Chapter 3. Internet Addressing. Chapter 3 Outline. Hosts Internet addresses Next Generation Internet IPv4 Class A,B and C addresses Domain Name System (DNS) Creating InetAddresses Java 1.4 Added Methods Getter Methods Address Types Object Methods Chapter 3 Highlights.

Télécharger la présentation

Chapter 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 3 Internet Addressing Prepared By E.Musa Alyaman

  2. Chapter 3 Outline • Hosts • Internet addresses • Next Generation Internet • IPv4 • Class A,B and C addresses • Domain Name System (DNS) • Creating InetAddresses • Java 1.4 Added Methods • Getter Methods • Address Types • Object Methods • Chapter 3 Highlights Prepared By E.Musa Alyaman

  3. Hosts • Devices connected to the Internet are called hosts • Most hosts are computers, but hosts also include routers, printers, fax machines,etc. Prepared By E.Musa Alyaman

  4. Internet addresses • Every host on the Internet is identified by a unique, four-byte Internet Protocol (IP) address. • This is written in dotted quadformat like 199.1.32.90 where each byte is an unsigned integer between 0 and 255. • There are about four billion unique IP addresses, but they aren’t very efficiently allocated Prepared By E.Musa Alyaman

  5. Next Generation Internet • The solution is IPv6 which uses 128 bit addresses • Improves services such as multicasting and secure communication • Not yet widely deployed by ISPs • Well written Java software should move to IPv6 without modification/recompilation this is one benefit of abstracted APIs Prepared By E.Musa Alyaman

  6. IPv4 • Each 32 bit IP number consists of two components: • The network address • The unique international address of the network • The host address • The unique address of a specific host in the net • There are three classes of network address denoted class ‘A’, ‘B’ and ‘C’ Prepared By E.Musa Alyaman

  7. Class A Class B Class C Class A,B and C addresses 192 . 85 . 35 . 87 0... 10... 110... Network Address Byte Host Address Byte Prepared By E.Musa Alyaman

  8. Domain Name System (DNS) • Numeric addresses are mapped to names like www.msn.com or mail.msn.com by DNS. • Each site runs domain name server software that translates names to IP addresses and vice versa • DNS is a distributed system Prepared By E.Musa Alyaman

  9. IP Addresses and Java • Java has a class java.net.InetAddress which abstracts network addresses • Serves three main purposes: • Encapsulates an address • Performs name lookup (converting a host name into an IP address) • Performs reverse lookup (converting the address into a host name) Prepared By E.Musa Alyaman

  10. Creating InetAddresses • There are no public InetAddress() constructors. Arbitrary addresses may not be created. • All addresses that are created must be checked with DNS Prepared By E.Musa Alyaman

  11. Ways to create InetAddress objects public static InetAddress getByName(String host) throws UnknownHostException public static InetAddress[ ] getAllByName(String host) throws UnknownHostException public static InetAddress getLocalHost() throws UnknownHostException Prepared By E.Musa Alyaman

  12. Java 1.4 Added Methods • Java 1.4 adds two more factory methods that do not check their addresses with the local DNS server. The first creates an InetAddress object with an IP address and no hostname. The second creates an InetAddress object with an IP address and a hostname. public static InetAddress getByAddress(byte[ ] address) throws UnknownHostException public static InetAddress getByAddress(String hostName, byte[] address) throws UnknownHostException Prepared By E.Musa Alyaman

  13. Getter Methods They return the hostname as a string and the IP address as both string and a byte array • public String getHostName() • public byte[ ] getAddress() • public String getHostAddress() Prepared By E.Musa Alyaman

  14. Address Types • Public boolean isAnyLocalAddress() • Public boolean isLoopbackAddress() • Public boolean isLinkLocalAddress() • Public boolean isSiteLocalAddress() • Public boolean isMulticastAddress() • Public boolean isMCGloabl() • Public boolean isMCNodeLocal(( • Public boolean isMCLinkLocal() • Public boolean isMCSiteLocal() • Public boolean isMCOrgLocal() Prepared By E.Musa Alyaman

  15. Object Methods • Public boolean equals (Object o) • Public int hashCode () • Public String toString () Prepared By E.Musa Alyaman

  16. Inet4Address and Inet6Address • Public final class Inet4Address extends InetAddress • Public final class Inet6Address extends InetAddress Prepared By E.Musa Alyaman

  17. Using InetAddress objects import java.net.InetAddress; import java.net.UnknownHostExcepion; public static void main(String[] args) { try { InetAddress inet1 = InetAddress.getByName("asp.ee.uwa.edu.au"); System.out.println( "HostAddress=" + inet1.getHostAddress()); InetAddress inet2 = InetAddress.getByName("130.95.72.134"); System.out.println("HostName=" + inet2.getHostName()); if (inet1.equals(inet2)) System.out.println("Addresses are equal"); } catch (UnknownHostException uhe) { uhe.printStackTrace(); } } Prepared By E.Musa Alyaman

  18. Chapter Highlights In this chapter, you have learned: • About the Domain Name System (DNS) and domain name suffixes (such as .com) • About the structure of an IP address and the various classes of IP addresses • About the InetAddress class and its various methods Prepared By E.Musa Alyaman

More Related