代写 Unencrypted P2P Instant Messenger程序、代写python P2P英文作业、代写C网络编程作业


1 A Simple, Unencrypted P2P Instant Messenger {30 points}
To introduce you to network programming, you will build a simple unencrypted instant messenger.
The program reads from standard input and sends input messages to another instance of the
program running on a different machine; received messages are sent to standard output. alice-HW1
Today was good
Today was fun
Tomorrow is another one.
From there to here
From here to there
Funny things are everywhere.
bob-HW1
Today was good
Today was fun
Tomorrow is another one.
From there to here
From here to there
Funny things are everywhere.
Figure 1: An example conversation between two nodes, as seen by each of the two nodes. Red text is entered
by the user at machine alice-HW1 and blue text is entered by the user at bob-HW1.
Figure 1 shows a conversation between instances of the IM client running on two machines, alice-HW1
and bob-HW1.
Your IM client should use TCP to send messages between hosts. Your program should run between
machines alice-HW1 and bob-HW1. That is, you will each have two dedicated machines to use for
this project.
?Last revised on August 27, 2018.
1
Program description. Your program should read from standard input and send all input data
to the other instance of your application (running on the other host), via TCP/IP over port 9999.
Here’s the tricky bit: Received messages should be immediately written to standard output. To do
this, you will need to use the select call to block and wait for input either on standard input or the
network socket. As an alternative to using select, you may use multiple threads, although this is
far less efficient.
Your program should be called UnencryptedIM (or UnencryptedIM.ext where ext ∈ {.py, .c}).
Your program should have the following command-line options:
UnencryptedIM -s|-c hostname
where the -s argument indicates that the program should wait for an incoming TCP/IP connection
on port 9999; the -c argument (with its required hostname parameter) indicates that the program
should connect to the machine hostname (over TCP/IP on port 9999).
For example, you may run “UnencryptedIM -s” on alice-HW1, and then start
“UnencryptedIM -c alice-HW1” on bob-HW1. Note that the instance with the -s option must
be started before the other instance.
Additional requirements and hints. Please make sure that your program conforms to the
following:
? You may write your program in Python or C (Python is strongly encouraged). Please contact
the teaching staff if you would like to use another programming language. For submissions
done in a compiled language (e.g., C), we will ignore all submitted executables (or byte code)
and will compile your code from the submitted source files.
? Twenty-four hours after the due date, we will disseminate our solutions to the homework
written in Python (maybe C). These solutions may be used to complete future parts of HW1.
? You may only use libraries already installed in the standard Ubuntu 16.04 VCL image.
? You may not collaborate on this homework. This project should be done individually. You
may search the Internet for help, but you may not copy (either via copy-and-paste or manual
typing) code from another source. You may use code from the textbook, or from the
instructor or TAs.
? To aid in automated testing/grading, do not provide a prompt to the user, and only write
received messages to standard out. (Text entered into standard input can also be shown; see
Figure 1.) We will be using automated testing tools to evaluate your solutions, and printing
additional messages or characters makes such automation far more difficult.
? Your program should not take in any additional command-line options other than the -s or
-c hostname options described above.
2
? It is OK if messages are only sent after the user presses [ENTER] after entering a line of text.
However, incoming messages should be displayed immediately after they are received by the
kernel.
? Your program can terminate either when the user presses CTRL-C, or when end-of-file (EOF)
is received. To generate EOF from the terminal, press CTRL-D.
? Hint: To stress test your code, try using your program to copy a file between machines. You
should be able to do this by redirecting standard input (at one end) and standard output (at
the other).
In part II of this homework (assigned shortly after the due date!), we will add a layer of encryption
to our IM applications.
Grading
This portion of HW1 is worth 35 points. A non-comprehensive list of deductions is provided in
Table 1.
We will award partial credit when possible and appropriate. To maximize opportunities for partial
credit, please rigorously comment your code. If we cannot understand what you intended, we
cannot award partial credit.
Description Deduction
Only included executables (no source code; applies to C) 30
Compilation / interpreter errors 20
Compiles, but IMs are neither successfully transmitted nor received 17
Compiles, but IMs are either only transmitted or only received 14
Received messages only appear after user presses [ENTER] (indicates that
select is used improperly)
10
General instability (e.g., occasional segfaults) 10
Run-time error (e.g., crash) on large input 7
Non-conformant command-line options (hinders automated testing) 5
No compilation instructions provided (applies to C) 5
Includes unnecessary prompts (hinders automated testing) 3
Table 1: Grading rubric. Note that this grading rubric is not intended to be comprehensive.
Submission Instructions
Submit your solution as a single tarball (tar.gz archive) using WolfWare (Moodle). To upload your
assignment, navigate to the CSC474 course. Use the “Homework 1, Part I” assignment.
3
Include in the archive all source code, using the naming conventions described in this assignment.
If your program is written in C, please also provide compilation instructions.
Please post questions (especially requests for clarification) about this homework to Piazza.
Using VCL
We will behttp://www.buy768.com using NC State University’s Virtual Computing Lab (VCL) computing infrastructure
for several homework assignments throughout the semester. The VCL Web page (https://vcl.
ncsu.edu) has detailed instructions for getting started with VCL. You may also be familiar with
VCL from other courses at NCSU. Below are quick instructions for using VCL for this assignment.
Important: Your assignment will be graded on VCL so you should make sure to test your code
on VCL. If your code does not work in VCL, you may not receive credit (even if it works on your
machine).
1. Direct your Web browser to https://vcl.ncsu.edu.
2. Click on “Reservations” on the left, under “Reservation System.” If necessary, log via Shibboleth.
If this is your first time using VCL, you may also be asked if VCL can receive your
account details.
3. Click the “New Reservation” button. If this button does not appear after logging in, click on
“Reservations” on the left again.
4. In the dialog box, select “Ubuntu 16.04 LTS Base” as the environment from the drop-down
box. Set the reservation duration to an appropriate length. Click “Create Reservation”
Note: Storing your work in your AFS directory (e.g., /afs/unity.ncsu.edu/users/b/bgreaves/)
will allow you to only require the reservation while working on the project.
5. Once the reservation is created, click the “Connect!” button. The dialog box will give you
IP address and login information.
6. Use SSH to connect to the remote computer. If you use Linux or Mac OS X, you can do
this directly from the built in terminal. If you use Windows, Putty (http://www.chiark.
greenend.org.uk/~sgtatham/putty/)http://www.6daixie.com/contents/19/1687.html  is highly recommended. Note that malware has recently
pretended to be PuTTY, so only get it from official sources.
Note: You are encouraged to explore the use of SSH public key authentication. The connect
dialog box in VCL has a link for more information.
7. Repeat the process for both the alice-HW1 and bob-HW1 machines. Take note of the IP
addresses of the two machines. You will need to use these IP addresses on the command line
instead of the machine names specified in the homework instructions above.
8. Save your data! Make sure your code is somewhere safe before the reservation is deleted.
You have been warned!
4
Note: If you SSH to remote-linux.eos.ncsu.edu, your AFS directory is your home directory
(run pwd). You can ensure your code and data are there.
9. In the VCL Web interface, click “Delete Reservation” when you are finished, or let the
reservation time out.

因为专业,所以值得信赖。如有需要,请加QQ99515681 或邮箱:[email protected] 

微信:codinghelp

猜你喜欢

转载自www.cnblogs.com/javaprogram/p/9575078.html