Grade_Ben_EE442 project.doc
Transcript of Grade_Ben_EE442 project.doc
EE442 Mutilmedia Network
TERM PROJECT
A Simple On-line VCR
Member:
Instruction: Dr. Dong
ContentI. Introduction 3
1
II. RTP packetization 4III. Experiment and Result 6
Local host 6LAN 7Internet 8
IV. Conclusion 9V. Appendix 11
RTPpacket.java 11Client.java 15
I. Introduction
In this term project, A Simple On-line VCR, is going to create a
Java programming using java system to connect the server side and
client side. Also, using Real-Time Streaming Protocol (RTSP) and
Real-Time Transfer Protocol (RTP) to implement a streaming video
server, client and send data on this project. Streaming server
approach supports real-time streaming protocol and RTP/RTCP faster
than old approach conventional web server and better quality.
2
The relationship between server and client showing below:
II. RTP packetization
In this term project, the most important thing is to implement the
RTP packetization in the server. The basic features in RTP are:
1. Sequence number-reorder packets.
2. Timestamp (synchronization): tell receiver what is
corresponding display time, and using timestamp to provide
relationship between display time of different media.
3. Multiple source identifier-ability to support multiple media bit
3
streams simultaneously.
**Data encapsulation for RTP packet**
There are four classes in this project, first is Client, second is
Server, third is RTPpacket, and fourth is VideoStream. But, there is
only one class need to work on the project that is RTPpacket. This
RTPpacket class needs to work together with server to send out RTP
packet.
On the above, this is the relationship between Server and Client
that needs to design in this project. RTP header field in this project
including
1. Version is two bits, set this to 2.
2. Padding is one bit, set this to Zero.
3. Extension is one bit, set this to Zero.
4
4. CSRC is four bits, set this to Zero.
5. Marker is one bit, set this to Zero.
6. Payload type (PT) is 7 bits, the MJEPG type number is 26.
7. Sequence number is 16 bits.
8. Timestamp is 32 bits.
9. SSRC is 32 bits. Pick any integer number on this task.
** The image gets form EE442 slide**
RTP standard header is 12-byte, maybe be longer with CSRC and
extension. This picture in the blow shows how to defined RTP
standard header is 12-byte.
III. Experiments and results
I change the client code to calculate the packet loss rate. The settings for running
program are three spaces: local host, LAN, and Internet.
5
Local host:In the local host, the client can receive most packets. The packet loss rate is almost
equal to zero, but the results have the difference on the different computer situations.
Testing equipment:
Hardware: IBM PowerPC G4 1.33GHz, 768MB DDR SD-RAM, 5400cps 60G HD.
Software : MAC OS X 10.4.3 based on UNIX.
1. Idle situation: the computer do not run any unnecessary program and shut
down any background programs. It only runs the JAVA and terminal
program. The CUP used rate is 90% idle at least. The packet loss rate is zero.
2. Light working situation: the sitting is that the original users surf on the
Internet, listen to the music, and type the document. The computer runs the
media player software, browser software, and paper work software. The
CPU used rate is 60~90% idle. The packet loss rate is 14.2% average.
3. Heavy working situation: the sitting is that the computer runs many
programs needed more computation, like image/video software, mathematic
software. Let the testing computer to run the MALTAB and Photoshop. The
CUP used rate is average lower than 60% idle. The packet loss rate is
6
47.20% average.
LAN:In the LAN environment, define that the paths between server and client have 3
ways: don’t through router, through routers, and through wireless network.
1. Don’t through router: the sittings of the server and client are the same IP
range. The server connects with c
2. Error! No index entries found.
3. lient by Ethernet through a hub. The packet loss rate is average 1.2%.
4. Through router: the sittings of the server and client are in the local
network, but not in the same IP range. If tracing the network, there are one
router between the server and client. The packet loss rate is 6.2%
5. Through wireless network: the sittings of the server and client are in the
local network, and two computers connect by the wireless network
station. The packet loss rate is average 1.6%
Internet:
In the Internet, define three connection ways between the server and client:
connection in the LA area, in the America, and international connection.
7
1. In the LA area: the sittings of the server and client are both around the Los
Angeles. If tracing the network, the delay time is 80ms, and the packets go
through four routers. The packet loss rate is 16.2%
2. In the America: server is in the Michigan, and the client is in the LA. Tracing
the network, there are at least 20 routers between the server and client, and the
delay time is 121.66ms. The packet loss rate is 22.2%
3. International connection: the sitting of the server is using the 64kbps upload
rate in Taiwan. If tracing the server, the tracing time is 233.56ms and the
routers between server and client are 32 routers. The packet loss rate is 35.8%.
IV. Conclusion
After the experiment, we have the conclusions as following:
8
1. The condition of the client is decided the quality of the video. The client
computer displays the receiving packet without delay. If the computer is in the
busy state, the CPU will spend other computation to run the program. It will
lose some packets if the CPU does not listen the port.
2. Wireless network can still maintain the quality of the video. Using the IEEE
802.11b, the client can receive most packets in the transmission. The packet
loss rate using the wireless network is not larger than the rate using the RJ-54
line to connect to the network.
3. The number of routers between the server and client is decided the delay time.
Using the TRACE and PING program, we can know how many routers
between the server and client, and how long of the delay time. The more
routers are between server and client, the greater delay time and the packet
loss rate are occurred.
4. The firewall is very important in the RTP protocol. There are many trouble
during the experiment, like the server receives the PLAY command and sends
the RTP packet out, but the client does not receive any packet at all, or
sometime the client can receive the RTP packets, but sometime the client
cannot receive any packet. Like the wireless station in my home, it will block
the UDP packet. Some routers block the UDP packet, but some routers do not.
If the packets pass through the routers that will block the UDP packet, the
client will not receive any packet, but in this time the packets pass through the
other routers that will not block the UDP packet, the client will receive the
packets. It is called datagram approach.
5. The capacity is not the limit of the fluent video. In the experiment,
transmitting from server using the higher data rate is not better than
transmitting from using the lower data rate. Using the higher data rate to
receive the packet is not greater than using the lower data rate to receive. But
the conclusion is not included the two problems: traffic jamming and packet
rate. As the technology, the high-speed data rate has the lower packet loss rate
in the Internet jamming. But in the experiment, it is hard to simulate the
network jamming, so the result does not consider the network jamming. And if
using the slower data upload rate, it will decrease the packet loss rate, but data
rate is in the network layer, not in the application. The data rate is not
considered in the experiment.
Though using the RTP packets has many confinements in the experiment, there
are many ways to get the better result.
9
1. Using the TCP protocol to pass through the firewall. Like the RTSP, it usually
uses the RTP/UDP protocol to transmit the video stream, but if the server
detects the firewall blocking the UDP packets, it will use the TCP protocol.
2. Using the error control. In the experiment, the server transmits the motion-
JPEG type video, so if there are several packets loss, it does not matter for the
media player. But it will become the big problems if the server transmits the
compressed video. Though the error control is in the network layer, it can be
used the software to simulate in the application layer. Like receiver-based
retransmission, the software can include the part of the Selective-Reject ARQ,
add the receive-ready packet sent from the client, and insert the time delay
consideration like RTT, timeout.
3. Adding the buffer, lagging the playing time, and reduce the video size. Using
the error control, the client can use the bigger buffer space and lag the playing
time. When the client receives enough packets, it plays the video from buffer,
not plays when the client receives the packets. Though increasing the waiting
time, the user can get the better quality and full part of the video. Reducing the
video size, the server can send the fewer packets. It is the other way to
decrease the packet loss rate.
10
V. Appendix: RTPpacket.java & client.java
RTPpacket.java
public class RTPpacket{
static int HEADER_SIZE = 12;
public int Version;
public int Padding;
public int Extension;
public int CC;
public int Marker;
public int PayloadType;
public int SequenceNumber;
public int TimeStamp;
public int Ssrc;
public byte[] header;
public int payload_size;
public byte[] payload;
public RTPpacket(int PType, int Framenb, int Time, byte[] data, int
data_length){
//fill by default header fields:
// To complete
Version = 2;
Padding = 0;
Extension = 0;
CC = 0;
Marker = 0;
Ssrc = 1111;
SequenceNumber = Framenb;
TimeStamp = Time;
PayloadType = PType;
11
header = new byte[HEADER_SIZE];
header[0] = (byte)(Version << 6);
header[0] = (byte)(header[0] | Padding << 5);
header[0] = (byte)(header[0] | Extension << 4);
header[0] = (byte)(header[0] | CC);
header[1] = (byte)(header[1] | Marker << 7);
header[1] = (byte)(header[1] | PayloadType);
header[2] = (byte)(SequenceNumber >> 8);
header[3] = (byte)(SequenceNumber & 0xFF);
header[4] = (byte)(TimeStamp >> 24);
header[5] = (byte)(TimeStamp >> 16);
header[6] = (byte)(TimeStamp >> 8);
header[7] = (byte)(TimeStamp & 0xFF);
header[8] = (byte)(Ssrc >> 24);
header[9] = (byte)(Ssrc >> 16);
header[10] = (byte)(Ssrc >> 8);
header[11] = (byte)(Ssrc & 0xFF);
payload_size = data_length;
payload = new byte[data_length];
for (int i = 0; i < data_length; i++){
payload[i] = data[i];
}
}
//--------------------------
// RTP packetization at receiever
//--------------------------
public RTPpacket(byte[] packet, int packet_size)
{
Version = 2;
Padding = 0;
Extension = 0;
CC = 0;
Marker = 0;
12
Ssrc = 1111;
//check if total packet size is lower than the header size
if (packet_size >= HEADER_SIZE)
{
header = new byte[HEADER_SIZE];
for(int i = 0; i < HEADER_SIZE; i++){
header[i] = packet[i];
}
payload_size = packet_size - HEADER_SIZE;
payload = new byte[payload_size];
for(int j = HEADER_SIZE; j < packet_size; j++){
payload[j - HEADER_SIZE] = packet[j];
}
PayloadType = header[1] & 127;
SequenceNumber = unsigned_int(header[3]) +
256*unsigned_int(header[2]);
TimeStamp = unsigned_int(header[7]) + 256*unsigned_int(header[6]) +
65536*unsigned_int(header[5]) + 16777216*unsigned_int(header[4]);
}
}
//--------------------------
//getpayload: return the payload bistream of the RTPpacket and its size
//--------------------------
public int getpayload(byte[] data) {
for (int i=0; i < payload_size; i++)
data[i] = payload[i];
return(payload_size);
}
//--------------------------
//getpayload_length: return the length of the payload
//--------------------------
public int getpayload_length() {
13
return(payload_size);
}
//--------------------------
//getlength: return the total length of the RTP packet
//--------------------------
public int getlength() {
return(payload_size + HEADER_SIZE);
}
//--------------------------
//getpacket: returns the packet bitstream and its length
//--------------------------
public int getpacket(byte[] packet)
{
//construct the packet = header + payload
for(int i = 0; i < HEADER_SIZE; i++)
packet[i] = header[i];
for(int j = 0; j < payload_size; j++){
int k = j + 12;
packet[k] = payload[j];
}
//return total size of the packet
return(payload_size + HEADER_SIZE);
}
//--------------------------
//gettimestamp
//--------------------------
public int gettimestamp() {
return(TimeStamp);
}
//--------------------------
//getsequencenumber
//--------------------------
public int getsequencenumber() {
14
return(SequenceNumber);
}
//--------------------------
//getpayloadtype
//--------------------------
public int getpayloadtype() {
return(PayloadType);
}
//--------------------------
//print headers without the SSRC
//--------------------------
public void printheader()
{
for (int i=0; i < (HEADER_SIZE-4); i++)
{
for (int j = 7; j>=0 ; j--)
if (((1 << j) & header[i]) != 0)
System.out.print("1");
else
System.out.print("0");
System.out.print(" ");
}
System.out.println();
}
//return the unsigned value of 8-bit integer nb
static int unsigned_int(int nb) {
if (nb >= 0)
return(nb);
else
return(256+nb);
}
15
}
The changed part of the client.java
class tearButtonListener implements ActionListener {
public void actionPerformed(ActionEvent e){
… CONTRACTION…
//Wait for the response
if (parse_server_response() != 200)
System.out.println("Invalid Server Response");
else
{
//change RTSP state and print out new state
state = INIT;
System.out.println("New RTSP state: INIT");
//ADD THE PART OF THE RATIO OF PACTKET LOSS
System.out.println("There are "+packetlossNo+" packets loss.");
float b = (float)(packetlossNo) / (float)(packetSN) * 100;
System.out.println("The packet loss rate is "+b+"%.");
//stop the timer
timer.stop();
//exit
System.exit(0);
}
}
}
class timerListener implements ActionListener {
16
public void actionPerformed(ActionEvent e) {
…CONTRACTION…
//print important header fields of the RTP packet received:
System.out.println("Got RTP packet with SeqNum #
"+rtp_packet.getsequencenumber()+" TimeStamp
"+rtp_packet.gettimestamp()+" ms, of type "+rtp_packet.getpayloadtype());
// ADD THE PART FOR CALCULATING THE LOSS PACKETS
packetSN = rtp_packet.getsequencenumber();
if (packetSN != periodSN + 1){
int a = packetSN - periodSN;
System.out.print("loss " +a+" packets.\n");
packetlossNo = packetlossNo + a;
}
periodSN = packetSN;
//print header bitstream:
rtp_packet.printheader();
… CONTRACTION…
}
17