java - What is difference between name and display name of a network interface? -
i using java 8 on ubuntu 16.04. class java.net.networkinterface has 2 methods interface name. first 1 is:
get name of network interface. returns: name of network interface public string [more ...] getname() { return name; }
other 1 is:
get display name of network interface. display name human readable string describing network device. returns: display name of network interface, or null if no display name available. public string [more ...] getdisplayname() { return displayname; }
when ifconfig, output is:
enp0s25 link encap:ethernet hwaddr 00:24:1d:6e:03:42 inet addr:10.100.14.40 bcast:10.100.255.255 mask:255.255.0.0 inet6 addr: fe80::fc60:10a7:2f7e:127f/64 scope:link broadcast running multicast mtu:1500 metric:1 rx packets:30338414 errors:0 dropped:31 overruns:0 frame:0 tx packets:446227 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 rx bytes:3188550996 (3.1 gb) tx bytes:53620407 (53.6 mb) interrupt:16 memory:fc500000-fc520000
only 1 name shown. if run following program:
import java.net.*; import java.io.*; import java.util.*; class mynetworkinterface { public static void main(string[] args) throws exception { enumeration<networkinterface> interfaces = networkinterface.getnetworkinterfaces(); while(interfaces.hasmoreelements()) { networkinterface n = (networkinterface) interfaces.nextelement(); system.out.println(n); system.out.printf("the name is: %s%n", n.getdisplayname()); system.out.printf("the name: %s%n", n.getname()); } }
}
the output is:
name:enp0s25 (enp0s25) name is: enp0s25 name: enp0s25 name:lo (lo) name is: lo name: lo
both names same.
my question is: difference between name , display name of network interface? why 2 names used?
Comments
Post a Comment