Monday, April 30, 2007

forcing file save dialog in web browser

Sometimes we want to download a file from the web browser in stead of opening the contents of the file. If the file is a text or xml file then the default operation for the browser is to open it. Then we have to save the file by File->Save As. But what will happen if you want to invoke the save dialog box of the browser if you click the link. then you have to manually force the response header to tell the browser that this is not a known MIME type. you can set

most of the browser will invoke the default save dialog. but the MSIE will not. halai poora foul. To invoke it from IE you have to add another varialble to the response header.

these codes can be added from html. but most of the times the file is generated in the server end. so here is the java code which reads a
file from the server and passes the file contents to the client through the response header.

FacesContext fc = FacesContext.getNewInstance();
HttpServletResponse response = (
HttpServletResponse) fc.getExternalContext().getResponse();
OutputStream out = null;
InputStream in = null;

response.setHeader("content-disposition=", "attachment;filename=\"myFile.txt\"");

try {
out = response.getOutputStream();
in = new FileInputStream(new File("inputfile.txt");
int i = 0;
while(( != -1) {
fc.responseComplete(); //this is important

} catch (IOException e) {
System.out.println("exception occured: "+ e.getMessage());
} finally {
if(in != null) {
} catch(Exception ex) {

Wednesday, April 25, 2007


Congestion Control: A study on BECN and MaxNet
Maroof Ahmed
Department of Computer Science and Engineering (CSE)
Bangladesh University of Engineering and Technology (BUET)

Congestion is one of the main barriers of proper utilization of packet switched network. Many important researches are done on congestion control mechanisms and still going on. In this paper I will try to focus on a couple of those researches. One is the Backward Explicit Congestion Notification (BECN) technique and the other one is the MaxNet, which ensures MaxMin fairness for reduced transmission rate of sources.

Congestion is a very common thing in a packet switched network. The switches have to maintain some of queue for transmitting data. It has to process the data of the input queue and put them in proper the output queue. If the arrival rate at the input queue is more than the processing rate than congestion occurs.

In this paper at first I have discussed about what congestion is and what techniques can be followed to control congestion. Then I have studied about a popular congestion control mechanism BECN for ATM Network. And then another internet congestion control mechanism MaxNet is discussed. At last the concluding remarks are given.

What is Congestion?
Congestion is an important issue in packet-switched network. Congestion in the network may occur if the load on the network- the number of packets sent to the network- is greater than the capacity of the network- the number of packets a network can handle. Congestion control refers to the mechanisms and techniques to control the congestions and keep the load below the capacity [1].

Congestion Control Mechanisms
Congestion can be prevented, before it happens or it may be removed after it is detected. In general we can divide congestion control mechanism into two broad categories: open loop congestion control (prevention) and closed looped congestion control (removal).

In open loop congestion controls there are some popular policies that can be applied to prevent congestion before it happens. In these mechanisms congestion control is handled by either the source or the destination. Some policies are retransmission policy, window policy, acknowledgment policy, discarding policy, admission policy etc.

Closed loop congestion control mechanism try to alleviate congestion after it happens. Several mechanisms have been used by different protocols. Some popular mechanisms are back pressure, choke point, implicit signaling, explicit signaling, backward signaling, forward signaling etc.

Congestion Control for ATM Network
Congestion control in an ATM network is achieved by exchange of feedback information, carried by the data cell headers or resource management cells. Two feed back congestion control schemes have been proposed to the ATM Forum [2]: rate-based flow control and credit-based flow control.

Rate based schemes make use of feedback information from the network to adjust the rate that the source of each virtual connection (VC) can send cells to the network. BECN has advantages of fast response and fault tolerant against some end system abnormalities. Unlike FECN in which end system does most processing, BECN requires more switch hardware in order not only to generate BECN RM cells but also to filter the information on congestion to prevent over reactive in sending the RM cells.

Credit based flow control schemes operate a link-by-link control by using the information contained in a credit cell (a special RM cell) returned from the receiver to the sender on each link. It adjusts the number of cells to be sent to the receiver to meet the its ability to accept new cells hence avoiding buffer overflow.

Backward explicit congestion notification (BECN) is a congestion avoidance technique. BECN provides a simple and effective traffic management for ATM LAN.

In the LAN all the attached stations share a single resource the shared medium. to transmit, will a station contends for access to the shared medium via the medium excess (MAC) protocol . If the network is heavily loaded it will apply back pressure, through the (MAC) protocol, to stations requesting access. Once a station has successfully gained access to the shared and now you medium it may transmit it’s data without fear of causing network congestion since all stations can receive from at the data rate of the shared medium. The most frequently discussed traffic management approach in ATM network is to determine the traffic characteristics of the source and to allocate resources accordingly you when the call is admitted to the network. this approach is best suited if the traffic is voice or compressed video, that means traffic sources can be accurately characterized in advance of transmission.

In ATM switch there is a queue to hold the incoming traffic. If the queue exceeds a certain threshold value, then it sends congestion notification cells back to the sources of the virtual channels currently submitting traffic to it. The sources that receive BECN cells on a particular virtual channel, it must reduce its transmission rate for the indicated virtual channel. if no BECN cells are received on a particular virtual channel for a certain period of time a source may gradually restore its transmission rate on that virtual channel [3].

In the pictorial representation of BECN in ATM network (Fig 1) we can understand it better. The sources (S) are sending packets to transmitter (T). After a transmission delay the packets reach at receiver (R). If the length of the destination queue exceeds a certain threshold value the Filter (F) generates BECN cells. With no filtering one BECN cell is generated for each incoming cell and returned to the source transmitter of the incoming cell.


Fig 1: BECN in ATM Network

In the Internet all the bottlenecked links contribute in the aggregated congestion signal that controls source rate. But MaxNet is such an architecture [5] that uses only one link, the most severely bottlenecked link, to control the source rate. It produces MaxMin fairness for sources with general homogeneous utility function.

In a MaxNet network, the congestion signal, qi, communicated to source i, is the maximum of all link prices on the end-to-end transmission path, as illustrated in Figure 2. Let pl be the price at link l and Li be the set of links source i uses. Then
qi = max{pl, l in Li}


Fig 2: MaxNet logical feedback loop

The source, l, maximizing pl is termed the controlling link of the path. If multiple sources achieve the maximum, then one is selected arbitrarily. To determine qi, the packet format must include sufficient bits to communicate the complete congestion price. Each link replaces the congestion price in the packet with its own congestion price if its own price is larger than the one in the packet. The congestion signal is relayed back to the source by the destination host in acknowledgment packets.

The behavior of source i is governed by an explicit demand function, Di(•), such that its transmit rate is
xi = Di(qi)
for a congestion signal qi. The link Active Queue Management (AQM) algorithm is the well studied integrator process:
pl(t + 1) = pl(t) + (yl(t) - cl)ρl
where yl(t) = ∑i:lεLixi(t) is the aggregate arrival rate for link l at time t, ρl is the control gain and cl is the target capacity of link l which is related to its physical capacity Cl by the target utilization
0 < µl < cl =" µlCl."

In the conclusion I can say that more efficient and dedicated congestion mechanism should be developed for better use of network bandwidth. Further research can be done on multilayered and hybrid congestion control mechanisms. In the future I have plan to stimulate the congestion control mechanisms I have discussed here.

[1]Forouzan B.A., “Data Communications and Networking”, 7th ed, page-636
[2] Qin Li and Zheng Wang, “A Comparison Study of Congestion Control for ABR Service in ATM Networks”
[3] Peter Newman, “Backward Explicit Congestion Notification for ATM Local Area Networks”
[4] Frank Akujobi, Ioannis Lambadaris, Rupinder Makkar Nabil Seddigh, Biswajit Nandy, “BECN for Congestion Control in TCP/IP Networks: Study and Comparative Evaluation”
[5] Bartek Wydrowski, Moshe Zukerman, “MaxNet: A congestion control architecture”