首页 > > 详细

Writing Socket? ?Programming? ?Project Homework ,C/C++ Programming Help,Help C/C++ Programming

EE450​ ​Socket​ ​Programming​ ​Project,​ ​Fall​ ​​ ​2017
Due​ ​Date​ ​:​ ​​ ​Thursday​ ​Nov​ ​16th,​ ​2017​ ​11:59​ ​PM​ ​(Midnight)
(The​ ​deadline​ ​is​ ​the​ ​same​ ​for​ ​all​ ​on-campus​ ​and​ ​DEN​ ​off-campus
students)
Hard​ ​Deadline​ ​(Strictly​ ​enforced)
The objective of this assignment is to familiarize you with UNIXsocket programming. This
assignment isworth​10%​of youroverallgradeinthiscourse. ​Itisanindividualassignment
and no collaborations are allowed. Any cheatingwill result inanautomatic Finthe
course​ ​(not​ ​just​ ​in​ ​the​ ​assignment).
If you have any doubts/questions, post your questions on Piazza. ​Youmustdiscussall
projectrelatedissuesonPiazza​. Wewillgivethosewhoactivelyhelpothersoutby
answering​ ​questions​ ​on​ ​Piazza​ ​up​ ​to​ ​10​ ​bonus​ ​points.

Problem​ ​Statement:
In​mathematics​, a​TaylorSeries​isarepresentationofa​functionasan​infinitesumof
termsthatarecalculatedfromthevaluesofthefunction's​derivativesatasinglepoint.
TheTaylorSeriesof isgivenby . TheTaylorSeriesof is 11−x 11−x = ∑∞
n=0
xn og(1 )l −x
given​ ​by​ ​ .​ ​In​ ​both​ ​cases,​ ​the​ ​series​ ​converge​ ​when​ ​ .og(1 )l −x =−∑∞
n=1 n
xn x| |​ ​

where​​cantakeavaluefrom​{DIV,LOG}​and​​willbeapositive
floatingpointnumberintherangeof(0,1).Asanexample,tofindthelog(0.8)using
Taylor’sexpansionuptothe6thorder(asdescribedintheproblemstatement), the
client​ ​should​ ​be​ ​run​ ​as​ ​follows:

./client​ ​LOG​ ​0.8


Afterbootingup,theclientestablishesaTCPconnectionwithAWS.Aftersuccessfully
establishingtheconnection,theclientfirstsendsthe​toAWS.
Oncethisissent,theclientshouldprintamessageintheformatgiveninthetable.This
ends​ ​Phase​ ​1A​ ​and​ ​we​ ​now​ ​proceed​ ​to​ ​Phase​ ​2.

Phase​ ​2:​ ​(75​ ​points)

In​ ​Phase​ ​1A,​ ​you​ ​read​ ​the​ ​function​ ​and​ ​input​ ​value​ ​and​ ​sent​ ​them​ ​to​ ​the​ ​AWS​ ​server​ ​over​ ​a
TCP​ ​connection.​ ​Now​ ​in​ ​phase​ ​2,​ ​this​ ​AWS​ ​server​ ​will​ ​send​ ​the​ ​value​ ​to​ ​the​ ​3​ ​back-servers.
The​ ​value​ ​will​ ​be​ ​sent​ ​to​ ​their​ ​respective​ ​back-end​ ​server​ ​depending​ ​on​ ​the​ ​power​ ​to​ ​be
calculated.

The​ ​communication​ ​between​ ​the​ ​AWS​ ​server​ ​and​ ​the​ ​back-servers​ ​happens​ ​over​ ​UDP.​ ​The
AWS​ ​server​ ​will​ ​send​ ​the​ ​​ ​to​ ​the​ ​server.​ ​The​ ​port​ ​numbers​ ​used​ ​by​ ​back-servers​ ​A,​ ​B
and​ ​C​ ​are​ ​specified​ ​in​ ​table​ ​2.​ ​Since​ ​all​ ​the​ ​servers​ ​will​ ​run​ ​on​ ​the​ ​same​ ​machine​ ​in​ ​our​ ​project,
all​ ​have​ ​the​ ​same​ ​IP​ ​address​ ​(the​ ​IP​ ​address​ ​of​ ​localhost​ ​is​ ​usually​ ​​ ​127.0.0.1).
The​ ​back-end​ ​servers​ ​are​ ​in​ ​charge​ ​to​ ​perform​ ​the​ ​operations​ ​ ,​ ​where​ ​n​ ​is​ ​thex) , x) and (x) ( 2 ( 3 5
input​ ​value,​ ​for​ ​servers​ ​A,​ ​B​ ​and​ ​C,​ ​respectively.​ ​This​ ​implies​ ​that​ ​the​ ​backend-servers​ ​are​ ​only
allowed​ ​to​ ​perform​ ​exponential​ ​operation​ ​and​ ​not​ ​any​ ​other​ ​operations​ ​such​ ​as​ ​sum,​ ​subtraction
or​ ​division.

Note​ ​that​ ​the​ ​Taylor​ ​series​ ​sum​ ​for​ ​​ ​that​ ​we​ ​obtained​ ​from​ ​the​ ​client​ ​will​ ​be​ ​performed
in​ ​the​ ​AWS​ ​server​ ​after​ ​obtaining​ ​all​ ​the​ ​powers​ ​of​ ​the​ ​​ ​value.​ ​The​ ​Taylor​ ​expansion
equation​ ​used​ ​for​ ​each​ ​operation​ ​is​ ​detailed​ ​in​ ​Table​ ​1:

Table​ ​1.​ ​Taylor​ ​Expansion​ ​Equations​ ​for​ ​AWS​ ​Server
Function Taylor Expansion for function with value x
DIV 1 x x x 11−x = + + 2+x3+ 4+x5 +x6
LOG log(1 )−x = −x − 2 x2 − 3 x3 − 4 x4 − 5 x5 − 6 x6

Each​ ​back-server​ ​will​ ​perform​ ​their​ ​respective​ ​exponential​ ​operation​ ​and​ ​then​ ​return​ ​their​ ​result
to​ ​AWS​ ​(server​ ​D)​ ​using​ ​UDP.​ ​​ ​AWS​ ​is​ ​the​ ​only​ ​server​ ​where​ ​it​ ​is​ ​allowed​ ​to​ ​perform​ ​sum,
subtraction​ ​and​ ​division​ ​operations,​ ​thus​ ​this​ ​is​ ​where​ ​the​ ​Taylor​ ​Expansion​ ​formulas​ ​are
employed.
Finally,​ ​for​ ​this​ ​phase,​ ​keep​ ​in​ ​mind​ ​that​ ​to​ ​calculate​ ​the​ ​ and​ ​ ​ ​factors​ ​needed​ ​for​ ​thex 4 x 6
formula,​ ​you​ ​will​ ​have​ ​to​ ​reuse​ ​servers​ ​A​ ​and​ ​B​ ​(the​ ​one​ ​in​ ​charge​ ​of​ ​the​ ​power​ ​of​ ​2​ ​and​ ​power
of​ ​3​ ​operations,​ ​respectively)​ ​by​ ​sending​ ​the​ ​previous​ ​ ​ ​obtained​ ​before.​ ​In​ ​other​ ​words,​ ​youx 2

will​ ​have​ ​to​ ​request​ ​to​ ​calculate​ ​two​ ​times​ ​for​ ​server​ ​A​ ​(for​ ​ , ),​ ​two​ ​times​ ​for​ ​server​ ​B​ ​(for​ ​ , x2 x4 x3
)​ ​and​ ​one​ ​time​ ​for​ ​server​ ​C​ ​( ). x6 x5

Phase​ ​1B:​​ ​(​25​ ​points​ ​for​ ​part​ ​A​ ​and​ ​B​)
At​ ​the​ ​end​ ​of​ ​Phase​ ​2,​ ​all​ ​backend-servers​ ​have​ ​their​ ​answers​ ​ready​ ​and​ ​these​ ​answer​ ​are
located​ ​now​ ​at​ ​server​ ​AWS.​ ​Let’s​ ​call​ ​the​ ​value​ ​calculate​ ​using​ ​the​ ​Taylor​ ​Expansion​ ​formula​ ​as
R.​ ​This​ ​is​ ​to​ ​be​ ​sent​ ​from​ ​the​ ​​ ​AWS​ ​server​ ​to​ ​the​ ​client​ ​using​ ​TCP.​ ​Also,​ ​AWS​ ​should​ ​send​ ​a​ ​list
with​ ​all​ ​the​ ​partially​ ​obtained​ ​values​ ​(the​ ​powers​ ​of​ ​x).​ ​The​ ​format​ ​on​ ​how​ ​to​ ​deliver​ ​the​ ​final
solution​ ​and​ ​the​ ​powers​ ​of​ ​x​ ​are​ ​explained​ ​in​ ​the​ ​example​ ​outputs​ ​below.

The​ ​ports​ ​to​ ​be​ ​used​ ​by​ ​the​ ​clients​ ​and​ ​the​ ​servers​ ​for​ ​the​ ​exercise​ ​are​ ​specified​ ​in​ ​the​ ​following
table:

Table​ ​3.​ ​Static​ ​and​ ​Dynamic​ ​assignments​ ​for​ ​TCP​ ​and​ ​UDP​ ​ports.
Process Dynamic
Ports
Static​ ​Ports
Backend-Server​ ​(A) - 1​ ​UDP,​ ​21000+xxx​ ​(last​ ​three​ ​digits​ ​of​ ​your​ ​USC​ ​ID)
Backend-Server​ ​(B) - 1​ ​UDP,​ ​22000+xxx​ ​(last​ ​three​ ​digits​ ​of​ ​your​ ​USC​ ​ID)
Backend-Server​ ​(C) - 1​ ​UDP,​ ​23000+xxx​ ​(last​ ​three​ ​digits​ ​of​ ​your​ ​USC​ ​ID)
AWS​ ​(D) - 1​ ​UDP,​ ​24000+xxx​ ​(last​ ​three​ ​digits​ ​of​ ​your​ ​USC​ ​ID) 1​ ​TCP,​ ​25000+xxx​ ​(last​ ​three​ ​digits​ ​of​ ​your​ ​USC​ ​ID)
Client 1​ ​TCP

NOTE​: Forexample,ifthelast3digitsofyourUSCIDare“319”,youshouldusethe
port:​ ​​21000+319​ ​=​ ​21319​ ​​for​ ​the​ ​Backend-Server​ ​(A).​ ​​It​ ​is​ ​NOT​ ​going​ ​to​ ​be​ ​21000319.

ON​ ​SCREEN​ ​MESSAGES:
Table​ ​4.​ ​​Backend-Server​ ​A​ ​(Square​ ​Server)​​ ​on​ ​screen​ ​messages
Event On​ ​Screen​ ​Message​ ​(inside​ ​quotes)
Booting​ ​Up​ ​(Only​ ​while​ ​starting): “The​ ​Server​ ​A​ ​is​ ​up​ ​and​ ​running​ ​using​ ​UDP​ ​on​ ​port​ ​.”
Upon​ ​Receiving​ ​the​ ​number: “The​ ​Server​ ​A​ ​received​ ​input​ ​”
After​ ​calculating​ ​the​ ​its​ ​square: “The​ ​Server​ ​A​ ​calculated​ ​square:​ ​​”

After​ ​sending​ ​the​ ​reduction​ ​value​ ​to
the​ ​AWS​ ​server​ ​(D):
“The​ ​Server​ ​A​ ​finished​ ​sending​ ​the​ ​output​ ​to​ ​AWS”


ON​ ​SCREEN​ ​MESSAGES:
Table​ ​5.​ ​​Backend-Server​ ​B​ ​(Cube​ ​Server)​ ​​on​ ​screen​ ​messages
Event On​ ​Screen​ ​Message​ ​(inside​ ​quotes)
Booting​ ​Up​ ​(Only​ ​while​ ​starting): “The​ ​Server​ ​B​ ​is​ ​up​ ​and​ ​running​ ​using​ ​UDP​ ​on​ ​port​ ​.”
Upon​ ​Receiving​ ​the​ ​number: “The​ ​Server​ ​B​ ​received​ ​input​ ​”
After​ ​calculating​ ​the​ ​its​ ​cube: “The​ ​Server​ ​B​ ​calculated​ ​cube:​ ​​”
After​ ​sending​ ​the​ ​reduction​ ​value​ ​to
the​ ​AWS​ ​server​ ​(D):
“The​ ​Server​ ​B​ ​finished​ ​sending​ ​the​ ​output​ ​to​ ​AWS”


ON​ ​SCREEN​ ​MESSAGES:
Table​ ​6.​ ​​Backend-Server​ ​C​ ​(5th​ ​power​ ​server)​ ​​on​ ​screen​ ​messages
Event On​ ​Screen​ ​Message​ ​(inside​ ​quotes)
Booting​ ​Up​ ​(Only​ ​while​ ​starting): “The​ ​Server​ ​C​ ​is​ ​up​ ​and​ ​running​ ​using​ ​UDP​ ​on​ ​port​ ​.”
Upon​ ​Receiving​ ​the​ ​number: “The​ ​Server​ ​C​ ​received​ ​input​ ​”
After​ ​calculating​ ​the​ ​its​ ​5th​ ​power: “The​ ​Server​ ​C​ ​calculated​ ​5th​ ​power:​ ​​”
After​ ​sending​ ​the​ ​reduction​ ​value​ ​to
the​ ​AWS​ ​server​ ​(D):
“The​ ​Server​ ​C​ ​finished​ ​sending​ ​the​ ​output​ ​to​ ​AWS”


ON​ ​SCREEN​ ​MESSAGES:
Table​ ​7.​ ​​AWS​ ​(D)​ ​​on​ ​screen​ ​messages
Event On​ ​Screen​ ​Message​ ​(inside​ ​quotes)
Booting​ ​Up​ ​(only​ ​while​ ​starting): “The​ ​AWS​ ​is​ ​up​ ​and​ ​running.”
Upon​ ​Receiving​ ​the​ ​number​ ​and
function​ ​from​ ​the​ ​client:
“The​ ​AWS​ ​received​ ​​ ​and​ ​function=​ ​​ ​from​ ​the​ ​client
using​ ​TCP​ ​over​ ​port​ ​”

After​ ​sending​ ​subset​ ​of​ ​numbers
to​ ​Backend-Server​ ​(i):
i​ ​is​ ​one​ ​of​ ​A,​ ​B,​ ​or​ ​C
“The​ ​AWS​ ​sent​ ​​ ​to​ ​Backend-Server​ ​”
After​ ​receiving​ ​result​ ​from
backend​ ​server​ ​i):​ ​i​ ​is​ ​one​ ​of​ ​A,​ ​B,
or​ ​C
“The​ ​AWS​ ​received​ ​​ ​Backend-Server​ ​​ ​using​ ​UDP​ ​over
port​ ​​”
After​ ​all​ ​values​ ​are​ ​received “Values​ ​of​ ​powers​ ​received​ ​by​ ​AWS:​ ​[INPUT^1,​ ​INPUT^2,​ ​INPUT^3,
INPUT^4,​ ​INPUT^5,​ ​INPUT^6]”
After​ ​function​ ​calculation​ ​by
AWS:
“AWS​ ​calculated​ ​​ ​on​ ​:​ ​”
After​ ​sending​ ​the​ ​calculated
value​ ​to​ ​the​ ​client:
“The​ ​AWS​ ​sent​ ​​ ​to​ ​client.”


ON​ ​SCREEN​ ​MESSAGES:
Table​ ​8.​ ​​Client​ ​​on​ ​screen​ ​messages
Event On​ ​Screen​ ​Message​ ​(inside​ ​quotes)
Booting​ ​Up: “The​ ​client​ ​is​ ​up​ ​and​ ​running.”
Upon​ ​sending​ ​the​ ​input​ ​and
function​ ​to​ ​AWS
"The​ ​client​ ​sent​ ​​ ​and​ ​​ ​to​ ​AWS.”
After​ ​receiving​ ​the​ ​reduction:
output​ ​from​ ​AWS
“According​ ​to​ ​AWS​ ​​ ​on​ ​:​ ​​”


Example​ ​Output:

Backend-Server​ ​A​ ​(Square​ ​server)​ ​Terminal:
The​ ​Server​ ​A​ ​is​ ​up​ ​and​ ​running​ ​using​ ​UDP​ ​on​ ​port​ ​21319. 
The​ ​Server​ ​A​ ​received​ ​input​ ​ 
The​ ​Server​ ​A​ ​calculated​ ​square:​ ​ 
The​ ​Server​ ​A​ ​finished​ ​sending​ ​the​ ​output​ ​to​ ​AWS 
The​ ​Server​ ​A​ ​received​ ​input​ ​ 
The​ ​Server​ ​A​ ​calculated​ ​square:​ ​ 
The​ ​Server​ ​A​ ​finished​ ​sending​ ​the​ ​output​ ​to​ ​AWS 
 

Backend-Server​ ​B​ ​(Cube​ ​server)​ ​Terminal: 
The​ ​Server​ ​B​ ​is​ ​up​ ​and​ ​running​ ​using​ ​UDP​ ​on​ ​port​ ​22319. 
The​ ​Server​ ​B​ ​received​ ​input​ ​ 
The​ ​Server​ ​B​ ​calculated​ ​cube:​ ​ 
The​ ​Server​ ​B​ ​finished​ ​sending​ ​the​ ​output​ ​to​ ​AWS 
The​ ​Server​ ​B​ ​received​ ​input​ ​ 
The​ ​Server​ ​B​ ​calculated​ ​cube:​ ​ 
The​ ​Server​ ​B​ ​finished​ ​sending​ ​the​ ​output​ ​to​ ​AWS 
 
Backend-Server​ ​C​ ​(5th​ ​Power​ ​server)​ ​Terminal: 
The​ ​Server​ ​C​ ​is​ ​up​ ​and​ ​running​ ​using​ ​UDP​ ​on​ ​port​ ​23319. 
The​ ​Server​ ​C​ ​received​ ​input​ ​ 
The​ ​Server​ ​C​ ​calculated​ ​5th​ ​power:​ ​ 
The​ ​Server​ ​C​ ​finished​ ​sending​ ​the​ ​output​ ​to​ ​AWS 
 
AWS​ ​Terminal: 
The​ ​AWS​ ​is​ ​up​ ​and​ ​running. 
TheAWSreceivedinputandfunction=LOGfromtheclientusingTCPover                             
port​ ​21319 
​ ​to​ ​Backend-Server​ ​A 
The​ ​AWS​ ​sent​ ​​ ​to​ ​Backend-Server​ ​B 
The​ ​AWS​ ​sent​ ​​ ​to​ ​Backend-Server​ ​C 
The​ ​AWS​ ​received​ ​​ ​Backend-Server​ ​​ ​using​ ​UDP​ ​over​ ​port​ ​ 
The​ ​AWS​ ​received​ ​​ ​Backend-Server​ ​​ ​using​ ​UDP​ ​over​ ​port​ ​ 
The​ ​AWS​ ​received​ ​​ ​Backend-Server​ ​​ ​using​ ​UDP​ ​over​ ​port​ ​ 
The​ ​AWS​ ​sent​ ​​ ​to​ ​Backend-Server​ ​A 
The​ ​AWS​ ​sent​ ​​ ​to​ ​Backend-Server​ ​B 
The​ ​AWS​ ​received​ ​​ ​Backend-Server​ ​​ ​using​ ​UDP​ ​over​ ​port​ ​ 
The​ ​AWS​ ​received​ ​​ ​Backend-Server​ ​​ ​using​ ​UDP​ ​over​ ​port​ ​ 
Values​ ​of​ ​powers​ ​received​ ​by​ ​AWS:​ ​ 
AWS​ ​calculated​ ​LOG​ ​on​ ​:​ ​ 
The​ ​AWS​ ​sent​ ​​ ​to​ ​client 
 
Client​ ​Terminal:
The​ ​client​ ​is​ ​up​ ​and​ ​running. 
The​ ​client​ ​sent​ ​​ ​and​ ​LOG​ ​to​ ​AWS 
According​ ​to​ ​AWS,​ ​LOG​ ​on​ ​:​ ​ 





Assumptions:

1. You haveto start the processesin this order:​backend-server(A),
backend-server​ ​(B),​ ​backend-server​ ​(C),​ ​AWS​ ​(D),​ ​Client.

2. If youneedtohavemorecodefilesthantheonesthatarementionedhere,
pleaseusemeaningfulnamesandallsmalllettersand​mentionthemallinyour
README​ ​file​.

3. YouareallowedtouseblocksofcodefromBeej’ssocketprogrammingtutorial
(Beej’sguidetonetworkprogramming)inyourproject.However,youneedto
mark​ ​the​ ​copied​ ​part​ ​in​ ​your​ ​code.

4. Whenyourunyourcode,if yougetthemessage“portalreadyinuse”or
“addressalreadyinuse”,​pleasefirstchecktoseeifyouhaveazombie
process(seefollowing).Ifyoudonothavesuchzombieprocessesorifyoustill
getthismessageafterterminatingallzombieprocesses,trychangingthestatic
UDPorTCPportnumbercorrespondingtothiserrormessage(allportnumbers
below1024arereservedandmustnotbeused).Ifyouhavetochangetheport
number,​ ​​please​ ​do​ ​mention​ ​it​ ​in​ ​your​ ​README​ ​file​ ​and​ ​provide​ ​reasons​ ​for​ ​it.

5. Youmaycreatezombieprocesseswhiletestingyourcodes,pleasemakesure
youkillthemeverytimeyouwanttorunyourcode.Toseealistofallzombie
processes,​ ​try​ ​this​ ​command:​ ​​ ​​ ​>>ps​ ​​ ​–aux​ ​​ ​|​ ​​ ​grep​ ​​ ​ee450
Identifythezombieprocessesandtheirprocessnumberandkillthembytyping
at​ ​the​ ​command-line:​​ ​​ ​​ ​​ ​​ ​​>>kill​ ​-9​ ​processNumber

Requirements:

1. DonothardcodetheTCPor UDPportnumbersthatareto beobtained
dynamically.​RefertoTable1toseewhichportsarestaticallydefinedandwhich
onesaredynamicallyassigned.Use​getsockname()​functionto retrievethe
locally-boundportnumberwhereverportsareassigneddynamicallyasshown
below:
/*Retrievethelocally-boundnameofthespecifiedsocketandstoreit inthe
sockaddr​ ​structure*/

Getsock_check=getsockname(TCP_Connect_Sock,(structsockaddr*)my_addr,
(socklen_t​ ​*)addrlen);
//Error​ ​checking
if​ ​(getsock_check==​ ​-1)​ ​{
perror("getsockname");
exit(1);
}

2. The​ ​host​ ​name​ ​must​ ​be​ ​hardcoded​ ​as​​ ​localhost​ ​(127.0.0.1)​​ ​in​ ​all​ ​codes.
3. Yourclientshouldterminateitselfafteralldone.Andtheclientcanrunmultiple
timestosendrequests.However,thebackendserversandtheAWSshouldkeep
berunningandbewaitingforanotherrequestuntiltheTAsterminatethemby
Ctrl+C.​ ​It​ ​they​ ​terminate​ ​before​ ​that,​ ​you​ ​will​ ​lose​ ​some​ ​points​ ​for​ ​it.
4. Allthenamingconventionsandtheon-screenmessagesmustconformtothe
previously​ ​mentioned​ ​rules.
5. Youarenotallowedtopassanyparameterorvalueorstringorcharacterasa
command-line​ ​argument​ ​except​ ​while​ ​running​ ​the​ ​client​ ​in​ ​Phase​ ​1.
6. Alltheon-screenmessagesmustconformexactlytotheprojectdescription.You
shouldnotaddanymoreon-screenmessages.If youneedtodosoforthe
debuggingpurposes,youmustcommentoutalloftheextramessagesbefore
you​ ​submit​ ​your​ ​project.
7. Usingfork()or similarsystemcallsarenotmandatoryif youdonotfeel
comfortable​ ​using​ ​them​ ​to​ ​create​ ​concurrent​ ​processes.
8. Pleasedoremembertoclosethesocketandteardowntheconnectiononceyou
are​ ​done​ ​using​ ​that​ ​socket.



Programming​ ​platform​ ​and​ ​environment:

1. All​ ​your​ ​submitted​ ​code​ ​​MUST​​ ​work​ ​well​ ​on​ ​the​ ​provided​ ​virtual​ ​machine​ ​Ubuntu.
2. AllsubmissionswillonlybegradedontheprovidedUbuntu.TAswon’tmakeany
updatesorchangestothevirtualmachine.It’syourresponsibilitytomakesure
yourcodeworkingwellontheprovidedUbuntu.“Itworkswellonmymachine”is
not​ ​an​ ​excuse​ ​and​ ​we​ ​don’t​ ​care.
3. YoursubmissionMUSThaveaMakefile.Pleasefollowtherequirementsinthe
following​ ​“”Submission​ ​Rules”​ ​section.



Programming​ ​languages​ ​and​ ​compilers:

YoumustuseonlyC/C++onUNIXaswellasUNIXSocketprogrammingcommands
andfunctions.HerearethepointersforBeej'sGuidetoCProgrammingandNetwork
Programming​ ​(socket​ ​programming):

http://www.beej.us/guide/bgnet/

(Ifyouarenewtosocketprogrammingpleasedostudythistutorialcarefullyassoonas
possible​ ​and​ ​before​ ​starting​ ​the​ ​project)

http://www.beej.us/guide/bgc/

Youcanuseaunixtexteditorlikeemacstotypeyourcodeandthenusecompilers
suchasg++(forC++)andgcc(forC)thatarealreadyinstalledonUbuntutocompile
yourcode.Youmustusethefollowingcommandsandswitchestocompileyourfile.cor
yourfile.cpp.​ ​It​ ​will​ ​make​ ​an​ ​executable​ ​by​ ​the​ ​name​ ​of​ ​"yourfileoutput”.

gcc​ ​-o​ ​​ ​yourfileoutput​ ​​ ​​ ​yourfile.c
g++​ ​-o​ ​​ ​yourfileoutput​ ​​ ​​ ​yourfile.cpp

Do​ ​NOT​ ​forget​ ​the​ ​mandatory​ ​naming​ ​conventions​ ​mentioned​ ​before!

Alsoinsideyourcodeyouneedtoincludetheseheaderfilesinadditiontoanyother
header​ ​file​ ​you​ ​think​ ​you​ ​may​ ​need:

#include​ ​
#include​ ​
#include​ ​
#include​ ​
#include​ ​
#include​ ​
#include​ ​
#include​ ​
#include​ ​
#include​ ​
#include​ ​




Submission​ ​Rules:

1. Alongwithyourcodefiles,includea ​READMEfileanda ​Makefile​. Inthe
README​ ​file​ ​write
a. Your​ ​​Full​​ ​​Name​​ ​as​ ​given​ ​in​ ​the​ ​class​ ​list
b. Your​ ​Student​ ​ID
c. What​ ​you​ ​have​ ​done​ ​in​ ​the​ ​assignment
d. Whatyourcodefilesareandwhateachoneofthemdoes.(Pleasedonot
repeattheprojectdescription,justnameyourcodefilesandbrieflymention
what​ ​they​ ​do).
e. The​ ​format​ ​of​ ​all​ ​the​ ​messages​ ​exchanged.
g. Anyidiosyncrasyofyourproject.It shouldsayunderwhatconditionsthe
project​ ​fails,​ ​if​ ​any.
h. ReusedCode:Didyouusecodefromanywhereforyourproject?Ifnot,say
so.Ifso,saywhatfunctionsandwherethey'refrom.(Alsoidentifythiswitha
comment​ ​in​ ​the​ ​source​ ​code.)

Submissions WITHOUT README AND Makefile WILL NOT BE
GRADED​.
Makefile​ ​tutorial:
https://www.cs.swarthmore.edu/~newhall/unixhelp/howto_makefiles.html

About​ ​the​ ​Makefile:​ ​​makefile​ ​should​ ​support​ ​following​ ​functions:

make​ ​all Compiles​ ​​all​​ ​your​ ​files​ ​and​ ​creates executables
make​ ​serverA Run​s​ ​server​ ​A
make​ ​serverB Run​s​ ​server​ ​B
make​ ​serverC Run​s​ ​server​ ​C
make​ ​aws Run​s​ ​AWS
./client​ ​​ ​ Starts​ ​the​ ​client

TAswillfirstcompileallcodesusing​makeall​.Theywillthenopenfivedifferent
terminalwindows.On4terminalstheywillstartserversA,B,CandAWSusing
commands​makeserverA​, ​makeserverB​, ​makeserverCand​makeaws​.

Rememberthatserversshouldalwaysbeononcestarted.​Clientcan
connectagainandagainwithdifferentinputvaluesandfunction.Onthefifth
terminaltheywillstarttheclientas​./clientLOG0.5or./clientDIV0.5​.Notethat
inputvalueof0.5isjustanexample.TAswillchecktheoutputsformultiple
valuesofinput.Theterminalsshoulddisplaythemessagesshownintable4,5,
6,​ ​7​ ​and​ ​8.

2. CompressallyourfilesincludingtheREADMEfileintoasingle“tarball”andcall
it: ​ee450_yourUSCusername_session#.tar.gz(all smallletters)e.g.my
filenamewouldbe​ee450_sakulkar_session1.tar.gz​. Pleasemakesurethat
your​ ​name​ ​matches​ ​the​ ​one​ ​in​ ​the​ ​class​ ​list.​ ​Here​ ​are​ ​the​ ​instructions:

a.OnyourVM,gotothedirectorywhichhasallyourprojectfiles.Removeall
executableandotherunnecessaryfiles.​Onlyincludetherequiredsource
code​ ​files,​ ​Makefile​ ​and​ ​the​ ​README​ ​file​.​ ​Now​ ​run​ ​the​ ​following​ ​commands:

b.
>>​ ​​tar​ ​cvf​ ​​ee450_yourUSCusername_session#.tar​​ ​*
>>​ ​​gzip​ ​​ee450_yourUSCusername_session#.tar
Now,youwillfindafilenamed“ee450_yourUSCusername_session#.tar.gz”in
the​ ​same​ ​directory.​ ​Please​ ​notice​ ​there​ ​is​ ​a​ ​star(*)​ ​at​ ​the​ ​end​ ​of​ ​first​ ​command.
Any​ ​compressed​ ​format​ ​other​ ​than​ ​.tar.gz​ ​will​ ​NOT​ ​be​ ​graded!

3. Upload“ee450_yourUSCusername_session#.tar.gz”totheDigitalDropboxon
theDENwebsite(DEN->EE450->MyTools->Assignments->SocketProject).
Afterthefileisuploadedtothedropbox,youmustclickonthe“​send”​buttonto
actually​ ​submit​ ​it.​ ​If​ ​you​ ​do​ ​not​ ​click​ ​on​ ​“​send​”,​ ​the​ ​file​ ​will​ ​not​ ​be​ ​submitted.

4. D2Lwillandkeepa historyof allyoursubmissions.If youmakemultiple
submission,wewillgradeyourlatestvalidsubmission.Submissionafterdeadline
is​ ​considered​ ​as​ ​invalid.

5. D2Lwillsendyoua“Dropboxsubmissionreceipt”toconfirmyoursubmission.So
pleasedocheckyouremailsto makesureyoursubmissionissuccessfully
received.Ifyoudon’treceiveaconfirmationemail,tryagainlaterandcontact
your​ ​TA​ ​if​ ​it​ ​always​ ​fails.


6. Pleasetakeintoaccountallkindsofpossibletechnicalissuesanddoexpecta
hugetrafficontheDENwebsiteveryclosetothedeadlinewhichmayrender
your​ ​submission​ ​or​ ​even​ ​access​ ​to​ ​DEN​ ​unsuccessful.

7. PleaseDONOTwaittillthelast5minutestouploadandsubmitbecausesome
technicalissuesmighthappenandyouwillmissthedeadline.Anda kind
suggestion,ifyoustillgetsomebugsonehourbeforethedeadline,pleasemake
a​ ​submission​ ​first​ ​to​ ​make​ ​sure​ ​you​ ​will​ ​get​ ​some​ ​points​ ​for​ ​your​ ​hard​ ​work!

8. Afterreceivingtheconfirmationemail,pleaseconfirmyoursubmissionby
downloadingandcompilingitonyourmachine.Iftheoutcomeisnotwhatyou
expected,tryto resubmitandconfirmagain.Wewillonlygradewhatyou
submitted​ ​even​ ​though​ ​it’s​ ​corrupted.

9. Youhaveplentyoftimetoworkonthisprojectandsubmititintimehence
thereisabsolutelyzerotoleranceforlatesubmissions!DoNOTassume
thattherewillbealatesubmissionpenaltyoragraceperiod.Ifyousubmit
yourprojectlate(nomatterforwhatreasonorexcuseoreventechnical
issues),​ ​you​ ​simply​ ​receive​ ​a​ ​zero​ ​for​ ​the​ ​project.




Grading​ ​Criteria:

Notice:Wewillonlygradewhatisalreadydonebytheprograminsteadofwhat
will​ ​be​ ​done.
Forexample,theTCPconnectionisestablishedanddataissenttotheAWS.Butresult
isnotreceivedbytheclientbecausetheAWSgotsomeerrors.Thenyouwilllosesome
points​ ​for​ ​phase​ ​1​ ​even​ ​though​ ​it​ ​might​ ​work​ ​well.

Your​ ​project​ ​grade​ ​will​ ​depend​ ​on​ ​the​ ​following:

1. Correctfunctionality,i.e.howwellyourprogramsfulfilltherequirementsofthe
assignment,​ ​specially​ ​the​ ​communications​ ​through​ ​UDP​ ​and​ ​TCP​ ​sockets.

2. Inlinecommentsinyourcode.Thisisimportantasthiswillhelpinunderstanding
what​ ​you​ ​have​ ​done.

3. Whether​ ​your​ ​programs​ ​work​ ​as​ ​you​ ​say​ ​they​ ​would​ ​in​ ​the​ ​README​ ​file.

4. Whether​ ​your​ ​programs​ ​print​ ​out​ ​the​ ​appropriate​ ​error​ ​messages​ ​and​ ​results.

5. Ifyoursubmittedcodes,donotevencompile,youwillreceive5outof100forthe
project.

6. Ifyoursubmittedcodescompileusingmakebutwhenexecuted,produceruntime
errors​ ​without​ ​performing​ ​any​ ​tasks​ ​of​ ​the​ ​project,​ ​you​ ​will​ ​receive​ ​10​ ​out​ ​of​ ​100.

7. EachUDPexchangeisworth15pointsandTCPexchangeisworth25points.
Forexample,if youonlycomplete2 UDPconnectionsandhalfoftheTCP
connections,youwillreceive42.5outof100fortheproject.Thereare5UDP
connections​ ​and​ ​one​ ​TCP​ ​connections​ ​in​ ​total.

8. IfyouforgettoincludetheREADMEfileorMakefileintheprojecttar-ballthatyou
submitted,youwilllose15pointsforeachmissingfile(plusyouneedtosendthe
file​ ​to​ ​the​ ​TA​ ​in​ ​order​ ​for​ ​your​ ​project​ ​to​ ​be​ ​graded.)

9. IfyourcodedoesnotcorrectlyassigntheTCPorUDPportnumbers(inany
phase),​ ​you​ ​will​ ​lose​ ​10​ ​points​ ​each.

10.You​ ​will​ ​lose​ ​5​ ​points​ ​for​ ​each​ ​error​ ​or​ ​a​ ​task​ ​that​ ​is​ ​not​ ​done​ ​correctly.


11.Theminimumgradeforanon-timesubmittedprojectis10outof100,assuming
therearenocompilationerrorsandthesubmissionincludesaworkingMakefile
and​ ​a​ ​README.

12.Therearenopointsfortheeffortorthetimeyouspendworkingontheprojector
readingthetutorial.Ifyouspendabout2monthsonthisprojectanditdoesn’t
even​ ​compile,​ ​you​ ​will​ ​receive​ ​only​ ​5​ ​out​ ​of​ ​100.

13.Usingfork()orsimilarsystemcallsarenotmandatoryhoweverif youdouse
fork()orsimilarsystemfilesinyourcodestocreateconcurrentprocesses(or
threads)​ ​and​ ​they​ ​function​ ​correctly​ ​you​ ​will​ ​receive​ ​10​ ​bonus​ ​points.

14.YoumustdiscussallprojectrelatedissuesonPiazza​. Wewillgivethose
whoactivelyhelpothersoutbyansweringquestionsonPiazzaupto10bonus
points.(​Ifyouwanttoearntheextracredits,doremembertoleaveyournames
visible​ ​to​ ​instructors​ ​when​ ​answering​ ​questions​ ​on​ ​Piazza.​)

15.Themaximumpointsthatyoucanreceivefortheprojectwiththebonuspointsis
100.Inotherwordsthebonuspointswillonlyimproveyourgradeifyourgradeis
less​ ​than​ ​100.

16.Yourcodewillnotbealteredinanywaysforgradingpurposesandhoweverit
willbetestedwithdifferentinputs.YourdesignatedTArunsyourprojectasis,
accordingto theprojectdescriptionandyourREADMEfileandthencheck
whetherit workscorrectlyornot.IfyourREADMEisnotconsistentwiththe
description,​ ​we​ ​will​ ​follow​ ​the​ ​description.




Cautionary​ ​Words:

1. Start​ ​on​ ​this​ ​project​ ​early!!!

2. Inviewofwhatisarecurringcomplaintneartheendofaproject,wewantto
makeitclearthatthetargetplatformonwhichtheprojectissupposedtorunis
theprovided​Ubuntu(16.04)​. Itisstronglyrecommendedthatstudentsdevelop
theircodeonthisvirtualmachine.In casestudentswishto developtheir
programsontheirpersonalmachines,possiblyrunningotheroperatingsystems,
theyareexpectedtodealwithtechnicalandincompatibilityissues(ontheirown)
to ensurethatthe finalprojectcompilesandrunsontherequestedvirtual
machine.Ifyoudodevelopmentonyourownmachine,pleaseleaveatleast
threedaystomakeitworkonUbuntu.Itmighttakemuchlongerthanyouexpect
because​ ​of​ ​some​ ​incompatibility​ ​issues.

3. Youmaycreatezombieprocesseswhiletestingyourcodes,pleasemakesure
youkillthemeverytimeyouwanttorunyourcode.Toseealistofallzombie
processes,​ ​try​ ​this​ ​command:​ ​​ ​​​ ​>>ps​ ​​ ​–aux​ ​​ ​|​ ​​ ​grep​ ​​ ​ee450
Identifythezombieprocessesandtheirprocessnumberandkillthembytyping
at​ ​the​ ​command-line:​​ ​​ ​​ ​​ ​​​ ​​>>kill​ ​-9​ ​processnumber



Academic​ ​Integrity:

All​ ​students​ ​are​ ​expected​ ​to​ ​write​ ​all​ ​their​ ​code​ ​on​ ​their​ ​own.

Copyingcodefromfriendsiscalled​plagiarismnot​collaborationandwillresultinanF
fortheentirecourse.​Anylibrariesorpiecesofcodethatyouuseandyoudidnotwrite
mustbelistedinyourREADMEfile​.Allprogramswillbecomparedwithautomatedtools
todetectsimilarities;examplesofcodecopyingwillgetanFforthecourse.​IFYOU
HAVEANYQUESTIONSABOUTWHATIS OR ISN’TALLOWEDABOUT
PLAGIARISM,​ ​TALK​ ​TO​ ​THE​ ​TA.​ ​​“I​ ​didn’t​ ​know”​ ​is​ ​not​ ​an​ ​excuse.
 

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!