0% found this document useful (0 votes)
3 views

CC LAB Week_1 to week _5

Uploaded by

22211a3232
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

CC LAB Week_1 to week _5

Uploaded by

22211a3232
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Week1:Study of Different types of cables and network IP

Aim: Study of different types of Network cables and Practically implement the cross -wired cable
and straight through cable using clamping tool.
Apparatus(Components):RJ-45connector,ClimpingTool,TwistedpairCable

Procedure:To do these practical following steps should be done:

Study of Different types of cables

This experiment explains the types of network cables used in computer networks in
detail.
Learn the specifications, standards, and features of the coaxial cable, twisted-pair
cable, and the fiber-optical cable.

To connect two or more computers or networking devices in a network, network cables


are used. There are three types of network cables; coaxial, twisted-pair, and fiber-optic.

Coaxial cable

Coaxial cable This cable contains a conductor, insulator, braiding, and sheath. The
sheath covers the braiding, braiding covers the insulation, and the insulation covers the
conductor.
Sheath

This is the outer layer of the coaxial cable. It protects the cable from physical damage.

Braided shield

This shield protects signals from external interference and noise. This shield is built from
the same metal that is used to build the core.

Insulation

Insulation protects the core. It also keeps the core separate from the braided shield. Since
both the core and the braided shield use the same metal, without this layer, they will
touch each other and create a short-circuit in the wire.

Conductor

The conductor carries electromagnetic signals. Based on conductor a coaxial cable can
be categorized into two types; single-core coaxial cable and multi-core coaxial cable.

A single-core coaxial cable uses a single central metal (usually copper) conductor, while
a multi-core coaxial cable uses multiple thin strands of metal wires. The following
image shows both types of cable.
Twisted-pair cables
The twisted-pair cable was primarily developed for computer networks. This cable is
also known as Ethernet cable. Almost all modern LAN computer networks use this
cable.

This cable consists of color-coded pairs of insulated copper wires. Every two wires are
twisted around each other to form pair. Usually, there are four pairs. Each pair has one
solid color and one stripped color wire. Solid colors are blue, brown, green, and orange.
In stripped color, the solid color is mixed with the white color.

Based on how pairs are stripped in the plastic sheath, there are two types of twisted-pair
cable; UTP and STP.

In the UTP (Unshielded twisted-pair) cable, all pairs are wrapped in a single plastic
sheath.

In the STP (Shielded twisted-pair) cable, each pair is wrapped with an additional metal
shield, then all pairs are wrapped in a single outer plastic sheath.

Similarities and differences between STP and UTP cables

• Both STP and UTP can transmit data at 10Mbps, 100Mbps, 1Gbps, and 10Gbps.
• Since the STP cable contains more materials, it is more expensive than the UTP cable.
• Both cables use the same RJ-45 (registered jack) modular connectors.
• Both cables can accommodate a maximum of 1024 nodes in each segment.
• The STP provides more noise and EMI resistance than the UTP cable.
• The maximum segment length for both cables is 100 meters or 328 feet.

The following image shows both types of twisted-pair cables.


category/name Maximum Bandwidth/support Ethernet Description
of the cable supported signals rate standard
speed
Cat 1 1Mbps 1MHz Not used This cable contains only
for data two pairs (4 wires). This
cable was used in the
telephone network for
voice transmission.
Cat 2 4Mbps 10MHz Token Ring This cable and all further
cables have a minimum
of 8 wires (4 pairs). This
cable was used in the
token-ring network.
Cat 3 10Mbps 16MHz 10BASE-T This is the first Ethernet
Ethernet cable that was used in
LAN networks.
Cat 4 20Mbps 20MHz Token Ring This cable was used in
advanced Token-ring
networks.
Cat 5 100Mbps 100MHz 100BASE- This cable was used in
T Ethernet advanced (fast) LAN
networks.
Cat 5e 1000Mbps 100MHz 1000BASE- This cable/category is the
T Ethernet minimum requirement
for all modern LAN
networks.
Cat 6 10Gbps 250MHz 10GBASE- This cable uses a plastic
T Ethernet core to prevent cross-talk
between twisted-pair. It
also uses a fire-resistant
plastic sheath.
Cat 6a 10Gbps 500MHz 10GBASE- This cable reduces
T Ethernet attenuation and cross-
talk. This cable also
potentially removes the
length limit. This is the
recommended cable for
all modern Ethernet LAN
networks.
Cat 7 10Gbps 600MHz Not drafted This cable sets a base for
yet further development.
This cable uses multiple
twisted-pair and shields
each pair by its plastic
sheath.

• Cat 1, 2, 3, 4, 5 are outdated and not used in any modern LAN network.
• Cat 7 is still a new technology and not commonly used.
• Cat 5e, 6, 6a are the commonly used twisted-pair cables.

Fiber optic cable


This cable consists of a core, cladding, buffer, and jacket. The core is made from thin
strands of glass or plastic that can carry data over a long distance. The core is wrapped
in the cladding; the cladding is wrapped in the buffer, and the buffer is wrapped in the
jacket.

• Core carries the data signals in the form of light.


• Cladding reflects light back to the core.
• Buffer protects the light from leaking.
• The jacket protects the cable from physical damage.

Fiber optic cable is completely immune to EMI and RFI. This cable can transmit data
over a long distance at the highest speed. It can transmit data up to 40 kilometers at the
speed of 100Gbps.

Fiber optic uses light to send data. It reflects light from one endpoint to another. Based
on how many beams of light are transmitted at a given time, there are two types of fiber
optical cable; SMF and MMF.

SMF (Single-mode fiber) optical cable


This cable carries only a single beam of light. This is more reliable and supports much
higher bandwidth and longer distances than the MMF cable. This cable uses a laser as
the light source and transmits 1300 or 1550 nano-meter wavelengths of light.

MMF (multi-mode fiber) optical cable


This cable carries multiple beams of light. Because of multiple beams, this cable carries
much more data than the SMF cable. This cable is used for shorter distances. This cable
uses an LED as the light source and transmits 850 or 1300 nano-meter wavelengths of
light.

UTP cable
A UTP cable contains 8 wires. These wires are grouped in four pairs. Each pair consists
of two twisted wires. The first wire has a single color-coded plastic coating while the
other wire has that color plus white color striped plastic coating. For example, for the
brown wire pair, one wire’s coating is all brown, while the other wire’s coating is brown-
and-white striped.

The following image shows a UTP cable.

RJ-45 (UTP cable) connector


Both NIC and switch port have an eight pins slot. To connect these pins with the wires
of a UTP cable, a connector known as the RJ-45 connector is used. The RJ-45 connector
has eight physical locations, known as pin positions or simply pins, into which the eight
wires of the UTP cable can be inserted. These pins create a place where the ends of the
copper wires can touch the pins of NIC or switch port.

The following image shows an RJ-45 connector.


Difference of Straight through and Crossover Cable

Cable pair orders

1. Blue Pair

2. Orange Pair

3. Green Pair

4. Brown Pair

Ethernet cables can be wired as straight through or crossover. The straight through is the
most common type and is used to connect computers to hubs or switches. They are most
likely what you will find when you go to your local computer store and buy a patch
cable. Crossover Ethernet cable is more commonly used to connect a computer to a
computer and may be a little harder to find since they aren’t used nearly as much as
straight through Ethernet cable.

T568A And T568B Wiring Standard Basis :A RJ45 connector is a modular 8 position,
8 pin connector used for terminating Cat5e patch cable or Cat6 cable. A pin out is a
specific arrangement of wires that dictate how the connector is terminated. There are
two standards recognized by ANSI, TIA and EIA for wiring Ethernet cables. The first is
the T568A wiring standard and the second is T568B. T568B has surpassed 568A and is
seen as the default wiring scheme for twisted pair structured cabling. If you are unsure
of which to use, choose 568B.

Straight through vs Crossover Cable

Straight Through Cable

A straight through cable is a type of twisted pair cable that is used in local area networks
to connect a computer to a network hub such as a router. This type of cable is also
sometimes called a patch cable and is an alternative to wireless connections where one
or more computers access a router through wireless signal. On a straight through cable,
the wired pins match. Straight through cable use one wiring standard: both ends use
T568A wiring standard or both ends use T568B wiring standard. The following figure
shows a straight through cable of which both ends are wired as the T568B standard.
Crossover Cable:

A crossover Ethernet cable is a type of Ethernet cable used to connect computing


devices together directly. Unlike straight through cable, the RJ45 crossover cable uses
two different wiring standards: one end uses the T568Awiring standard and the other
end uses the T568B wiring standard. The internal wiring of Ethernet crossover cables
reverses the transmit and receive signals. It is most often used to connect two devices
of the same type: e.g.
two computers (via network interface controller) or two switches to each other.
“A Crossover cable of which both ends”

Straight through vs Crossover Cable:


Straight through cables are primarily used for connecting unlike devices. And
crossover cables are use for connecting alike devices.

Use straight through Ethernet cable for the following cabling:

Switch to router
Switch to PC or server
Hub to PC or server

Use crossover cables for the following cabling:

Switch to switch
Switch to hub
Hub to hub
Router to router
PC to PC
Network cable Crimping and Testing Tools
In This part of experiment explains the most common twisted-pair network cable
testing and crimping tools in detail. Learn the tools that you can use to crimp and test
twisted-pair network cables. Cables are the backbone of a wired network. The stability,
reliability, and performance of a wired network depend on cables. Installing and
maintaining cables in a wired network is a difficult task. To make this task easier, a
variety of network cable crimping and testing tools are available. In this tutorial, we
will not only discuss some of the most common network cable crimping and testing
tools but also understand their features and functions.

Twisted-pair (STP and UTP) network cable crimping tools

Crimping tools are used for the following purposes.

1. To cut the network cable of the required length from the bundle.

2. To remove the outer and inner jackets of the network cable.

3. To attach the connectors on both ends of the cable.

Some crimping tools provide all the functionality while others provide one or two
functionalities. The most common twisted-pair network cable crimping tools are
described below.

Wire Cutter: - To cut the network cable of the required length from the bundle, you can
use any standard wire cutter tool or can use a wire cutter tool that is specially designed
for the twisted-pair cable. A twisted-pair wire cutter usually includes additional blades
for stripping the wire

Wire Stripper: - This tool is used to remove the outer and inner jackets of the network
cable. Typically, you do not need to purchase this tool separately as all standard
twisted-pair wire cutters are equipped with wire-strippers.

Crimp tool: - This tool is used to attach the connectors to the cable. Typically, this tool
also includes a wire-cutter and wire-stripper. So if you buy a crimp tool, you don't have
to buy a wire-cutter and wire-striper separately.
Network cable testing and troubleshooting toolsA network cable testing and
troubleshooting tool is used for the following purposes.To measure the length of a
segment or network cable.To detect loose connectors.To identify an un-labeled
network cable from all network cables.To find a break in the network cable.
To certify the cable installation.The following section describes the most common
network cable testing and troubleshooting tools

Basic cable tester


If you can't afford a network cable certifier, you can buy and use this device to
manage your network cables.Besides certifying the cable installation, this device
provides all remaining functionalities of a network cable Certifier. It can test cable
length, cross talk, and breaks in the cable. It can also check whether the connectors on
both ends of a network cable are properly attached or not.
IP address
An IP address represents a unique address that distinguishes any device on the
internet or any network from another. IP or Internet Protocol defines the set of
commands directing the setup of data transferred through the internet or any
other local network.

An IP address is represented by a series of numbers segregated by periods(.). They


are expressed in the form of four pairs - an example address might be
255.255.255.255 wherein each set can range from 0 to 255.

The process of IP address works in the following way:

1. Your computer, Smartphone, or any other Wi-Fi-enabled device firstly


connects to a network that is further connected to the internet. The network
is responsible for giving your device access to the internet.
2. While working from home, your device would be probably using that network
provided by your Internet Service Provider (ISP). In a professional
environment, your device uses your company network.
3. Your ISP is responsible to generate the IP address for your device.
4. Your internet request penetrates through the ISP, and they place the
requested data back to your device using your IP address. Since they provide
you access to the internet, ISP's are responsible for allocating an IP address
to your computer or respective device.

As show in figure wet each how the ip addresses are classified and when
they are used.

Class Address Range Supports


1.0.0.1to126.255.255.254 Supports 16million hosts on each of 127
Class A networks.
Class B 128.1.0.1to191.255.255.254 Supports 65,000 hosts on each of 16,000
networks.
Class C
192.0.1.1to223.255.254.254 Supports 254 hosts on each of 2million
networks.
Class D 224.0.0.0to239.255.255.255 Reserved for multicast groups.
Class E
240.0.0.0to254.255.255.254 Reserved.
In Windows:

1. Open the command prompt by typing the term 'cmd' (no quote marks) in the
Windows search panel.

The following window will appear. Type "ipconfig" (without the quotes) to access
the private IP address information.

It will display the following information.


Experiment – 2

Week2:Study of following network devices in detail

A)Repeater b)Hub c)Bridge d)Router e)Gateway


f)Switch

Aim:Study of following Network Devices in Detail


• Repeater

• Hub

• Switch

• Bridge

• Router

• GateWay

Apparatus(Software):No software or hardware needed.

Procedure:Following should be done to understand t his practical.

1.Repeater:Functioning at Physical Layer.Arepeater is an


electronic device that receives a signal and retransmits it at a
higher level and/or higher power, or onto the other side of an
obstruction, so that the signal can cover longer distances.
Repeater have two ports,so cannot be use to connect form or
ethan two devices

2. Hub:An Ethernet hub,active hub,network hub,repeater hub,hub


or concentrator is a device for connecting multiple twisted pair or
fiber optic Ethernet devices together and making the mactas a single
network segment.Hubs work at the physical layer(layer1) of the OSI
model. The device is a form of multiport repeater. Repeater hubs also
participate in collision detection,forwarding a jam signal to all ports
fit detects a collision.

3. Switch:A network switch or switching hub is a computer networking


device that connects network segments.The term commonly refers to
a network bridge that processes and routes data at the data link layer
(layer 2) of the OSI model. Switches that additionally process data at
the network layer(layer3 and above)are often referred to as Layer3
switches or multilayer switches.

4.Bridge: A network bridge connects multiple network segments at the


data link layer(Layer 2) of the OSI model. In Ethernet networks, the
term bridge formally means a device that behaves according to the IEEE
802.1D standard. A bridge and switch are very much alike; a switch
being a bridge with numerous ports. Switch or Layer 2 switch is often
used interchangeably with bridge. Bridges can analyze incoming data
packets to determine if the bridge is able to send the given packet to
another segment of the network.

5.Router: A router is an electronic device that interconnects two or


more computer networks, and selectively interchanges packets of data
between them. Each data packet contains address information that a
router can use to determine if the source and destination are on the
same network, or if the data packet must be transferred from one
network to another. Where multiple routers are used in a large
collection of interconnected networks, the routers exchange
information about target system addresses, so that each router can
build up at able showing the preferred paths between any two systems
on the interconnected networks.
6. GateWay:In ac ommunications network, a network node equipped for
interfacing withAnother network that uses different protocols.
• A gateway may contain devices such as protocol translators,
impedance matching devices, rate converters, fault isolators, or signal
translators as necessary to provide system interoperability. It also
requires the establishment of mutually acceptable administrative
procedures between both networks.
• A protocol translation/mapping gateway interconnects networks
with different network protocol technologies by performing the
required protocol conversions.
Experiment – 3

Week3: Study and practice the basic network configuration commands

Aim: Study and practice the basic network configuration commands

Go to Start! Run and in the box type “cmd”. The command window opens and a cursor is waiting at
the prompt. Type the following in the command window.

PING:

PING is a network tool that is used on TCP/IP based networks. It stands for Packet internet Groper.
The idea is to verify if a network host is reachable from the site where the PING command issued.
The ping command uses the ICMP to verify if the network connections are intact. When a PING
command is issued, a packet of 64 bytes is sent to the destination computer. The packet is composed
of 8 bytes of ICMP header and 56 bytes of data. The computer then waits for a reply from the
destination computer.

ping www.targetname.com

C:\>ping www.google.com

Pinging www.l.google.com [64.233.161.99] with 32 bytes of data:

Reply from 64.233.161.99: bytes=32 time=58ms TTL=242

Reply from 64.233.161.99: bytes=32 time=70ms TTL=242

Reply from 64.233.161.99: bytes=32 time=60ms TTL=242

Reply from 64.233.161.99: bytes=32 time=60ms TTL=242

Ping statistics for 64.233.161.99: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate
round trip times in milli-seconds:

Minimum = 58ms, Maximum = 70ms, Average = 62ms

Tracert:

C:\>tracert: The tracert command displays a list of all the routers that a packet has to go through to
get from the computer where tracert is run to any other computer on the internet.
C:\>tracert www.google.com

Tracing route to www.l.google.com [64.233.161.104] over a maximum of 30 hops:

1 3 ms 3 ms 3 ms 192.168.0.1

2 10 ms 14 ms 9 ms 10.116.96.1

3 11 ms 22 ms 11 ms srp0-0.brhmalhe-rtr2.bham.rr.com [66.25.96.2]

4 27 ms 25 ms 25 ms pos2-0.tampflerl.rtr3.tampabay.rr.com [65.32.8.109]

5 26 ms 26 ms 26 ms pop1-tby-P0-1.atdn.net [66.185.136.169]

6 36 ms 26 ms 25 ms bb1-tby-P0-0.atdn.net [66.185.136.160]

7 45 ms 43 ms 42 ms bb2-atm-P7-0.atdn.net [66.185.152.245]

8 45 ms 43 ms 42 ms pop2-atm-P1-0.atdn.net [66.185.147.211]

9 42 ms 41 ms 42 ms Google.atdn.net [66.185.147.218]

10 44 ms 53 ms 53 ms 216.239.46.157

11 44 ms 71 ms 55 ms 66.249.95.124

12 58 ms 58 ms 60 ms 216.239.47.149

13 60 ms 58 ms 58 ms 216.239.47.69

14 63 ms 66 ms 58 ms 216.239.47.

15 6 15 61 ms 61 ms 58 ms 64.233.161.104

Trace complete.

Netstat:
The following is displayed on the command prompt:

C:\>netstat

Active Connections:

Proto Local Address Foreign Address State

TCP ams:1053 baym-cs6.msgr.hotmail.com:1863 ESTABLISHED

TCP ams:1056 cs34.msg.dcn.yahoo.com:5050 ESTABLISHED


TCP ams:1070 sip25.voice.re2.yahoo.com:5061 ESTABLISHED

TCP ams:1115 192.168.0.12:5101 ESTABLISHED

Nslookup:
The prompt changes from ‘c:\’ to ‘>’. Type in www.hotmail.com. The following
appears on the

command prompt:

C:\>nslookup

Default Server: ns1.mindspring.com

Address: 207.69.188.185

> hotmail.com

Server: ns1.mindspring.com

Address: 207.69.188.185

Non-authoritative answer:

Name: hotmail.com

Addresses: 64.4.32.7, 64.4.33.7

The above command uses the name server of your Internet Service Provider (ISP) to resolve the IP
address for the domain name specified. The nslookup command can be exited by pressing ‘ctrl’ and
‘c’ keys together.

Ipconfig:
Ipconfig is used to show information on TCP/IP, DNS server addresses, your network
interface cards etc. Ipconfig can be used from the command line. In order to use
Ipconfig, go to Start!

Run and in the box type “cmd”. The command window opens and a cursor is waiting at
the prompt. Type the following in the command window:
Ipconfig

Ipconfig/all
Ip config can be used to renew or release a DHCP configuration for all interface cards or adapters. In
order to see the formats in which Ipconfig can be used, type the following:

Route:
The routing tables in your computer can be viewed using the route command. In order to use the
route command, go to Start ! Run and in the box type “cmd”. The command window opens and a
cursor is waiting at the prompt. Type the following in the command window:

route Print

ARP:

The ARP command maps the IP addresses of a station to the MAC hardware addresses.
As discusses in module 5, the ARP request contains the IP address of the requestor and
IP address of the computer whose MAC address is desired. The ARP packet is
broadcasted and the destination computer accepts the packet by looking at its IP
address. The destination computer then sends an ARP reply packet that contains its IP
address and MAC address to the requestor. In order to look at the arp cache maintained
in your computer, go to Start! Run and in the box

type “cmd”. The command window opens and a cursor is waiting at the prompt. Type
the following in the command window:

Arp –a

The following arp cache table is displayed:

C:\>arp -a

Interface: 192.168.0.8 --- 0x20002

Internet Address Physical Address Type

192.168.0.1 00-09-5b-36-b4-06 dynamic

Windows deletes an entry that has not been used every 10 minutes. Windows also
deletes the oldest entry even if the lifetime is not expired in order to make room for
new entries in the ARP cache table. The following command can be used to list, add,
and remove an ARP cache entry.
Systeminfo:

Displays detailed configuration information about a computer and its operating system,
including operating system configuration, security information, product ID, and
hardware properties (such as RAM, disk space, and network cards).

Tasklist:
Windows programs run as one or more processes or tasks. You can use the TASKLIST
command to display a list of currently-running tasks. TASKLIST displays the process
ID number for each running task, the name of the executable program that started the
task, and, when available, the window title.
Week 4

PROGRAM NO 4(a): CRC polynomials

RESOURCE: Turbo C

Implement on a data set of characters the three CRC polynomials

#include<stdio.h>
#include<string.h>
// length of the generator polynomial
#define N strlen(gen_poly)
// data to be transmitted and received
char data[28];
// CRC value
char check_value[28];
// generator polynomial
char gen_poly[10];
// variables
int data_length,i,j;
// function that performs XOR operation
void XOR(){
// if both bits are the same, the output is 0
// if the bits are different the output is 1
for(j = 1;j < N; j++)
check_value[j] = (( check_value[j] == gen_poly[j])?'0':'1');

}
// Function to check for errors on the receiver side
void receiver(){
// get the received data
printf("Enter the received data: ");
scanf("%s", data);
printf("\n-----------------------------\n");
printf("Data received: %s", data);
// Cyclic Redundancy Check
crc();
// Check if the remainder is zero to find the error
for(i=0;(i<N-1) && (check_value[i]!='1');i++);
if(i<N-1)
printf("\nError detected\n\n");
else
printf("\nNo error detected\n\n");
}

void crc(){
// initializing check_value
for(i=0;i<N;i++)
check_value[i]=data[i];
do{
// check if the first bit is 1 and calls XOR function
if(check_value[0]=='1')
XOR();
// Move the bits by 1 position for the next computation
for(j=0;j<N-1;j++)
check_value[j]=check_value[j+1];
// appending a bit from data
check_value[j]=data[i++];
}while(i<=data_length+N-1);
// loop until the data ends
}

int main()
{
// get the data to be transmitted
printf("\nEnter data to be transmitted: ");
scanf("%s",data);
printf("\n Enter the Generating polynomial: ");
// get the generator polynomial
scanf("%s",gen_poly);
// find the length of data
data_length=strlen(data);
// appending n-1 zeros to the data
for(i=data_length;i<data_length+N-1;i++)
data[i]='0';
printf("\n----------------------------------------");
// print the data with padded zeros
printf("\n Data padded with n-1 zeros : %s",data);
printf("\n----------------------------------------");
// Cyclic Redundancy Check
crc();
// print the computed check value
printf("\nCRC or Check value is : %s",check_value);
// Append data with check_value(CRC)
for(i=data_length;i<data_length+N-1;i++)
data[i]=check_value[i-data_length];
printf("\n----------------------------------------");
// printing the final data to be sent
printf("\n Final data to be sent : %s",data);
printf("\n----------------------------------------\n");
// Calling the receiver function to check errors
receiver();
return 0;
}
Output
Enter data to be transmitted: 1001101
Enter the Generating polynomial: 1011
----------------------------------------
Data padded with n-1 zeros : 1001101000
----------------------------------------
CRC or Check value is : 101
----------------------------------------
Final data to be sent : 1001101101
----------------------------------------
Enter the received data: 1001101101
-----------------------------
Data received: 1001101101
No error detected
Explanation
There is no signal error since the data being transferred and received is identical.
Enter the received data: 1001001101
-----------------------------
Data received: 1001001101
Error detected
Week 5

PROGRAM NO 5(a): Bit Stuffing

RESOURCE: Turbo C

PROGRAM LOGIC: The new technique allows data frames to contain an arbitrary number if
bits and allows character codes with an arbitrary no of bits per character. Each frame
begins and ends with special bit pattern, 01111110, called a flag byte. Whenever the

Sender’s data link layer encounters five consecutive one’s in the data ,it automatically
stuffs a 0 bit into the outgoing bitstream

Program :1(a)
#include<stdio.>
#include<conio.>
#include<string.>
void main()
{
int
a[20],b[30],i,j,k,count,n;
clrscr();
printf("Enter frame length:");
scanf("%d",&n);
printf("Enter input frame (0's & 1's only):");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
i=0;
count=1;
j=0;
while(i<n)
{
if(a[i]==1)
{
b[j]=a[i];
for(k=i+1;a[k]==1 && k<n &&count<5;k++)
{
j++;
b[j]=a[k];
count++;
if(count==5)
{
j++;
b[j]=0;

i=k;
}
}
else
{
b[j]=a[i];
}
i++
;
j++;
}
printf("After stuffing the frame is:");
for(i=0;i<j;i++)
printf("%d",b[i]);
getch();
}
Program 5(b): Character Stuffing.

OBJECTIVE: Implement the data link layer framing


methods. RESOURCE: Turbo C
PROGRAM LOGIC:
The framing method gets around the problem of resynchronization after an
error by havi ng ea ch fra me sta r t with th e ASCII c ha ra cter s equ en
ce D L E ST X a nd the sequence DLE ETX. If the destination ever losses
the track of the frame boundaries all it has to do is look for DLE STX or DLE
ETX characters to figure out.

The data link la yer on t he recei vin g en d re mo ve s th e D LE b efore


th e da ta a re giv en t o th e network layer. This technique is called
character stuffing.

PROCEDURE:
Go to debug -> run or press CTRL + F9 to run the program.

Source code :

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<process.h>
void main()
{
int i=0,j=0,n,pos;char a[20],b[50],ch;
clrscr();
printf("enter
string\n");
scanf("%s",&a);
n=strlen(a);
printf("enter
position\n");
scanf("%d",&pos);
if(pos>n)
{
printf("invalid position, Enter again
:"); scanf("%d",&pos);
}
printf("enter the
character\n"); ch=getche();
b[0]='d';
b[1]='l';
b[2]='e';
b[3]='s';
b[4]='t';
b[5]='x';
j=6;
while(i<n)
{
if(i==pos-1)
{
b[j]='d';
b[j+1]='l';
b[j+2]='e';
b[j+3]=ch;
b[j+4]='d';
b[j+5]='l';
b[j+6]='e';
j=j+7;
}
if(a[i]=='d' && a[i+1]=='l' && a[i+2]=='e')
{
b[j]='d';
b[j+1]='l';
b[j+2]='e';
j=j+3;
}
b[j]=a[i];
i++;
j++;
}
b[j]='d';
b[j+1]='l';
b[j+2]='e';
b[j+3]='e';
b[j+4]='t';
b[j+5]='x';
b[j+6]='\0';
printf("\nframe after
stuffing:\n"); printf("%s",b);
getch();
}

Output:

You might also like