# BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

# 代码代写｜COMP 5416 Assignment 2 (2022)

### 代码代写｜COMP 5416 Assignment 2 (2022)

Question 1 (TCP, 20%). In the following network, node A transmits packets that pass through B–D, and arrive at the destination

1. The bit rate of all links is R = 1 Mbit/sec. The maximum packet size in the network is 1500 Bytes. Ignore the header size.

The one-way propagation delay on each link is 20 msec.

(1) How long does it take to transmit N = 50 packets if TCP Reno is used. At the beginning, ssthresh is 6 segment size (9000 bytes). B–D use Store-and-Forward. No packet is lost. TCP timer does not expire. There is no bit-error in transmission.

The size of ACK packets is negligible. The size of TCP header is negligible. Please also ignore TCP handshake delay and TCP termination delay.

(2) Repeat (1) when the sender transmits N = 250 packets.

!”#\$%2

Question 2 (BER vs SNR with different modulation schemes, 20%). We aim to plot BER vs SNR curves of two 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 Gaussian 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) 4PAM. Now we consider another modulation scheme, where each signal can represent two bits. We can transmit 00, 01, 11,10 through signals 3, 1, 1, and 3 respectively. The mean signal power of the signal is 32+12+12+324 = 5. This is called 4 pulse-amplitude modulation (4PAM). Still, due to the existence of noise, the received signal is 3 + n, 1 + n, 1 + n, or 3 + respectively, where n is the noise term. Still, n follows Gaussian distribution n N(0, σ2). σ2 is the power of the noise, and thus σ5 2 is SNR. If the received signal is in (−∞, 2], (2, 0], (0, 2], and (2, ), it is decoded as 00, 01, 11, and 10 respectively.

We assume that 00, 01, 11, and 10 are sent with equal probabilities. Compute average BER vs SNR of 4PAM when SNR =[0,5,10,15,20,25] dB. Note that if 00 is decoded as 01, it is regarded as one bit error; if 00 is decoded as 11, it is regarded as two bit errors.

To compute Q function, you can use Python math.erfc() function. math.erfc() returns result of erfc function, and Q(x) = 1 2 erfc( x2 ).

(3) Plot the BER vs SNR curves of BPSK and 4PAM. You should derive a figure like Page 45 in the slides of Week 8. Discuss why improved data rate can cause higher BER. Discuss why the transmitted signal should be 00, 01, 11, and 10 at 3, 1, 1,and 3 respectively for 4PAM. Why not 00, 01, 10, and 11?3

Question 3 (Network Policing, 20%). Alice, Bob, and Chris are three users sharing one bottleneck link. We utilise token buckets and queues to mark, schedule, and police their traffic. The bottleneck link has a bandwith of 4Mbps and it can buffer at most Mbit data. Alice’s traffic is a VoIP session and Alice has declared 1 Mbps data rate and 1 Mbit burst size. Bob’s traffic is a VoIP session and Bob has declared 2 Mbps data rate and 1 Mbit burst size. Chris’s traffic is an HTTP session without declared data rate or burst size. Each packet has a size of 1000 byte. We prioritise the traffic as follows: Alice’s conforming traffic = Bob’s conforming traffic > Chris’s traffic > Alice’s non-conforming traffic = Bob’s non-conforming traffic.

Queue

token bucket A

Arriving traffic (Alice)

Arriving traffic (Chris)

Arriving traffic (Bob)

token bucket B

(1) Design the policies at the two token buckets and the rule at the queue to satisfy the above requirements.

(2) The above design in (1) has one disadvantage: When both Alice and Bob are non-conforming, and the system has enough capability to handle some of the non-conforming traffic, it cannot handle the non-conforming traffic in a fair way. Discuss the following scenario: In a long period of time, Alice is transmitting with a constant rate of 2 Mbps; Bob is transmitting with a constant rate of 100 Mbps; Chris is inactive. There is no burst traffic. Discuss what will happen.

(3) Modify the design in (1) to address the issues in (2). If the system has capability to handle a partial or all non-conforming traffic, non-conforming traffic will be handled in a fair way. Please note that this is an open question. You can add token bucket,queue, or other modules at any place in the system. Your will get full mark as long as your design works correctly. Bonus marks may be granted if your design is smart.

Question 4 (Queue and Erlang B: Simulation, Analysis, and Application, 20%). In this task, you need to simulate and analyze an M/M/m/n queue with arbitrary m and n. You can reuse the codes in Week 6 Lab to simulate an M/M/m/n queue. You Python code must be submitted as supplementary material. You also need to theoretically compute the stationary distribution to verify your simulation or table-lookup.

Throughout this question, let the arrival rate be λ. Let the service rate of each server be µ.

(1) Let λ = 2 and µ = 3. What is the stationary distribution of an M/M/1/10 queue. Please figure out this result by both simulation and analysis.

(2) Let λ = 5 and µ = 1. What is the stationary distribution of an M/M/5/10 queue. Please figure out this result by both simulation and analysis.

(3) Use theoretical analysis only. What is the stationary distribution of an M/M/m/m queue (now n = m). What is the probability that a new arrival is blocked (dropped) by the system? This probability is defined as pb.

(4) Follow (3). Let µ = 1 and m = 10. If the blocking probability pb must be limited to 0.001, what is the maximum value of λ?

(5) Follow (3). Let λ = 10 and µ = 1. If the blocking probability pb must be limited to 0.001, what is the minimum value of m, i.e., the number of servers?

(6) Use the Erlang B table provided to verify your solution in (4) and (5). Which row and column shows the solution to (4) and

(5)? Why?5

Question 5 (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”.