- Forward


Using Internet Addresses and the DNS
in Java


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

The Internet Protocol (v4)
Back SMYC Forward
  • IP Addresses:
    • Four bytes (32 bits)
    • Dotted Quads
  • IP Packet Format:
    • Header (20-60 bytes) that includes from/to addresses
    • Payload (up to 65,515 bytes)
The Internet Protocol (v6)
Back SMYC Forward
  • More Addresses (16 bytes)
  • Simplified Headers
  • Additional Privacy and Security Features
Internet Addresses in Java
Back SMYC Forward
  • InetAddress :
    • public byte[] getAddress()
    • public String getHostAddress()
  • Child Classes:
    • Inet4Address
    • Inet6Address
The Domain Name System (DNS)
Back SMYC Forward
  • Description:
    • A distributed database that allows users to map human readable names to IP addresses
  • Interaction with the DNS:
    • Handled by a resolver that first consults a local DNS server and then, if necessary, consults foreign DNS servers
  • Domain Names:
    • Are hierarchical
    • Portions are separated by '.'
    • Left portion is most specific, right portion is DNS root
DNS in Java
Back SMYC Forward
  • Forward Resolution (Name to Address):
    • InetAddress.getByName(host:String):InetAddress
    • InetAddress.getAllByName(host:String):InetAddress[]
  • Reverse Name Resolution (Address to Name):
    • InetAddress.getByAddress(address:byte[]):InetAddress
DNS in Java (cont.)
Back SMYC Forward

Finding the Local Address

javaexamples/internet/MyAddress.java
 
DNS in Java (cont.)
Back SMYC Forward

Finding Any Address

javaexamples/internet/GetAddress.java
 
There's Always More to Learn
Back -