CSC 469/569 Fall 2014 Computer Networks

Homework 1 : Network Intefaces and IP addresses

The goal of this assignment is to learn about network interfaces, IP addresses, and how DNS is used to resolve between host names and IP addresses.

Start at this site and also using the index in your course text book, At the site on the link above, learn about the terms IP address (First three paragraphs, you do not have to understand the Class A, B, C and CIDR at this time) "subnet", "subnet mask" (First two paragraphs),"DHCP" (First there paragraphs). Also, do some research online for the terms "DNS name server" and "default gateway." Make sure you understand these terms and you are able to define them. These are basic networking terms that you should be familiar with.

Another term related to "subnet" that you should know is "network prefix".

You should also understand the idea of a "broadcast address" on an IP v4 network subnet. Basically, the broadcast address on a subnet is the address with the host part set to all 1s.

Next, you need to learn about the Java API for working with Network interfaces. You will need to browse the documentation for NetworkInterface. This class represents the physical network interface on a machine. It consists of a name for the interface and and a list of IP addresses assigned to the interface. Most network interfaces are assigned a single IP address. Question for you to think about: why would any network interface need more than one IP address?

Next, check out the documentation for the InterfaceAddress . A NetworkInterface can have many addresses, and this class represents a single address assigned to an network interface. The address may be an IPv4 address, or an IPv6 address. If it is a v4 address, it consisist of an IP address, a subnet maskt, and a broadcast address: just the things you see in network adapter configuration tab when look at the properties of a network adapter in Windows.

Finally, check out the documentation for the InetAddress . This represents a single IP address, which may be IPv4 or IPv6. Notice the two subclasses of this class. This class has static methods for querying a DNS server.

The Assignment

For uniformity in grading, this project requires you to use the NetBeans IDE.

Write a Java program that leverages the above three classes to display information about network interfaces and interface addresses. The program should do the following:

  1. List all network interfaces on this computer. Do this by using the static getNetworkInterfaces() method of the NetworkInterface class. This class returns an Enumeration object. If you have never used Enumeration in Java, look online for examples. You can print the data for a NetworkInterface object by passing the object to System.out.println().
  2. For each NetworkInterface object, print out its name and display name. Use the appropriate instance methods of the NetworkInterface class.
  3. Print the names of all the interfaces that are currently up. (Use the isUp() method of NetworkInterface).
  4. List the name, and all IP addresses of each interface that is up. Do this using getInetAddresses() on each interface to get an Enumeration of InetAddresses, and use getHostAddress() on the InetAddress to get the IP address.
  5. List the name, and all IP addresses, and broadcast address of each interface that is up. Do this using getInterfaceAddresses() on each interface to get a List of InterfaceAddress objects, and then use getAddress() and getBroadcastAddress() on the InterfaceAddress objects.
  6. Initialize an array
                      String [] hosts = {"www.noctrl.edu", "www.northcentralcollege.edu", 
                                         "www.microsoft.com", "www.ebay.com", 
                                        "www.whitehouse.gov"
                                        };
                    
    of host names. For each host, use the static method InetAddress.getAllByName(host) to get an array of all InetAddress objects for that host. Add all these InetAddressObjects to a list. Finally, use InetAddress.getLocalHost() to get the InetAddress of the local host and add it to the list. Then, for each InetAddress object in the list print the canonical name and IP address of the corresponding host. If you do not know what a canonical name is, find out.

Here are some questions for you to ponder. Answers to these questions are not part of what you have to turn in.

  1. In the beginning of the program, output appears instantaneously. Toward the end of the program, there is a delay between the printing of successive sets of information. What is the reason for this?
  2. What is a canonical name?
  3. Why do some hosts have more than one canonical name?
  4. The entry for www.Microsoft.com shows a single canonical name. However, if you run the program several times, you will notice that you do not always get the same canonical name or IP address for Microsoft. Why is this?
  5. Gathering information about a remote computer has network security implications. Look at the information for the local host in the sample program output at the end of this page. What can guess about the computer on which the program was run?

What to hand it, and Due Date

Hand in a Java program that does what is required. Due Monday night at the beginning of Week 4. Submit by zipping up the entire Netbeans folder and attaching to an email.

Following is output from a sample run. Make your output match the sample output exactly, because I need to know where to look for information during grading.

List of all network interfaces on this machine: 
name:lo (Software Loopback Interface 1)
name:eth0 (Microsoft Kernel Debug Network Adapter)
name:eth1 (Realtek PCIe GBE Family Controller)
name:net0 (Microsoft ISATAP Adapter)
name:net1 (Teredo Tunneling Pseudo-Interface)
name:eth2 (Realtek PCIe GBE Family Controller-WFP Native MAC Layer LightWeight Filter-0000)
name:eth3 (Realtek PCIe GBE Family Controller-QoS Packet Scheduler-0000)
name:eth4 (Realtek PCIe GBE Family Controller-WFP 802.3 MAC Layer LightWeight Filter-0000)

Names and display names of all interfaces:
Name is  lo  and  display name is Software Loopback Interface 1
Name is  eth0  and  display name is Microsoft Kernel Debug Network Adapter
Name is  eth1  and  display name is Realtek PCIe GBE Family Controller
Name is  net0  and  display name is Microsoft ISATAP Adapter
Name is  net1  and  display name is Teredo Tunneling Pseudo-Interface
Name is  eth2  and  display name is Realtek PCIe GBE Family Controller-WFP Native MAC Layer LightWeight Filter-0000
Name is  eth3  and  display name is Realtek PCIe GBE Family Controller-QoS Packet Scheduler-0000
Name is  eth4  and  display name is Realtek PCIe GBE Family Controller-WFP 802.3 MAC Layer LightWeight Filter-0000

Here is a list of all interfaces that are up:
lo
eth1
net1

getInetAddresses() version of IP addresses of active interfaces:
lo: 127.0.0.1, 0:0:0:0:0:0:0:1, 
eth1: 192.168.3.115, fe80:0:0:0:1cc9:5e97:704e:888b%eth1, 
net1: 2001:0:9d38:6ab8:38e0:25e1:9330:9e4f, fe80:0:0:0:38e0:25e1:9330:9e4f%net1, 

getInterfaceAddresses() version of IP and broadcast addresses  for active interfaces:
lo: 
Address is /127.0.0.1  Broadcast Address is /127.255.255.255
Address is /0:0:0:0:0:0:0:1  Broadcast Address is null
eth1: 
Address is /192.168.3.115  Broadcast Address is /192.168.3.255
Address is /fe80:0:0:0:1cc9:5e97:704e:888b%eth1  Broadcast Address is null
net1: 
Address is /2001:0:9d38:6ab8:38e0:25e1:9330:9e4f  Broadcast Address is null
Address is /fe80:0:0:0:38e0:25e1:9330:9e4f%net1  Broadcast Address is null

Canonical names and IP addresses for selected hosts:
www.noctrl.edu:
	Canonical name : uuo.noctrl.edu
	IP address : 192.160.165.164
www.northcentralcollege.edu:
	Canonical name : 192.160.165.163
	IP address : 192.160.165.163
www.microsoft.com:
	Canonical name : 64.4.11.42
	IP address : 64.4.11.42
www.ebay.com:
	Canonical name : www.ebay.com
	IP address : 66.135.210.61
www.ebay.com:
	Canonical name : www.ebay.com
	IP address : 66.211.181.181
www.ebay.com:
	Canonical name : www.ebay.com
	IP address : 66.211.181.161
www.ebay.com:
	Canonical name : www.ebay.com
	IP address : 66.135.210.181
www.whitehouse.gov:
	Canonical name : 207.152.124.33
	IP address : 207.152.124.33
www.whitehouse.gov:
	Canonical name : 207.152.124.48
	IP address : 207.152.124.48
Win8FamilyRoom:
	Canonical name : Win8FamilyRoom
	IP address : 192.168.3.115