CPS 4931 PLTL Workshops

infestationwatchSoftware and s/w Development

Oct 28, 2013 (4 years and 15 days ago)

99 views

CPS 4931 PLTL Workshops

Workshop
3


Fall 2011

Exercise 1:

a. In your textbook do problems:

4.3





4.10






Exercise
2
:

a. Using the Socket API for DatagramSocket and the writeup Example 2 code (Figures 4.10, 4.11, &
4.12) Each student should download
three java files from


ftp://eve.kean.edu/pub/stewart/cps4931

to their mydocuments directory.

Both students need a copy of the MyDatagramSocket code to their /CPS4931 directory on eve..

Ha
ve one person copy the senderReceiver to their eve /CPS4931 directory..

Have another person on a different machine copy the receiverSender to eve in /CPS4931 directory .

b. On
each

machine SSH to eve and compile the
two

.java files on each machine.

T
hen on one machine, start Example2ReceiverSender first, then on the other machine start
Example2SenderReceiver second, using the following commands:


java Example2ReceiverSender eve.kean.edu 20000 10000 studentname1

java Example2SenderRecei
ver eve.kean.edu 20000 10000 studentname2


Describe the outcome. Be clear what is on each terminal window.



Describe
how

it is happening.



Why

are the two port numbers different?

Try it with all port numbers as 20000.
Why

does this
not

work?



c. On one machine boot up in Fedora. On that machine, start a local terminal on your PC (not SSH to
eve).


ls


to see where you are.


cd


CPS4931 directory where you have the java files from above.

Copy the 2
java

files
from that /CPS4931 directory to the local machine’s /tmp directory. (Every
Fedora PC has a /tmp directory on that PC). Then


cd /tmp


ls


should show you these 2 files are in your /tmp directory

Then compile the E
xample2SenderReceiver.java and the MyDatagramSocket.java on your local
machine (from the /tmp directory)


In order to run the processes on different machines, one on your machine and one on eve,

First find out the domain name of the localhost PC using t
he command

uname


a


Then read the comments in the code to know where to put which address in the command line. What
do the two
command lines

have to look like?


If nothing works, try reversing the Example2ReceiverSender to eve, and the Example2Sende
rReceiver
to the other machine.

Do the port numbers still need to be different? Try it once with both ports the same 20000 port. What
happens? Why is this different from the first time?

If nothing works, how can you change the code to at least finish more

smoothly?

Then run the two processes on the separate machines both in Fedora. Describe the outcome.


d. Discuss :

1. Why is the order of the execution of the two processes important? What happens if you
execute the SenderReceiver first?


2. How would you
have to change the code so that the ReceiverSender on eve.kean.edu could
be run without knowing which machine the SenderReceiver was on?

(such that the command line arguments on the ReceiverSender does NOT contain the address of the
other SenderReceiver ma
chine)


3. Why does the MyDatagramSocket have to be compiled on both your machine and eve?
Read MyDatagramSocket. How would the MyDatagramSocket.java have to be changed in discussion 2
above?


When
Working in Fedora
:

1. You are on a PC which has network a

DomainName like
CPS22205

All hosts on the network have the same name
to themselves

which is called
localhost

2. You are running the linux operating system which is very similar to Unix but not identical. This is
why you should compile code on the linux
machine if you are going to run it on the linux machine.

3. In a terminal on your PC you have access to the local directories, such as /tmp as well as the
networked mapped directories on eve.kean.edu which you know as your home directory. When you
are in
a local terminal screen you can see both local directories, such as /tmp, and network mapped
directories on eve.

Your home directory which is /home/student/
username

is your default directory.

So when you compile and run on the local machine you want the f
iles on the local /tmp directory. So
/tmp is where you will copy the files that you are going to compile or run on the local PC

4. In order to compile and execute on eve, you must ssh to eve in the terminal screen.

When you are in eve you can only see fi
les in your home directories below you, like

/home/student/
username
/CPS4931 so this is where you will have your .java and .class files for running
programs on eve.


Exercise 3
:

a. Comparing connection oriented to connectionless protocols:

If a message i
s 16K long, and each packet is 1 K message and 128 bytes for addresses and 8 bytes for
checksums 8 bytes for circuit number, and 8 bytes for packet number; and connection needs 10 mills,
how fast must the average data transfer rate be for traffic on connec
tionless to be better choice than
connection oriented.

Exercise
4
:

a. In Pairs, Read the code of your application, until you discover which java’s invoke which jsp’s and
visa versa. Be sure to get them all, including the ones you
will be

modifying.


For
Example:

Control.java begins


It calls Shared
.java


It transfers control to Login.jsp thru gotoPage (dispatcher)

Login.jsp


It calls Shared
.java


It transfers control to Login.java thru the form action

Login.java


It calls login method



It calls DBI.java
to check the userid and password



It cal
ls the DBI.java to get the employeeI
nfo

If userid and password are ok it transfers to mainPage.java (thru dispatcher)


Else transfers control back to Login.jsp(thru dispatcher)

What about all of the others servlets
and jsp’s?

Complete the chart above
.