代写COMP 5416 Assignment 2代做Python编程

COMP 5416 Assignment 2
Due: 6/November/2021 23:59
Question 1 (TCP, 20%). In the following network, node A transmits packets that pass through B, C, and 
D, and arrive at the
destination E. The bit rate of all links is R = 1 Mbit/sec. The maximum packet size in the network is 500 Bytes. Ignore the
header size. The one-way propagation delay on each link is 4 msec.
How long does it take to transmit 100 + s packets if TCP Reno is used, where s is the last two digits of your student number.
At the beginning, ssthresh is 8 segment size (4000 bytes). B, C, and D use Store-and-Forward. No packet is lost. There is
no bit-error in transmission. The size of ACK packets is negligible. The size of TCP header is negligible.
! " # $ %
2Question 2 (Token Bucket Simulation, 20%). In this task, you need to simulate and analyze a token bucket. You can reuse some
the codes in Week 6 Lab. You Python code must be submitted as supplementary material. Only Python 3 is allowed.
The token bucket scheduler consists of a bucket which can accommodate x tokens and a queue which can accommodate infinite
packets. The arrival of packets follows an independent Poisson process with rate λ > 0 unit/second. The arrival of tokens follows
a deterministic process. That it, the inter-arrival time is a constant, i.e., 1µ unit/second. We assume that λ = 1 unit/second, and
µ = 1.25 unit/second.
Let x = 3 + floor(s/2), where s is the last digit of your student number. For example, if your student number is 490012345,
then s = 5 and x = 5.
Let 1, 2, 3, 4, . . . denote the states where there are 1, 2, 3, 4, . . . packets in the buffer. Let −1,−2, . . . ,−x denote the states where
there are 1, 2, . . . , x tokens in the bucket. Let 0 denote the state where there are 0 packet and 0 token.
(1) By simulation, find out the unconditional stationary distribution of the system states −x,−x+ 1, . . . , 0, 1, 2, . . ..
(2) By simulation, find out the conditional distribution of the the system states when a packet arrives.
(3) By simulation, find out the conditional distribution of the the system states when a token arrives.
(4) By simulation, find out the mean time that a packet waits in the buffer.
(5) Find out the probability that a token is dropped.
3Question 3 (Multi-thread Server: Implementation, 20%). You are given the complete code for the client in Lab in Week 8. Your
task is to write the TCP server. The client code is in client.py. You must not modify this code. (However, you are allowed
to change ServerName and ServerPort). Only Python 3 is allowed.
Different from the server in the lab, the new server must be able to serve multiple clients simultaneously. Please note that the
server code in Week 8 can only accept one client! In order to serve multiple clients simultaneously. The server should run multiple
threads. The server will establish a new connection socket to communicate with one new client, and each new connection socket
will be managed by a new thread. You should self-study the following function: _thread.start_new_thread().
The following figure shows an example of server when two clients are sending images at the same time. The two connections
are closed in the end, demonstrating that there are two concurrent transmissions before the first “Connection closed”.
You also need to capture the concurrent data transmission by Wireshark. In the example in the next page, we can see that the
two clients are running at 192.168.0.3, with port numbers 60458 and 60462. The server is running at 192.168.0.4, with port
number 12011. The throughputs of the two connections are both positive at around the 4th second.
Tasks and submissions:
(1) Build up a multi-thread server which can serve multiple clients at the same time. Submit your server-side Python code.
Submit your server code as Lastname_Firstname_Server.py. We will use the client in Week 8 to test against your server.
(2) Test your server with three clients sending images at the same time. Capture the packets by Wireshark at the server side.
You are allowed to run the server and clients in one computer using localhost. Submit your Wireshark capture. Your capture
file must be smaller than 10MB. Your capture will be ignored and will not be marked if it is greater than 10MB. Submit your
capture as Lastname_Firstname_Capture.pcapng (or .pcap).
(3) In the main submission file, based on your capture in (2), plot the throughput vs. time of the three connections (similar to
the figures in the next page). Show that they are operated in parallel. In the main file, you also need to give the three clients’
IP addresses, clients’ port numbers, server’s IP address, and server’s port number.
4You overall mark will be zero if you do not submit code in (1), no matter if you submit (2) or (3).
You submission in (2) and (3) will be ignored and will not be marked if your submission in (1) does not work.
You overall mark will be zero if your Wireshark capture in (2) does not match the throughput plots in (3).
5Question 4 (BER vs SNR with different modulation schemes, 20%). We aim to plot BER vs SNR curves of different modulation
schemes in this question.
(1) BPSK. In wireless communication, we can transmit 0 and 1 through signals −1 and 1 respectively. Both −1 and 1 signals
have power of 1, so that the mean signal power is 1. This is called Binary Phase Shift Keying (BPSK). Due to the existence of
noise, the received signal is −1+n or 1+n respectively, where n is the noise term. n follows normal distribution n ∼ N(0, σ2).
σ2 is the power of the noise, and thus 1σ2 is SNR. If the received signal is ≥ 0, it is decoded as 1; if the received signal is < 0,
it is decoded as 0. We assume that 0 and 1 are sent with equal probabilities. Compute average BER vs SNR of BPSK when
SNR = [0,5,10,15,20,25] dB. Hint: What is dB?
(2) 4QAM. Now we consider another modulation scheme, where we can use two orthogonal signals (x, y) to represent 2 bits. (x
is usually carried by a cosine signal, and y is usually carried by a sine signal.) We can transmit 00, 01, 11, and 10 through signals
(−1,−1), (−1, 1), (1, 1), and (1,−1) respectively. The signal power is 2. This is called 4 quadrature amplitude modulation
(4QAM). Still, due to the existence of noise, the received signal (r1, r2) is (−1+n1,−1+n2), (−1+n1, 1+n2), (1+n1, 1+n2),
and (1 + n1,−1 + n2) respectively, where (n1, n2) is the noise term. n1 and n2 are independent random variables with normal
distribution, with mean 0 and variance σ2. The power of the noise calculated as E(n21 + n
2
2). The received signal is decoded as
• 00, if r1 < 0 and r2 < 0;
• 01, if r1 < 0 and r2 ≥ 0;
• 11, if r1 ≥ 0 and r2 ≥ 0;
• 10, if r1 ≥ 0 and r2 < 0;
where the regions r1 < 0 and r2 < 0; r1 < 0 and r2 ≥ 0; r1 ≥ 0 and r2 ≥ 0; and r1 ≥ 0 and r2 < 0 are called decision regions
(see the figure below).
Compute average BER vs SNR of 4QAM when SNR =[0,5,10,15,20,25] dB. Still, we assume that bits 0 and 1 are sent with
equal probabilities. You can make reasonable approximations to calculate the probabilities using Q function or erfc function
through computer. It is not necessary to calculate double integral.
11
00
01
10
x
y
(3) 16QAM. Now we consider an even more complicated modulation scheme. We use two orthogonal signals (x, y) to represent
4 bits. x and y can be −3, −1, 1, or 3, and the represented four bits are shown in the figure below. For example, (−1,−1)
represents 0101. Please note that through this arrangement, there is only one bit difference between two neighbors, which will
reduce bit error rate. Still, the noise is (n1, n2). n1 and n2 are independent random variables with normal distribution, with mean
0 and variance σ2. The power of the noise is calculated as E(n21 +n
2
2). The decision regions are shown in the figure below. For
example, for the received signal (r1, r2), if −2 ≤ r1 < 0 and −2 ≤ r2 < 0, it is decoded as 0101. The average signal power is
(32+32)+(32+12)+(12+32)+(12+12)
4 = 10.
6y
x
0001
0011
0010
0000
0101
0111
0110
0100
1101
1111
1110
1100
1001
1011
1010
1000
-1-3 1 3
1
3
-1
-3
Compute average BER vs SNR of 16QAM when SNR =[0,5,10,15,20,25] dB. Still, we assume that bits 0 and 1 are sent with
equal probabilities. You can make reasonable approximations to calculate the probabilities using Q function or erfc function
through computer. It is not necessary to calculate double integral.
(4) Plot the BER vs SNR curves of BPSK, 4QAM, and 16QAM. You should derive a figure like Page 53 in the slides of Week
8. Discuss why improved data rate can cause higher BER.
7Question 5 (Cellular network with guard channel, 20%). Consider one cell in a cellular network. There are 60 available channels
and each channel can be used by exactly one user. New user arrivals follow an independent Poisson Process with arrival rate λn
and handoff user arrivals follow an independent Poisson Process with arrival rate λh. Both new and handoff users stay active for
a random duration, following exponential distribution with mean 1µ . The cell reserves X channels for handoff user arrivals. As
discussed in the class, new arrivals will be blocked if 60−X or more channels are occupied. Handoff arrivals will be dropped
if 60 channels are occupied. We assume that λn = 2400 units/hour, λh = 600 units/hour, and 1µ = 1 minute.
(1) Let X = 5. Compute the probability that a new arrival is blocked. Compute the probability that a handoff arrival is dropped.
(2) If a new arrival is blocked, a $0.01 loss will be incurred; If a handoff arrival is dropped, a $0.1 loss will be incurred. Find
the optimal X so that the overall loss is minimised.
8Submission Instructions: You should submit one main file and several supplementary files. You should include your answers
to Q1–Q5 and explanations of your answers in the main file. You should submit your main file at “main file submission”. The
main file is in the format of pdf. For Q2, you must submit your simulator at “Q2 code submission”. For Q3, you must submit
your Python code at “Q3 code submission” and Wireshark capture at “Q3 capture submission”. Your code and capture will be
examined against your answers in the main file. Penalty would be incurred if your code/capture does not match your answer
in the main file. For Q4/Q5, you may upload Python code to calculate the result in “Q4/Q5 calculation”. Please note that,
files uploaded in Q4/Q5 will be marked as intermediate steps. Wrong answers in Q4/Q5 without file uploads will incur heavier
penalties.
File upload File format Must upload?
main file submission pdf Yes
Q2 code submission Python 3 code Yes
Q3 code submission Python 3 code Yes
Q3 capture submission Wireshark capture Yes
Q4 calculation Python 3 code No
Q5 calculation Python 3 code No
TABLE I
FILE UPLOAD
All your submissions will be checked by plagiarism examination tools.
This is one assignment with multiple pieces to submit. Your submission time is equal to the submission time of the last piece.
Submission instruction of Q6 (bonus question) will be released when Q6 is available in Week 12.




热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图