How to use Eclipse for Perl Programming

Eclipse is a boon for developers. It is an outstanding development environment. The best thing about it is that it comes with no cost at all, absolutely free. Eclipse is more known as a Java development environment. By default it supports Java only but it also has plug-ins for Perl,C/C++ and PHP. Now its double boon. In this post we will cover how to install the Perl plug-in in Eclipse. Perl integration in Eclipse is provided by EPIC. Here are few things that you must have before proceeding to install the Perl plugin:

  • You have Eclipse installed on your computer (If not then get Eclipse)
  • You have Java SDK on your computer (If not then get Java SDK)
  • You have on Perl SDK your computer (If not the get Perl SDK)

If you have all these three, then lets proceed for installing Perl plug-in.

Step 1:

Start Eclipse. From the “Help” menu. Select “Install New Softwares”

Step 2:

In here you will be asked to provide the source of the update. Add this source: http://e-p-i-c.sf.net/updates/testing. Click add. Then you will be asked to name this plugin. Choose “Perl” (or whatever you want to name it). Click Next.

Step 3:

Now click the check box EPIC and press Next. And then follow a series of Next Next click. Accept the license terms. And go for Next.

You might be prompted with this warning. Just click “OK”

After successful installation you will be asked to restart Eclipse. Restart Eclipse.

Step 4:

Now that you have successfully installed EPIC Perl plugin in eclipse, its time to run the Perl environment in Eclipse. Go to workbench. On the right corner you can see a Java button and another button in its left. Click on it and select “Other”.

When you click other, it opens Perspective and gives you several options. Select Perl and click Ok.

There you go. You have both Perl and Java environment. At any time you can go back to either of them by selecting the respective environment.

Hope it was helpful. Comments, feedbacks and suggestions are welcomed. Enjoy :)

How to know which network adapter I’m using?

To know the manufacturer of the network adapter of your computer in Linux, type this command in terminal:

sudo lshw -C network

The output of the command may look something like this:

       *-network               
       description: Wireless interface
       product: BCM4313 802.11b/g/n Wireless LAN Controller
       vendor: Broadcom Corporation
       physical id: 0
       bus info: pci@0000:03:00.0
       logical name: wlan0
       version: 01
       serial: 70:f1:a1:c2:f2:e9
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless
       configuration: broadcast=yes driver=brcm80211 driverversion=2.6.38-8-generic firmware=N/A ip=172.17.4.253 latency=0 link=yes multicast=yes wireless=IEEE 802.11bgn
       resources: irq:17 memory:f0500000-f0503fff
  *-network
       description: Ethernet interface
       product: AR8152 v1.1 Fast Ethernet
       vendor: Atheros Communications
       physical id: 0
       bus info: pci@0000:04:00.0
       logical name: eth0
       version: c1
       serial: b8:ac:6f:67:11:46
       capacity: 100Mbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress vpd bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=atl1c driverversion=1.0.1.0-NAPI firmware=N/A latency=0 link=no multicast=yes port=twisted pair
       resources: irq:43 memory:f0400000-f043ffff ioport:2000(size=128)

Check the output closely. It gives information about both Wired and Wireless Network Adapter. No need to specify that one with Wireless Interface describes wireless adapter and one with Ethernet Interface describes Wired Network Adapter. As you can see in the output, I have Broadcom’s wireless adapter and Atheros Ethernet (wired) adapter.

Questions, suggestions and feedbacks are welcomed. If you liked the post then please acknowledge it by liking/voting/commenting on the post. Enjoy :)

How to measure the throughput of a network with ipmt Unix command

ipmt, for IP measurement tools, is a set of tools able to carry out performance measurements on IP networks at the transport layer. tcpmt and udpmt are network performance measurement tools at the transport layer (respectively TCP and UDP). Every second, they generate a throughput report.
By default, they transmit on the discard port of the destination station. This means that, for UDP, the measured throughput at the sender cannot be the effective transmitted throughput since UDP is not reliable.

How to use them :
# tcpmt [-p port] [-s pktsz] [-n pktnb] host
# udpmt [-p port] [-s pktsz] [-n pktnb] host

Where :
port is the destination port number (discard, by default).
pktsz is the size of sent packets (1024 bytes by default) This parameter is only significant in the UDP context.
pktnb is the packet number to send (by default, press Control-C to stop the transmission).
host is the destination address.
A report is generated every second

  • transmission time (in ms since 0h),
  • the number of sent packets during the time interval,
  • the total number of sent packets,
  • the measured throughput during the time interval in kbit/s,
  • the average throughput on the last ten seconds,
  • the average throughput since the beginning.

tcptarget and udptarget are two programs which measure the trhoughput at the destination. Thay can be launched with no argument and they display the port number on which they are listening. We must use the -p option of tcpmt/udpmt in order to specify a port. As soon as tcptarget/udptarget start to receive packets, they display a report every second. This report is easier to understand than the sender report but it is less detailed. It displays the reception time in seconds with a precision around the millisecond and the throughput in kbit/s.

If you want to measure the behavior of concurrent flows sent on the same target station, Tcp/udptarget are the perfect tools since the arrival times are computed on the same station. Thus you can easily compare the packet arrival times of the different flows without having to synchronize the sending stations.

How to manipulate the routing table in Unix

The routing table of a station can be modified or seen thanks to the route command. It may be used to add or remove entries in the table. The routing table can be displayed by “netstat -r” command (For more information on netstat command please follow: http://computerandu.wordpress.com/2011/03/03/how-to-use-netstat-a-unix-networking-command/).

1. Route command presentation:

route add|delete [-net|-host] []

command keywords signification :
add|delete : add will add an entry in the routing table , delete will remove one ;
-net|-host : -net allows to specify an entry towards a network, -host allows to specify an entry towards a host ;
destination : The destination can be a host station address or a network address followed by the subnet mask length, /20 ; The destination may also be the keyword default. In this case, the packet will be sent to the matching router if the destination network address is not specified in the routing table ;
gateway : the router address which relays the packets from one network to another;
netmask : the subnet mask of the destination network.

2. Add a path in a routing table: Use the add option, and specify in the following order : the -net option if you need to enter a network route or -host if it is a host route, the destination IP address (network or station) and the destination internet address (network or station) and the IP address of the router that will relay the traffic. For instance :
# route add -net 192.168.0 192.168.1.2
add net 192.168.0: gateway 192.168.1.2
will add a path in the routing table : to reach the network 192.168.0/24, you must go through the 192.168.1.2 router.

3. Remove an entry in the routing table: Use the delete option and specify host or network options like in the addition process. For instance :
# route delete -net 192.168.0/24
will remove the previous entry added in the routing table.

4. Delete all the routing table entries: The flush command will remove all the entries added with the add command. If you use this command remotely, it may suspend all your current communications with this router and make this station unreachable.

Remark : do not remove the loopback entry, 127.0.0.1 or localhost, which enables the application to communicate localy.

How to use netstat : A Unix networking command

This command displays the different data structure contents linked to the station network configuration. Here we will only talk about two ways to use netstat, but there are many other information that we can get (sockets status, routing table, multicast ).

Network interface statistics: Use the option -I (interface), and specifythe interface name to observe (em0 for instance), and the option -w 1 to display a report every second. If you do not specify this last option, netstat will only give one report in a different style. We can also specify the option -d.

Theses reports include the following information :
(fxp0) : network interface name.
packets : the received/transmitted packets with no errors ;
errs : the received/transmitted packets with errors ;
bytes : The number of received/transmitted bytes ;
colls : the collisions number ;
drops : the dropped packet numbers (with -d).

For instance :
# netstat -w 1 -I fxp0 -d will display a report of the fxp0 interface every second. We get :

Routing table display: Specify the -r option (routing table). It can be also interesting to specify the -n option and -f inet, to disable the name resolution and only list IPv4 information (use inet6 to display the IPv6 table).

Various fields signification (for a thorough explanation, use man) :
Destination : the destination network of host address ;
Gateway : the router address, the local link or the remote interface address on thelink ;
Flags :
U : Indicates route is ”up” ;
G : Route is to a gateway ;
S : Static route (manual addition) ;
H : Route is to a host and not a network ;
D : Route was created dynamically by a redirect ;
Refs : The ref field gives the current number of active uses of the route ;
Use : The use field provides a count of the number of packets sent using that route. ;
Netif : The interface entry indicates the network interface utilized for the route ;
Expire : The Expire entry is the result of FreeBSD’s unfortunate co-mingling network layer routing information with layer 2 ARP information. The only entries with ”Expire” values are actually ARP entries.

 

Sources: INPG Prof. Olivier

Java code for GUI of a chat program

I worked on the GUI of a chat program in Java. I would like to share the experience as well as codes of my program. The code which I am going to share is a stand alone GUI i.e. its not a complete chat program but just the windows without any connectivity. (I’ll also upload the running version of the complete program sometime later).

It consists of three classes, LogInWindow, ConnectWindow, ChatWindow. The features of these classes are as following:

LogInWindow:

It consists the main and the whole code is run by this class. When it runs for the first time it automatically calls ConnectWindow so that user can provide detail about itself like its name, nick name, port number etc. There are (in this example predefined) a no. of users as buttons. Clicking on a user (Buttons) opens a ChatWindow. When you exit the LogInWindow the whole program exits. The window is named “WeChat”. There are two menu option in menu bar. One is to change status and one is to connect and terminate the chat. Various Status option are:

  • Available
  • Do Not Disturb
  • Away
  • Invisible

Connexion consists of two option: Connect and Terminate. Clicking on Connect allows the user to put info about itself in the ConnectWindow (If user has already done it then it shows the previous entries). Terminate deletes all the previous info about the user.

ConnectWindow:

It allows user to put info about itself. Already discussed in LogInWindow.

User can put the following information:

  • First Name
  • Last Name
  • Nick Name
  • Display Name
  • Status Message
  • Port Number

Pressing Ok Button enters these information. Clicking on cancel simply disposes the window

ChatWindow:

Chat Window class provides different facilities for interacting with other user. It has a text field where user can enter chat. All the text is shown in a text area. There are some buttons for Voice and Video Calls as well. The chat transcript can be saved easily by clicking the save button. Closing the chat window disposes it. And it also gives calls a function while closing the chat window (So that it can be used to pass info about the closing the chat window to some other class/module, if needed).


P.S. You can find the codes here (All the code are in word file. You can copy paste these codes in txt file): GUI Code