## GATE-Computer Networks-Flow Control

Previous GATE questions with solutions on Computer Networks (Flow Control) - CS/IT

GATE -2015
1. Since it is a network that uses switch, every packet goes through two links, one from source to switch and other from switch to destination.
Since there are 10000 bits and packet size is 5000, two packets are sent. Transmission time for each packet is 5000 / 107 seconds
Two hosts are connected via a packet switch with 107 bits per second links. Each link has a propagation delay of 20 microseconds. The switch begins forwarding a packet 35 microseconds after it receives the same. If 10000 bits of data are to be transmitted between the two hosts using a packet size of 5000 bits, the time elapsed between the transmission of the first bit of data and the reception of the last bit of the data in microseconds is _________.
(a) 1075      (b) 1575        (c) 2220         (d) 2200

Ans: option (b)
Explanation:
It is given that there are 10,000 bits and since the packet size id 5000 it means we have 2 packets to send.
Transmission time for one packet = 5000 / 107 seconds = 500μs
Transmission time is the time taken to transmit a packet from host to the outgoing link.

It is also given that the propagation delay of links is 20μs.  Propagation delay is the time taken by a bit to reach from sender to receiver (in this case from sender to switch it is 20μs and from switch to receiver it 20μs)

Time for the first packet (P1) to reach switch =Transmission time + Propagation delay
=500μs + 20μs = 520μs
Once P1 reaches the switch, the switch will take 35μs to process the packet and then it takes 500μs to transmit it to the link and then the packet will take 20μs to reach the receiver.
Therefore Time taken by P1 to reach from switch to receiver = 35μs + 500μs+ 20μs = 555μs
Therefore time taken by P1 to reach from sender to receiver = 520μs+555μs = 1075μs

But we need to note that after 520μs the switch starts receiving second packet (P2).
i.e. At 520μs+500μs = 1020μs P2 is completely received by switch.
Now Time taken by P2 to reach from switch to receiver = 35μs + 500μs+ 20μs = 555μs
It means that at  1575μs (1020μs+555μs) P2 reaches the destination.

Gate-2015
2. Suppose that the stop-and-wait protocol is used on a link with a bit rate of 64 kilobits per second and 20 milliseconds propagation delay. Assume that the transmission time for the acknowledgement and the processing time at nodes are negligible. Then the minimum frame size in bytes to achieve a link utilization of at least 50% is_________________.
(a) 160      (b) 320      (c) 640      (d) 220

Ans: option (b)
Explanation:
Since the link utilization should be atleast 50% it means that efficiency, η 50%
Since it is mentioned that it is a stop&wait protocol, the efficiency of the link can be calculated as below:
η =  1 /( 1 + 2a)
a = Tp/Tt (where Tp = Propagation delay & Tt = Transmission Time)
Lets see the length of the packet to achieve a link utilization of 50%
50/100 = 1 /( 1 + 2a)
1/2 = 1 /( 1 + 2a)
a = 1/2
Tp/Tt = 1/2
20/Tt=1/2
Tt = 40ms
Tt = transmission time = L/B (where L = length of packet and B = bandwidth)
L/B = 40
L =40 * B = 40 ms * 64 Kbps = 40*10-3 *64*103 = 2560 bits
Since we need to determine the frame size in bytes L = 2560/8 = 320 bytes.
Therefore, the minimum frame size in bytes to achieve a link utilization of at least 50% is 320bytes

## ISRO Questions - C/C++ Programming

INDIAN SPACE RESEARCH ORGANISATION
Recruitment Entrance Test for Scientist/Engineer
Previously asked questions on C/C++ Programming

ISRO May 2017
1. What is the output of this C++ program?
```#include <iostream>
using namespace std;
void square (int *x)
{
*x = (*x)++ * (*x);
}
void square (int *x, int *y)
{
*x = (*x) * --(*y);
}

int main ( )
{
int number = 30;
square(&number, &number);
cout << number;
return 0;
}
```

(a) 910    (b) 920     (c) 870     (d) 900

Ans: option (c)
Explanation:
Starting from main function. number variable has been initialized to 30. We pass address of number as parameters in the square function. As per the concept of function overloading in C++ the second square function will be executed.
--(*y) will be executed first since decrement operator has the higher precedence than multiplication.
Therefore,
*x = (*x) * --(*y);
*x = 30 * 29;
*x = 870

x is a pointer variable and it holds the address of the variable number. Therefore the value of 870 is now stored to number after the execution of *x = (*x) * --(*y); expression. Hence 870 will be printed.

Other points:
1. iostream is a header file. Header files are included in C/C++ because they have some inbuilt predefined functions.
2. Purpose of using namespace std; - When you make a call to using namespace <some_namespace>; all symbols in that namespace will become visible without adding the namespace prefix. If you do not add that statement you need to call cout << number; like this std::cout << number; else you get the error 'cout' was not declared in this scope.
3. Function overloading is a feature in C++ where two or more functions can have the same name but different parameters. Difference in parameters can be in terms of number of parameters as we saw in the case of square function or difference can be in terms of data type also. For example refer: https://www.geeksforgeeks.org/function-overloading-c/

## Ionic 3 Build Android App - Create apk file which can be installed in an android device

Steps to create an apk file using ionic 3

\$ ionic cordova add platform android

Step 2: Go to platforms/android

\$ cd platforms/android

Note: Add the location of the bin folder of the JDK installation in the PATH Environment Variable

Step 3: Generate Keystore file

\$ keytool -genkey -v -keystore some_name.keystore -alias some_name-keyalg RSA -keysize 2048 -validity 10000

You should enter a password during the generation of some_name.keystore. Remember this passoword and keep some_name.keystore in a safe place.

Step 4: Open build.gradle file in platforms/android and search for the section signingConfigs. Make changes as shown below.

signingConfigs {
release {
// These must be set or Gradle will complain (even if they are overridden).
keyAlias = "some_name"
keyPassword = "your_password" // And these must be set to non-empty in order to have the signing step added to the task graph.
storeFile = "some_name.keystore"
}
}

Step 5: Go to your root folder of the project

\$ cd ../../

Step 6: Build

\$ ionic cordova build android --release

If successful you will get the following message
...
...
BUILD SUCCESSFUL

Total time: 45.593 secs
Built the following apk(s):
path_root_folder/platforms/android/build/outputs/apk/android-release-unsigned.apk

Step 7: Sign the apk

\$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore platforms\android\some_name.keystore platforms\android\build\outputs\apk\android-release-unsigned.apk some_name

Note: Add the location of the Android sdk build tools folder in the PATH Environment Variable.

Step 8: Zipalign

\$ zipalign -v 4 platforms\android\build\outputs\apk\android-release-unsigned.apk Some_Name.apk

You will find the generated apk file in the root folder of your project. Generated apk file is now ready to be installed in your android phone.

## Kerala PSC HSST Computer Science Previous Questions - Set 3

Q1. For some page–replacement algorithms, the page-fault rate may increase as the number of allocated frames increases. This is known as:
(A) Thrashing
(B) Swapping
(D) Fragmentation

Q2. The Unix inode contains ___________ pointers to data blocks and _________ pointers to indirect blocks.
(A) 10,3
(B) 10,5
(C) 12,3
(D) 15,5

Q3. Which of the following disk scheduling algorithms may result in starvation?
(A) FCFS
(B) Shortest-seek-time-first
(C) SCAN
(D) C-SCAN

Q4. An RPC uses ______________ to execute a routine on a remote system.
(A) FTP
(B) TFTP
(C) TCP
(D) UDP

Q5.  'Location transparency' in distributed systems means that:
(A) Name of the file does not reveal any hint of its physical storage location
(B) Name of the file does not need to be changed when the storage location changes
(C) The storage location can be understood from the name of the file
(D) Name of the file will change if the storage location changes

Q6. The BSD version of UNIX was developed by:
(A) Bell Labs
(B) MIT
(C) University of Berkeley
(D) Sun Microsystems

Q7.  An example of a file system whose contents are not actually stored anywhere, but are computed on demand is:
(A) NTFS
(B) NFS
(C) proc
(D) ext3

Q8. Which among the following is a type of top-down parsing?
(A) Predictive parsing
(B) Shift-reduce parsing
(C) Operator precedence parsing
(D) LR parsing

Q9.  If r and s are regular expressions denoting languages L(r) and L(s), then (r)|(s) is a regular expression denoting:
(A) L(r) U L(s)
(B) L(r) L(s)
(C) {E}
(D)  L(rs)

Q10. What will the following program fragment output?
Integer i=new integer (5);
Integer j=new Integer (5);
If (i==j)System.out.println(“Equal”);
else System.out.println(“Not equal”);
(A) Equal
(B) Not Equal
(C) Equal Not equal
(D) The program doesn’t compile= = can’t be used with references

## Kerala PSC HSST Computer Science Previous Questions - Set 2

Q1. The solution to the count-to-infinity problem in which a router never advertises the cost of a destination to its neighbour N, if N is the next hop to that destination, is called:
(A) Triggered update
(B) Source tracing
(C) Split-horizon
(D) Path vector

Q2. A compiler which runs on one machine and produces target code for another is called a:
(A) Bootstrapping compiler
(B) Just-in-time compiler
(C) Cross compiler
(D) Optimizing compiler

Q3.Which among the following is an interior routing protocol?
(A) OSPF
(B) EGP
(C) BGP
(D) NNTP

Q4. The maximum length (in bytes) of an IP packet:
(A) 255
(B) 1023
(C) 32767
(D) 65535

Q5. Which among the following is not a type of HTTP request?
(A) GET
(C) RELEASE
(D) POST

Q6. Which among the following is not a real time operating system?
(A) RT-Linux
(B) VxWorks
(C) Solaris
(D) Lynx

Q7. What is returned by a fork() call to the child process?
(A) 0
(B) Process-id-pf parent
(C) Process-id of child
(D) -1

Q8. The degree of multiprogramming is controlled primarily by?
(A) Short-term scheduler
(B) Medium-term scheduler
(C) Long-term scheduler
(D) Disk scheduler

Q9. Which of the following is a high-level synchronization concept?
(A) Interrupt
(B) Semaphore
(C) Mutex
(D) Monitor

Q10. Paging solves the problem of:
(A) Thrashing
(B) Page faults
(C) Internal fragmentation
(D) External Fragmentation

## Kerala PSC HSST Computer Science Previous Questions - Set 1

Q1. The size of an ATM cell is .............. bytes.
(A) 25
(B) 32
(C) 53
(D) 64

Q2. Stored program concept is attributed to:
(A) Ken Thompson
(B) Dennis Ritchie
(C) Von Neumann
(D) Edsger Dijkstra

Q3. In a UNIX system, the macro htons is used to:
(A) Convert a short number from host to network order
(B) Convert a long number from host to network order
(C) Convert a short number from network to host order
(D) Convert a long number from network to host order

Q4. The cache which is on the same chip as the processor is called :
(A) L1
(B) L2
(C) L3
(D) None of these

Q5. Which IEEE standard is refers to fast Ethernet?
(A) 802.1
(B) 802.3b
(C) 802.3u
(D) 802.12

Q6. Which level of RAID uses mirroring to achieve redundancy?
(A) 0
(B) 1
(C) 2
(D) 3

Q7. The new generation Intel processor with the IA-64 architecture is called
(A) Itanium
(B) Pentium 4
(C) Athlon
(D) Xeon

Q8. A MAC address is ............. bytes long:
(A) 4
(B) 6
(C) 8
(D) 12

Q9. RARP is used to convert:
(C) IP address to port number
(D) Port number to IP address

Q10. Which among the following is an NP-Complete problem?
(A) 3SAT Problem
(B) Travelling Salesman
(D) Graph 3-coloring
(D) All of the above

## Installing Laravel in Ubuntu 16.04

First install composer. Refer http://www.btechonline.org/2017/08/installing-composer-globally-in-ubuntu.html

`\$ composer global require "laravel/installer"`

Edit environment config:
`\$ nano .bashrc`
Note: If the above fails due to permissions, you may need to run it again with sudo.

Add the below line to the end of the file:
export PATH="\$PATH:\$HOME/.config/composer/vendor/bin"

`\$ source ~/.bashrc`

To verify:
`\$ laravel`

You will get a similar output as shown below:
Laravel Installer 1.3.3

Usage:
command [options] [arguments]

Options:
-h, --help            Display this help message

-q, --quiet           Do not output any message