C ¸ankaya University Department of Computer Engineering 2014 - 2015 Spring Semester CENG 290 - Data Communications Midterm Examination 1) Fill in the blanks with appropriate terms from the list: 1. We want to send a sequence of computer screen images over an optical fiber. The screen is 480 × 640 pixels, each pixel being 24 bits. There are 60 screen images per second. Therefore we need a bandwidth of 442 2. satellites permanently remain above the same spot on Earth. 3. The is the distance between two routers divided by the propagation speed. 4. The largely depends on the rate at which traffic arrives at the queue and the transmission rate of the link. 5. The concerns with transmitting raw bits over a com- munication channel. 6. If the intensity of a signal is reduced to 1/1000 of its previous value, we say it reduced by dB. 7. The main task of the is to transform a raw transmis- sion facility into a line free of transmission errors. 8. In networks, the resources needed along a path (buf- fers, link bandwidth) are reserved for the duration of communication session. 9. Telephones are systems because both parties on the phone can talk and listen at the same time. 10. is sending multiple signals or streams of information on a carrier at the same time in the form of a single, complex signal and then recovering the separate signals at the receiving end.
29
Embed
CENG 290 - Data Communications Midterm Examination
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Cankaya UniversityDepartment of Computer Engineering
2014 - 2015 Spring Semester
CENG 290 - Data Communications
Midterm Examination
1) Fill in the blanks with appropriate terms from the list:
1. We want to send a sequence of computer screen images over an optical fiber. Thescreen is 480 × 640 pixels, each pixel being 24 bits. There are 60 screen images persecond. Therefore we need a bandwidth of 442
2. satellites permanently remain above the same spoton Earth.
3. The is the distance between two routers divided bythe propagation speed.
4. The largely depends on the rate at which trafficarrives at the queue and the transmission rate of the link.
5. The concerns with transmitting raw bits over a com-munication channel.
6. If the intensity of a signal is reduced to 1/1000 of its previous value, we say itreduced by dB.
7. The main task of the is to transform a raw transmis-sion facility into a line free of transmission errors.
8. In networks, the resources needed along a path (buf-fers, link bandwidth) are reserved for the duration of communication session.
9. Telephones are systems because both parties on thephone can talk and listen at the same time.
10. is sending multiple signals or streams of informationon a carrier at the same time in the form of a single, complex signal and thenrecovering the separate signals at the receiving end.
11. The most natural example of is radio and televisionbroadcasting, in which multiple radio signals at different frequencies pass throughthe air at the same time.
12. Telephone system of a neighborhood use topology.
13. If you are moving as you use your cell phone, you may be transferred to anotherbase station. This is called
14. Garage door openers, radio controlled toys etc. usebands
15. The ratio of signal power to noise power is called .
2) Consider sending a large file of F bits from Host 1 to Host 2. There are two links and onenode between 1 and 2. Neglect propagation delays and queueing delays. Host 1 segmentsthe file into segments of S bits and adds h bits of header to each segment. Assume F/Sis an integer. Each link has a transmission rate of R bps. Find the end-to-end delay insending the file.
3) Using CDMA encoding, users A,B,C,D each send a 2-bit message. Their codewords are:
b) What is the maximum number of errors we can detect?
c) What is the maximum number of errors we can correct?
5) A message 10110101 is transmitted using the CRC polynomial method. The generatorpolynomial is x3 + 1.
a) What is the actual frame transmitted?
b) How many bits must be damaged for an error to be unrecognized?
6) A transmitted message is corrupted with probability p. We use error detection and ret-ransmission. (Assume errors are always detected) What is the probability we need exactlytwo retransmissions?
Cankaya UniversityDepartment of Computer Engineering
2014 - 2015 Spring Semester
CENG 290 - Data Communications
Final Examination
1) Fill in the blanks with appropriate terms from the list:
1. Garage door openers, radio controlled toys etc. usebands.
2. The ratio of signal power to noise power is called .
3. The rules 1)If medium idle, transmit; 2)If medium busy, listen until idle; then trans-mit immediately describe the CSMA protocol.
4. In a stop-and-wait protocol, the sender sends one frame and then waits for an.
5. A valid Ethernet frame carries a minimum of bytesand a maximum of bytes of data.
6. If there is an error in a packet, the receiver will detect this when it computes.
7. Temporarily delaying acknowledgements so that they can be added to next outgoingdata frame is known as .
8. Token-ring protocol is a protocol.
9. In pure ALOHA, suppose it takes 8 ms to send a frame. Then, the vulnerable timeperiod is ms.
10. In slotted ALOHA, suppose it takes 8 ms to send a frame. Then, the vulnerabletime period is ms.
11. The channel utilization of slotted ALOHA is thanpure ALOHA.
12. In protocol, the sender first listens to the channel. Ifsomebody is transmitting, it waits.
13. If the sender receives no acknowledgement and the timer expires, it sends the framewith the same .
14. After the first collision, each station waits 0 or 1 time slots. (The choice is random)After the second collision, each waits 0,1,2 or 3 time slots and so on. This is called
.
15. A valid Ethernet frame must have a minimum length ofbytes.
16. If the receiver does not have sufficient buffer and if the sender is sending frames tooquickly, packets may be lost. This is called .
17. To solve the hidden terminal problem in wireless communications, the sender firstsends a short message and the receiver replies with a
message. After that, the data is sent.
18. The receiver will send a NAK if the frame it receives is
2) Consider a 1 Mbps satellite channel with 50 ms round trip propagation delay. We want tosend a 1000 bit frame, and we will not send a second frame until we receive acknowledge-ment for the first frame.
a) What percent of the available bandwidth are we using?
b) Now suppose the round trip delay is doubled. Can we say that the bandwidth usageis reduced to half?
3) A 1500 km long line with bandwidth 1.544 Mbps is used to transmit 64 byte frames.Propagation speed is 150 000 km/s. We are using selective repeat protocol.
a) If we use the full bandwidth, how many frames are on the line simultaneously?
b) How many bits do we need for sequence numbers?
4) A large population of ALOHA users manages to generate 50 requests/sec, including bothoriginals and retransmissions. Time is slotted in units of 40 msec. What are the chancesof success on the first attempt?
5) Consider five wireless stations, A, B, C, D, and E.
• Station A can communicate with all other stations.
• B can communicate with A, C and E.
• C can communicate with A, B and D.
• D can communicate with A, C and E.
• E can communicate A, D and B.
a) When A is sending to B, what other communications are possible?
b) When B is sending to C, what other communications are possible?
Answers
1)
1. ISM
2. SNR
3. 1-persistent
4. Acknowledgement
5. 46, 1500
6. Checksum
7. Piggybacking
8. Collision free
9. 16
10. 8
11. Better
12. CSMA
13. Sequence number
14. Binary Exponential Backoff
15. 64
16. Flooding
17. RTS, CTS
18. Corrupted
2) a)1000 bits
106 bits/sec= 10−3s = 1 ms
Together with the round trip delay, this is 51 ms. We are using the channel for 1 msonly, so the bandwidth usage is:
1
51= 0.0196 = 1.96%
b) This time usage is
1
101= 0.0099 = 0.99%
It is almost reduced to half, but not exactly.
3) a)1500 km
150 000 km/sec= 10−2s
1.544× 106 bits/sec× 10−2s = 1.544× 104 bits
1
8× 1.544× 104 bits = 1930 bytes
1930 bytes/64 = 30.16 frames
b) Using the selective repeat protocol, the sequence numbers must be double the numberof frames.
2× 30.16 = 60.3225 < 60.32 < 26
⇒ we need 6 bits.
4) G = 50 req/sec ×40× 10−3 sec=2 requests.
No one else must communicate during one slot.
Usinge−GGn
n!with n = 0, we obtain:
e−2 = 0.1353
5)
A
C
E
DB
a) Nobody can talk. Everybody will hear A, so there will be interference.
b) E can talk to D. There will be no interference, because D can not hear B, and C cannot hear E.
Cankaya University
Department of Computer Engineering
CENG 290 - Data Communications03.03.2015
LABWORK 1
In this lab, our aim is to write two files, Encode and Decode, that use CDMA encodingfor 4 users and 8 bit codewords. The messages may be of any length, but the exampleprovided is for 5-bits. The first file will combine the messages and the second one willseparate them.
ENCODE
%The aim of this file is to use CDMA encoding for 4 users. Each user sends
%an arbitrary binary message. Messages must be of the same length. In the
%example below, the length is 5.
%Each user has a codeword of 8 bits. Note that codewords are orthogonal
%in the sense of inner product. dot product)
%The file combines the messages by multiplying the codeword by +1 for input 1
%and -1 for input 0, and then adding all. The result is stored in the variable MSG.
%For the example below, MSG is 40 bits.
%Written by Emre Sermutlu, 10.03.2015
%Codewords necessary for each user
CodeA = [-1 -1 -1 +1 +1 -1 +1 +1];
CodeB = [-1 -1 +1 -1 +1 +1 +1 -1];
CodeC = [-1 +1 -1 +1 +1 +1 -1 -1];
CodeD = [-1 +1 -1 -1 -1 -1 +1 -1];
%Messages of each user
MsgA = [1 0 1 0 1];
MsgB = [0 1 1 0 1];
MsgC = [1 1 1 0 1];
MsgD = [0 0 1 0 0];
%Input ends here. We assume all messages are of the same size.
%Actually, we need a check here.
%Can you see what trick is being done here?
MsgA = 2 * MsgA - 1;
MsgB = 2 * MsgB - 1;
MsgC = 2 * MsgC - 1;
MsgD = 2 * MsgD - 1;
bits = size(MsgA,2);
MSG = zeros(1, 8*bits);
%It is not a good idea to write this manually like that. I advise you to
%develop this code by adding a third for loop over the users.
Write MATLAB functions with the following descriptions:
Decode2D: The matrix y is a 7× 7 binary message matrix. By adding parity bits to 8th
row and column, the 8× 8 matrix x is obtained.The function Decode2D takes the input x. If there are no errors, it gives y and prints a
message. If there is one error, it corrects the error and gives y. It also prints the coordinatesof the error. If there are two or more errors, it prints ”REQUEST RETRANSMISSION”.
HammingEncode: Given a message in the form of an n× 2 binary matrix, the function
HammingEncode outputs an n × 5 binary matrix according to the following translationrules:
00→ 0000001→ 0101110→ 1010111→ 11110
Decode2Dfunction y = Decode2D(x)
if (size(x,1) ~= 8 || size(x,2) ~= 8)
error(’The input x must be an 8 x 8 matrix’);
end
RowErr = 0;
for i = 1:8
sum = 0;
for j = 1:8
if (x(i,j) ~= 0 && x(i,j) ~= 1)
error(’The input x must be a binary matrix’);
end
sum = sum + x(i,j);
end
if(mod(sum,2) ~= 0)
RowErr = RowErr + 1;
row = i;
end
end
ColErr = 0;
for i = 1:8
sum = 0;
for j = 1:8
sum = sum + x(j,i);
end
if(mod(sum,2) ~= 0)
ColErr = ColErr + 1;
col = i;
end
end
if (RowErr == 0 && ColErr == 0)
y = x; y(8,:)=[]; y(:,8)=[];
fprintf(’There are no errors\n\n’);
elseif (RowErr == 1 && ColErr == 1)
x(row,col) = 1 - x(row,col);
y = x; y(8,:)=[]; y(:,8)=[];
fprintf(’There is one error at (%d,%d). It is corrected\n\n’,row,col);
else
y = zeros(7);
fprintf(’There are two or more errors. REQUEST RETRANSMSSION.\n\n’);
end
end
HammingEncodefunction B = HammingEncode( A )
if (size(A,2) ~= 2)
error(’The input A must be an n x 2 matrix’);
end
n = size(A,1);
B=zeros(n,5);
Codewords = [ 0 0 0 0 0; 0 1 0 1 1;...
1 0 1 0 1; 1 1 1 1 0];
for i = 1:n
k = 1 + A(i,2) + A(i,1) * 2;
B(i,:)=Codewords(k,:);
end
end
Cankaya University
Department of Computer Engineering
CENG 290 - Data Communications24.03.2015
LABWORK 4
Write MATLAB functions with the following descriptions:
CRCEncode: Given a binary vector msg, and a generator polynomial gen, the program
encodes the vector to msg2 using CRC encoding.
CRCDecode: The inputs are a binary vector msg2 and a generator polynomial gen. The
vector msg2 was encoded using CRC encoding. If there are no errors, the program decodesthe vector to obtain msg. If there is any error, the output is a vector of correct lengthconsisting of −1’s
CRCEncode
function msg2 = CRCEncode(msg, gen)
%This function encodes the message (msg) using
%CRC encoding with the given generator polynomial (gen)
%Written by: Emre Sermutlu on 24.03.2015
n = size(gen,2) - 1;
msg = [msg zeros(1,n)];
[Q,R] = deconv(msg, gen);
R = mod(R,2);
k = size(msg,2)-size(R,2);
R = [zeros(1,k) R];
msg2 = msg + R;
end
CRCDecode
function msg = CRCDecode(msg2, gen)
%This function decodes the message (msg2) which was encoded
%using CRC encoding with the given generator polynomial (gen)
%If there is an error, it returns a msg vector of correct length
%but it consists of zeros
%Written by: Emre Sermutlu on 01.04.2015
[Q,R] = deconv(msg2, gen);
R = mod(R,2);
test = 0;
for i = 1:size(R,2);
if R(i) ~= 0
test = 1;
break;
end
end
m = size(msg2,2) - size(gen,2) + 1;
msg = (-1)*ones(1,m);
if test == 0
for i = 1:m
msg(i) = msg2(i);
end
end
end
Cankaya University
Department of Computer Engineering
CENG 290 - Data Communications07.04.2015
LABWORK 5
Write MATLAB functions with the following descriptions:
MySwap: Given a vector x = [x1, x2, x3, x4, . . .] swap the elements to obtain
y = [x2, x1, x4, x3, . . .]. If the number of components is odd, the last one is not changed.
Billiard: Generate a matrix of zeros of given size. Then, starting with the given row and
first column, insert 1 in a diagonal pattern until the bottom row. Then go up until thetop row etc.
MySwapfunction y = MySwap( x )
%Written by Emre Sermutlu on 10.04.2015
%This function swaps the consecutive elements of a vector as follows:
%[x1 x2 x3 x4] -> [x2 x1 x4 x3]
n = size(x,2);
y = zeros(1,n);
for i = 1:n-1
if mod(i,2) == 1
y(i) = x(i+1);
else
y(i) = x(i-1);
end
end
if mod(n,2) == 0
y(n) = x(n-1);
else
y(n) = x(n);
end
end
Billiardfunction A = Billiard(n,m,k)
%Written by Emre Sermutlu on 10.04.2015
%This function generates a zero matrix of size (n,m)
%And then puts 1 to position (k,1). Then, starting with
%this element, going down and right in a diagonal,
%and reflecting back up and right, all those elements
%are transformed to 1, as if it is a billiard ball bouncing.
A = zeros(n,m);
i = k;
del = 1;
for j = 1:m
A(i,j) = 1;
if i == n
del = -1;
elseif i == 1
del = 1;
end
i = i + del;
end
end
Cankaya University
Department of Computer Engineering
CENG 290 - Data Communications21.04.2015
LABWORK 6
Write a MATLAB function SlottedAloha that takes as input the number of expectedpackets per unit time and finds the probabilities of 0 packet,1 packet, 2 or more packetsusing a simulation of slotted Aloha protocol.
SlottedAlohafunction [k0 k1 k2] = SlottedAloha( G )
%written by Emre Sermutlu on 21.04.2015
% A simulation that gives probabilities of
% 0 packet,1 packet, 2 or more packets
% using slotted Aloha protocol
N=1000;
p=G/N;
% G is the expected number of packets arriving at the system per unit time
% N is the number of users. p is the expected number of packets by one user
runs=10000;
k0=0;
k1=0;
k2=0;
for j=1:runs
cnt = 0;
for i = 1:N
if rand() < p
cnt = cnt+1;
end
end
if cnt == 0
k0 = k0 + 1;
elseif cnt == 1
k1 = k1 + 1;
else
k2 = k2 + 1;
end
end
k0=k0/runs;
k1=k1/runs;
k2=k2/runs;
end
Cankaya University
Department of Computer Engineering
CENG 290 - Data Communications05.05.2015
LABWORK 7
Suppose a number of users (a) have collided on a time slot. Each will wait a randomnumber of time slots (b) and try again.
Write a MATLAB function Backoff that takes as input the number of users, thenumber of time slots and the number of experiments to find the success rate in the firstslot by simulation.