homework 1 - solutions cs 414, spring 2012 instructor
TRANSCRIPT
Homework 1 - Solutions
CS 414, Spring 2012
Instructor: Klara Nahrstedt
Note: Homework is an individual effort, i.e., no working in groups. Consider the homework as a
preparation for your midterm. The deadline for HW1 is Thursday, March 1, midnight. You can upload
your solutions through Compass in pdf format or you can slide the homework solutions in paper form
under the door of the office 3104 Siebel Center. The homework has 100 points together.
Problem 1: Multiple-choice (10 points – 10 questions 1 points each)
1. Weakly periodic stream means that
a. Time intervals between two consecutive packets are of the same length;
b. Packet sizes are of the same length;
c. Packets are transmitted without intermediate gaps;
d. None of the above
Answer: D
2. An closed LDU (Logical Data Unit) means that
a. There is a pre-defined duration of the LDU;
b. Duration of the LDU is not known in advance;
c. Duration of the LDU is predictable;
Answer: A
3. Nyquist theorem says
a. For lossless digitization, the sampling rate must be in the range of human hearing
frequency;
b. For lossless digitization, the sampling rate must e at least twice the maximum
frequency responses.
c. For lossless digitization, the sampling rate must be 44100 Hz;
Answer: B
4. Sampling rate of audio means
a. Allocation of number of bits to the sampled waveform;
b. Rate at which a continuous waveform is sampled;
c. Frequency of voice;
Answer: B
5. Flicker effect is avoided if
a. We increase spatial resolution of video to 1080p resolution;
b. We increase aspect ratio to 16/9;
c. We increase viewing distance to 5 m;
d. We increase refresh rate to 50 Hz.
Answer: D
6. Chrominance signal carries
a. Color information;
b. Brightness information;
c. Compressed information;
Answer: A
7. PAL system uses
a. RGB color encoding;
b. YUV color encoding;
c. YIQ color encoding;
Answer: B
8. HDTV system differs from NTSC system in
a. Resolution, aspect ratio, viewing distance;
b. Coding, flicker effect handling;
c. Deployment, robustness;
Answer: A
9. Pulse Code Modulation represents
a. Each PCM-encoded sample as a whole;
b. First PCM-coded sample as a whole and following samples as differences from
the first PCM-coded sample;
c. First PCM-coded sample as a whole and following samples as differences from
the previous PCM-coded sample;
Answer: A
10. Quantization Matrix in JPEG compression was introduced because
a. It is computationally more efficient to work with matrix than with scalar
quantization;
b. It allows better entropy encoding due to DC and AC coefficient distribution in the
8x8 block matrix;
c. It allows better differentiation of DC and AC coefficients in the 8x8 block matrix
than a scalar quantization;
Answer: C
Problem 2 (15 Points)
1. (5 Points) Consider the textual sequence “aaaaaaaaaccfffffffffdddddffffffff”. Compress
the textual sequence and compare the compression of the textual sequence when applying
two following compression algorithms:
a. (a) Run-Length Coding
Solution:
The run-length coding compression leads to the compressed sequence a!9ccf!9d!5f!8 and it
yields compression from 33 bytes to 14 bytes; with the compression ratio is 33/14 ~ 3.57
b. (b) Huffman Coding (Note: calculate the probabilities of symbol occurrence
based on the occurrence of symbols in the textual sequence, e.g., P(a) = 9/33)
Solution: For calculation of the probabilities, we alphabet A={a,c,d,f} with P(a) = 9/33; P(c) =
2/33; P(f) = 17/33; P(d) = 5/33 (based on the textual sequence above). Then the Huffman code is
f 1
a 01
d 001
c 000
The Huffman compression of the sequence aaaaaaaaaccfffffffffdddddffffffff yields bit sequence
01 01 01 01 01 01 01 01 01 000 000 1 1 1 1 1 1 1 1 1 001 001 001 001 001 1 1 1 1 1 1 1 1, and
the compression ratio is:
- if we allocate for each letter according to the whole alphabet 1 byte = 8 bits, then the
compression ratio is 8*33/56 =264 bits/56 bits ~ 4.71.
Since Run-length coding compares against a fixed coding with a letter encoded with 8 bits (1
byte), to compare both coding approaches fairly, we will also compare fixed coding with
each letter being encoded 8bits per letter versus Huffman coding using statistical occurrence
in the letter sequence. Under this assumption Huffman yields much higher compression ratio
(~4.71) than for run-length coding (~3.57).
2. (5 Points) Explain what is minimum coded unit (MCU) and how to build MCU in JPEG
compression (Image preparation step) if image has different resolution for single
component. Show the MCU construction (e.g., MCU1 and MCU2) on an example with
three components C1, C2, C3 and their resolution relation is C1 (H = 2, V = 2); C2 (H =
2, V = 1); C3 (H = 1, V = 2).
Solution: Consider as an example with three components C1, C2, C3 of the JPEG Image:
C1: H1=2, V1=2 C2: H2=2, V2=1 C3: H3=1, V3=2
C1: (c1ij), i=0,1,2,3, j=0,1,2,3, C2: (c2ij), i=0,1,2,3, j=0,1, C3: (c3ij), i=0,1, j=0,1,2,3,
MCU is a combination of interleaved data units of different components belonging to one JPEG
image. It is built by taking the corresponding pixels from each component C1, C2, C3 data unit
(block) in an interleaved processing order of data units.
Two MCUs from the configuration above:
MCU1: c100, c101, c110, c111, c200, c201, c300, c310
MCU2: c102, c103, c112, c113, c202, c203, c301, c311
3. (5 Points) Provide five differences between MPEG-4 video encoding standard and the
H.261.
Solution: Differences:
- MPEG-4 has audiovisual objects (AVOs), H.261/H.263 do not consider AVOs
- MPEG-4 defines coded representation of objects, such as text, graphics, animated human
bodies, previous do not
- MPEG-4 supports B-frames, H. 261 does not have B-frames
- MPEG-4 supports scene description, H.261 does not.
- MPEG-4 supports fundamental video coding extensions:
o Object-based scene layering and separate coding and decoding of layers;
o Shape-adaptive DCT coding;
o Object-based tool box for motion prediction;
- MPEG-4 standard specifies how AVOs are bundled into one or more elementary streams,
characterized by QoS for transmission, H.261 does not.
- MPEG-4 has many temporal and spatial scaling features, H.261 does not
- MPEG-4 supports symmetric error codes, H.261 does not.
Problem 3 (20 Points)
1. Consider that the threshold of hearing is at 10-12
W/m2 and the threshold of pain for
hearing is at 1 W/m2. (Assume dB = 10*log(I/I0), where I0 is the reference level, equal to
the threshold of hearing)
a. (5 Point) Show that the threshold of pain is 120 dB.
Solutions: dB for threshold of pain: 10*log(I/I0) = 10*log(101/10
-12) = 10*log(10
12) =
10*12=120dB;
b. (5 Point) Derive what the intensity I is for conversation of 60 dB.
Solutions: 60 = 10*log(I/I0) = 10*log(I/10-12
) -> 6= log I – log 10-12
-> -6 = log I -> I = 10-6
c. (10 Points) Suppose whisper produces a sound of 30dB. How many times more
intense is the sound of a conversation if it produces a sound of 60 dB?
Solutions: 30dB is 1000 times more intense than TOH (Threshold of Hearing)
40dB is 10000 times more intense than TOH
50dB is 100000 times more intense than TOH
60dB is 1000000 times more intense than TOH
Hence, 60dB is 1000000/1000=1000 times more intense that the sound of 30dB. Each 10 dB
increases 10 times the intensity.
Problem 4 (20 Points)
Consider the alphabet A={a,b,g}. Let p(a) = 0.51, p(b) = 0.29, p(l) = 0.2.
1. (10 Points) Compute the Huffman code for this alphabet and encode the word “ball”.
Huffman Table:
Symbol a: 1
Symbol b: 01
Symbol l: 00
“ball” is encoded: 0110000
l b
a
0
0
1
1
P(l) = 0.2 P(b) = 0.29
P(a) = 0.51 P(lb) = 0.49
2. (10 Points) Consider Arithmetic coding with p(a) = 0.5, p(b)=0.3, p(g) = 0.2 and consider
a word that has the encoded value 0.64, and the length of the word is 3. What is the
word? Show your work as you decode.
Solution: decoded word is “bag”
0
0.5
0.8
0.5 0.5
a
b
g
1
a
b
g
0.8
0.65
0.74
g
b
a
0.65
0.62
0.575
Problem 5 (20 Points)
Write in pseudo-code the triangular negotiation protocol. Consider (target QoS) as the input
pair into the triangular negotiation. Assume that the sender initiates the negotiation.
1. (5 Points) Write in pseudo-code the functionality of the sender during the triangular
negotiation.
2. (5 Points) Write in pseudo-code the functionality of the receiver during the triangular
negotiation.
3. (10 Points) Write in pseudo-code the functionality of the service provider (network)
during the triangular negotiation.
Solution: Consider the triangular negotiation protocol:
Sender pseudo-code:
GetFromUser (targetQoS);
desiredQoS = targetQoS;
availableQoS = check(desiredQoS, SenderAvailableResources);
if (availableQoS ≥ desiredQoS) then
{reserveQoS = desiredQoS;
SendRequestToServiceProvider(desiredQoS, senderAdr, receiverAdr);
WaitForResponseFromServiceProvider(answer, senderAdr, ReceiverAdr);
if (answer == reject) then
{ Release reserveQoS; // release also any reserved resources
Inform user that a connection with targetQoS cannot be established;}
if (answer == accept) then
{negotiatedQoS = desiredQoS; //allocate reserved resources
Inform user that connection with targetQoS will be established;}
}
Receiver pseudo-code
GetRequestFromServiceProvider(desiredQoS, senderAdr, receiverAdr);
availableQoS = Check(desiredQoS, ReceiverAvailableResources);
If availableQoS ≥ desiredQoS then
{SendResponseToServiceProvider(accept,senderAdr, receiverAdr);
negotiatedQoS=desiredQoS;}
Else
{SendResponseToServiceProvider (reject, senderAdr, receiverAdr);
Exit(); }
Service Provider Pseudo-Code
getRequestFromSender(desiredQoS, senderAdr, receiverAdr);
availableQoS = Check(desiredQoS, ServiceProviderAvailableResources);
if availableQoS ≥desiredQoS then
{SendRequestToReceiver(desiredQoS, senderAdr, ReceiverAdr);
reservedQoS = desiredQoS; // reserve also corresponding resources
waitForResponseFromReceiver(answer, senderAdr, receiverAdr;
if (answer == reject) then
{SendResponseToSender(answer, senderAdr, receiverAdr);
Release reservedQoS; // release also any reserved resources
Exit();}
If (answer == accept) then
{negotiatedQoS = desiredQoS; // allocate also corresponding resources
SendResponseToSender(answer, senderAdr, receiverAdr); }
}
else
{SendResponseToSender(reject, senderAdr, receiverAdr);
Exit(); }
Problem 6 (15 Points)
Consider three flows with the following shapes:
1. Video flow f1 with the frame size 640x480 pixels, 24 bits per pixel and 30 fps rate
2. Video flow f2 with the characteristics of HDTV format
3. CD quality audio flow f3
These three flows are to be exchanged between the sender A and receiver B. Let us also assume
that all three flows are stored at the sender A, the network packet size to transmit the flow
information is 4 KBytes, the sender A has the maximum available network bandwidth of 100
Mbps and the receiver B has the maximum available bandwidth of 60 Mbps prior to sending any
of the three flows f1, f2, f3. Also, assume that the receiver has an access to the name (e.g., movie
or song name) of each flow.
Perform the following tasks to prepare the end-to-end transmission of the three multimedia
flows:
a. (7 Points) Show how the receiver-driven peer-to-peer negotiation protocol would
work between the sender A and receiver B (Note: specify the steps);
Solution:
Let us assume that A has all the flows characteristics. Then the negotiation protocol between A
and B is as follows:
- B sends a negotiation request to A with the request for flows f1, f2, f3 through their
names for each flow. So the negotiation request will include three names corresponding
to each flow.
- A sends a negotiation response to B. During this process, the following functions are
executed: (1) A does translation from application flows characteristics to network BW,
(2) A does network BW admission; (3) For flows that pass admission tests, reservation
will be done at A; (4) Message with accepted flows and their application characteristics
and network bandwidth requirements are sent to B; (5) B executes network BW
admission for its own network interface; (6) B also stores the application characteristics
for admitted flows; (7) B reserves network BW for admitted flows
- B sends final response to A with final admitted flows at B. During this process, B’s
reserved network BW changes to allocation, and A’s reserved network BW
corresponding to the agreed upon admitted flows at B get allocated.
b. (5 Points) Show how the network bandwidth admission control would be
conducted at the sender and at the receiver side. (Note: show your steps and also
explain if all three flows can be admitted and if yes, why?)
Solution:
f1: PC video BA = 640x480x24x30 = 221184000 bps; 216000 kbps; 210.9375 Mbps
MA = 640x480x24 bits
f2: HDTV video BA = 1920x1080x24x60 = 2916000 Kbps = 2847.65625 Mbps;
MA = 1920x1080x24 bits
f3: CD quality audio BA = 44100x16 = 705600 bps = 0.6729126 Mbps
Let us assume that application PDU size corresponds to amount of bytes carrying audio for
1second, which is then 44100x2 = 88200 Bytes, so MA = 88,200 Bytes (there can be also other
decisions for MA – it depends on the designer, e.g., the designer may put into MA the 1/2 second
of audio data) , and RA is then 1 PDU per second
MN = 4 Kbytes = 4096 bytes = 32768 bits
BN = MN * RN and RN = ┌MA/MN┐ * RA
f1: 32768*6750 bps = 210.9375 , this flow is not accepted at A since 210.9375 Mbps > 100
Mbps
f2 will not be accepted at A since the network BW for the HTDV (2847 Mbps) exceeds the
available network BW 100 Mbps
f3 will be accepted at A since f3’s network BW (0.6875 Mbps) demand will be less that
available network BW at A
Only flow f3 will be included in the negotiation response from A to B and reservation for flow f3
will be made at A first. At B, the admission control result is as follows: f3 is going to be admitted
since BN of f3 is less than 100 Mbps.
c. (3 Points) Show how the translation between the application flows f1, f2, f3 and
their corresponding network flows happens, i.e., what is the application
bandwidth BA and the network bandwidth BN?
Solutions:
BN = MN * RN and RN = ┌MA/MN┐ * RA
For flow f1 BA = 210.9375 Mbps; BN = 210.9375 Mbps
For flow f2 BA = 2847.65 Mbps; BN = 2848.125 Mbps
For flow f3 BA = 0.6729126 Mbps ; BN = 720896 bps = 0.6875 Mbps