Wednesday, 8 March 2017

What is Character Count ?

This method uses a field in the header to specify the number of characters in the frame. When the data link layer at the destination sees the character count,it knows how many characters follow, and hence where the end of the frame is. The disadvantage is that if the count is garbled by a transmission error, the destination will lose synchronization and will be unable to locate the start of the next frame. So, this method is rarely used.


#include<stdio.h>
#include<string.h>
#include<math.h>
main()
{
int ssize,rsize;
char str[20];
printf("Enter the string:");
gets(str);
ssize=strlen(str);
printf("\nSize of the string send by the sender:%d",ssize);
printf("\nEnter the size received by the receiver:");
scanf("%d",&rsize);
if(ssize == rsize)
printf("Hence the frame ends at %d",rsize);
else
printf("\nThere's an error");
}

OUTPUT:
charctercount

What is ISO-OSI model ?

The Open Systems Interconnection model (OSI model) implementation is a conceptual model that characterizes and standardizes the communication functions of a telecommunication or computing system without regard to their underlying internal structure and technology. Its goal is the interoperability of diverse communication systems with standard protocols. The model partitions a communication system into abstraction layers. The original version of the model defined seven layers.
A layer serves the layer above it and is served by the layer below it. For example, a layer that provides error-free communications across a network provides the path needed by applications above it, while it calls the next lower layer to send and receive packets that comprise the contents of that path. Two instances at the same layer are visualized as connected by a horizontal connection in that layer.
Data processing by two communicating OSI-compatible devices is done as such:
  1. The data to be transmitted is composed at the topmost layer of the transmitting device (layer N) into a protocol data unit (PDU).
  2. The PDU is passed to layer N-1, where it is known as the service data unit (SDU).
  3. At layer N-1 the SDU is concatenated with a header, a footer, or both, producing a layer N-1 PDU. It is then passed to layer N-2.
  4. The process continues until reaching the lowermost level, from which the data is transmitted to the receiving device.
  5. At the receiving device the data is passed from the lowest to the highest layer as a series of SDUs while being successively stripped from each layer’s header and/or footer, until reaching the topmost layer, where the last of the data is consumed.

Implementation of ISO-OSI model in c


//OSI Model (encapsulation and decapsulation process)
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>//for linux to run sleep command
#include<windows.h>//for windows to run sleep command
main(){
printf("\n\t\t ISO-OSI Model");
printf("\nLAYERS Sender Side");
printf("\nAPPLICATION LAYER !! AH !! DATA");
Sleep(1);
printf("\nPRESENTATION LAYER !! PH!!AH!!DATA");
Sleep(1);
printf("\nSESSION LAYER !! SH !!PH!!AH!!DATA");
Sleep(1);
printf("\nTRANSPORT LAYER!!TH!!SH!!PH!!AH!!DATA");
Sleep(1);
printf("\nNETWORK LAYER!!NH!!TH!!SH!!PH!!AH!!DATA");
Sleep(1);
printf("\nDATALINK LAYER!!DH!!NH!!TH!!SH!!PH!!AH!!DATA!!CRC");
Sleep(1);
printf("\nPHYSICAL LAYER 100100101010101110001010010");
Sleep(1);
printf("\n\nLAYERS Receiver Side");
printf("\nPHYSICAL LAYER 100100101010101110001010010");
Sleep(1);
printf("\nDATALINK LAYER!!DH!!NH!!TH!!SH!!PH!!AH!!DATA!!CRC");
Sleep(1);
printf("\nNETWORK LAYER!!NH!!TH!!SH!!PH!!AH!!DATA");
Sleep(1);
printf("\nTRANSPORT LAYER!!TH!!SH!!PH!!AH!!DATA");
Sleep(1);
printf("\nSESSION LAYER !! SH !!PH!!AH!!DATA");
Sleep(1);
printf("\nPRESENTATION LAYER !! PH!!AH!!DATA");
Sleep(1);
printf("\nAPPLICATION LAYER !! AH !! DATA");
Sleep(1);
}

OUTPUT:


Implementation of ISO-OSI Model
Implementation of ISO-OSI Model
References:
  • https://en.wikipedia.org/wiki/OSI_model

Network Commands


title
1) ping
The ping command (named after the sound of an active sonar system) sends echo requests to the host specified on the command line, and lists the responses received.

Syntax: ping ipAddress or hostname
e.g
ping www.technerds.in ping – sends an ICMP ECHO_REQUEST packet to the specified host. If the host responds, an ICMP packet is received. One can “ping” an IP address to see if a machine is alive. It provides a very quick way to see if a machine is up and connected to the network. Output
2) netstat
It works with the LINUX Network Subsystem, it will tell us what the status of ports are ie. open, closed, waiting connections. It is used to display the TCP/IP network protocol statistics and information.
e.g netstat
netstat -a
3) tcpdump
This is a sniffer, a program that captures packets off a network interface and interprets them.
3) hostname
Tells the user the host name of the computer they are logged into.
e.g hostname
4) traceroute (In Windows use tracert )
traceroute will show the route of a packet. It attempts to list the series of hosts through which our packets travel on their way to a given destination.
Command syntax: traceroute machineName or ip
e.g traceroute wwwtechnerds.in
Each host will be displayed, along with the response times at each host.
Output
5) finger
Retrieves information about the specified user.
e.g finger bce8001
Output
6) ifconfig ( In Windows use ipconfig )
This command is used to configure network interfaces, or to display their current configuration.
e.g /sbin/ifconfig
/sbin/ifconfig -a
Output
7) dig
The “domain information groper” tool. If a hostname is given as an argument, it outputs information about that host, including it’s IP address, hostname and various other information.
e.g dig technerds
8) telnet telnettelnet
telnet allows you to log in to a computer, just as if you were sitting at the terminal. Once your username and password are verified, you are given a shell prompt. From here, you can do anything requiring a text console.
e.g telnet bce0753
9) ftp
To connect to an FTP server.
Syntax: ftp ipaddress
e.g ftp 192.168.0.15
Output
10) nslookup
nslookup returns the ipaddress of the given hostname and vice versa.
e.g nslookup www.technerds.in
Output

What is Bit Stuffing and Destuffing ?

In data transmission and telecommunication, bit stuffing (also known—uncommonly—as positive justification) is the insertion of non information bits into data. Stuffed bits should not be confused with overhead bits. The opposite is called destuffing.
Only text ;
 Flag is any char. not used in text
 But any pattern used for flag can also be part of the
information
 The receiver will encounter this pattern in the
middle of the data, assume it as the end of frame.
 To fix this Byte stuffing strategy was added.
Byte stuffing
 A special byte is added to the data section of the
frame when there is character with the same pattern
as the flag.
 The data section is stuffed with a extra byte
 This byte is usually called the escape character
(ESC), which has a predefined bit pattern.
 When encountered remove it from data
 Treat the next character as data , not as flag
fig1
Byte stuffing is the process of adding 1 extra byte whenever there is a flag or escape character in the text.
 The data section of a frame is a sequence of bits to be
interpreted by the upper layer as text, audio etc.
 In addition to header and trailers there is a need for
delimiter to separate one frame from the other.
 Special 8 bit pattern flag 0111 1110 as delimiter
 Same type of problem.
 Not the end of frame.
Stuffing 1 bit (instead of 1 byte) to prevent the
pattern from looking like a flag.
 This strategy is called bit stuffing
 In bit stuffing, if a 0 and five consecutive 1 bits are
encountered, an extra 0 is added
 This extra stuffed bit is eventually removed from the
data by the receiver.
 This guarantees that the flag field sequence does not
appear in the frame
fig2
Bit stuffing is the process of adding one extra 0 whenever five consecutive 1s follow a 0 in the data, so that the receiver does not mistake the pattern 0111110 for a flag.
fig3
C Program To Find Bit Stuffing And Destuffing In C

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include<stdio.h>
#include<stdlib.h>
int main()
{
char *p,*q;
char temp;
char in[100];
char stuff[100];
char destuff[100];
int count=0;
printf("enter the input character string (0‘s & 1‘s only):\n");
scanf("%s",in);
p=in;
q=stuff;
while(*p!='\0')
{
if(*p=='0')
{
*q=*p;
q++;
p++;
}
else
{
while(*p=='1' && count!=5)
{
count++;
*q=*p;
q++;
p++;
}
if(count==5)
{
*q='0';
q++;
}
count=0;
}
}
*q='\0';
printf("\nthe stuffed character string is");
printf("\n%s",stuff);
p=stuff;
q=destuff;
while(*p!='\0')
{
if(*p=='0')
{
*q=*p;
q++;
p++;
}
else
{
while(*p=='1' && count!=5)
{
count++;
*q=*p;
q++;
p++;
}
if(count==5)
{
p++;
}
count=0;
}
}
*q='\0';
printf("\nthe destuffed character string is");
printf("\n%s\n",destuff);
return 0;
}
OUTPUT:
bitstuff

REFERENCES: