Router
Router
Router
INTRODUCTION
A router is a device that forwards data packets across computer
networks. Routers perform the data "traffic direction" functions on the
Internet. A router is a microprocessor-controlled device that is
connected to two or more data lines from different networks. When a
data packet comes in on one of the lines, the router reads the address
information in the packet to determine its ultimate destination. Then,
using information in its routing table, it directs the packet to the next
network on its journey. A data packet is typically passed from router to
router through the networks of the Internet until it gets to its destination
computer. Routers also perform other tasks such as translating the data
transmission protocol of the packet to the appropriate protocol of the
next network.
The most familiar type of routers are home and small office
routers that simply pass data, such as web pages and email, between the
home computers and the owner's cable or DSL modem, which connects
to the Internet (ISP) However more sophisticated routers range from
enterprise routers, which connect large business or ISP networks up to
the powerful core routers that forward data at high speed along the
optical fiber lines of the Internet backbone.
Applications of Router
Distribution
Distribution routers aggregate traffic from multiple access routers,
either at the same site, or to collect the data streams from multiple sites
to a major enterprise location. Distribution routers are often responsible
for enforcing quality of service across a WAN, so they may have
considerable memory installed, multiple WAN interface connections,
and substantial onboard data processing routines. They may also
provide connectivity to groups of file servers or other external
networks.
Security
External networks must be carefully considered as part of the
overall security strategy. Separate from the router may be a firewall or
VPN handling device, or the router may include these and other
security functions. Many companies produced security-oriented routers,
including Cisco Systems' PIX and ASA5500 series, Juniper's
Netscreen, Watchguard's Firebox, Barracuda's variety of mail-oriented
devices, and many others.
In enterprises, a core router may provide a "collapsed backbone"
interconnecting the distribution tier routers from multiple buildings of a
campus, or large enterprise locations. They tend to be optimized for
high bandwidth.[8]
Routers for Internet connectivity and internal use
Routers intended for ISP and major enterprise connectivity
usually exchange routing information using the Border Gateway
Protocol (BGP). RFC 4098[9] standard defines the types of BGP-
protocol routers according to the routers' functions:
Edge router: Also called a Provider Edge router, is placed at the
edge of an ISP network. The router uses External BGP to EBGP
protocol routers in other ISPs, or a large enterprise Autonomous
System.
Subscriber edge router: Also called a Customer Edge router, is
located at the edge of the subscriber's network, it also uses EBGP
protocol to its provider's Autonomous System. It is typically used in an
(enterprise) organization.
Inter-provider border router: Interconnecting ISPs, is a BGP-
protocol router that maintains BGP sessions with other BGP protocol
routers in ISP Autonomous Systems.
Core router: A core router resides within an Autonomous System as a
back bone to carry traffic between edge routers.
Within an ISP: In the ISPs Autonomous System, a router uses internal
BGP protocol to communicate with other ISP edge routers, other
intranet core routers, or the ISPs intranet provider border routers.
"Internet backbone:" The Internet no longer has a clearly
identifiable backbone, unlike its predecessor networks. See default-free
zone (DFZ). The major ISPs system routers make up what could be
considered to be the current Internet backbone core.[11] ISPs operate
all four types of the BGP-protocol routers described here. An ISP
"core" router is used to interconnect its edge and border routers. Core
routers may also have specialized functions in virtual private networks
based on a combination of BGP and Multi-Protocol Label Switching
protocols.
Port forwarding: Routers are also used for port forwarding
between private internet connected servers.
Voice/Data/Fax/Video Processing Routers: Commonly referred to
as access servers or gateways, these devices are used to route and
process voice, data, video, and fax traffic on the internet. Since 2005,
most long-distance phone calls have been processed as IP traffic
(VOIP) through a voice gateway,. Voice traffic that the traditional cable
networks once carried. Use of access server type routers expanded with
the advent of the internet, first with dial-up access, and another
resurgence with voice phone service.
Historical and technical information
Wireless broadband routers look much the same as a wired router, with
the obvious exception of the antenna on top, and the lack of cable
running from the PCs to the router when it is all set up. Creating a
wireless network adds a bit more security concerns as opposed to wired
networks, but wireless broadband routers do have extra levels of
embedded security.
Along with the features found in wired routers, wireless routers also
provide features relevant to wireless security such as Wi-Fi Protected
Access (WPA) and wireless MAC address filtering. Additionally, most
wireless routers can be configured for "invisible mode" so that your
wireless network cannot be scanned by outside wireless clients.
Wireless routers will often include ports for Ethernet connections as
well. For those unfamiliar with WiFi and how it works, it is important
to note that choosing a wireless router may mean you need to beef up
your Wi-Fi knowledge-base. After a wireless network is established,
you may possibly need to spend more time on monitoring and security
than one would with a wired LAN.
Wired and wireless routers and the resulting network can claim pros
and cons over each other, but they are somewhat equal overall in terms
of function and performance. Both wired and wireless routers have high
reliability and reasonably good security (without adding additional
products). However —and this bears repeating — as we mentioned you
may need to invest time in learning more about wireless security.
Generally, going wired will be cheaper overall, but setting up the router
and cabling in the computers is a bit more difficult than setting up the
wireless network. Of course, mobility on a wired system is very limited
while wireless offers outstanding mobility features.
Today you can purchase a basic sub $90 broadband router that will
enable you to share your broadband Internet connection with multiple
computers in your home or small office. Before buying a router,
however, you need to take into consideration the type of Internet
connect you have, and how many ports you will need for individual
computers, and of course, make the choice between wired or wireless.
It is always a good idea to purchase a router with extra ports in case you
need to connect additional computers at a later date.
Forwarding plane
The router has a one input port from which the packet enters. It has
three output ports where the packet is driven out. The router has an
active low synchronous input resetn which resets the router.
8 8
data data_out_0
packet_valid vld_out_0
suspend_data read_enb_0
err 8
data_out_1
vld_out_1
read_enb_1
clock Router_1X3 8
resetn data_out_2
vld_out_2
read_enb_2
Packet Format:
7 6 5 4 3 2 1 0
data[0] byte 1
data[1]
Payload
Packet - Header:
DA: Destination address of the packet is of 2 bits. The router drives the
packet to respective ports based on this destination address of the
packets. Each output port has 2-bit unique port address. If the
destination address of the packet matches the port address, then router
drives the packet to the output port. The address “3” is invalid.
Packet - Payload:
Data: Data should be in terms of bytes and can take anything.
Packet - Parity:
Parity: This field contains the security check of the packet. It should be
a byte of even, bitwise parity, calculated over the header and data bytes
of the packet.
Router Input Protocol:
clock
delay
reset
packet_valid
data H D D D P H D D D P
Suspend_data
err
sent packet Packet 1 (addr = 0) Packet 1 (addr = 0)
1 All input signals are active high and are synchronized to the
falling edge of the clock. This is because the DUV router is
sensitive to the rising edge of clock. Therefore, driving input
signals on the falling edge ensures adequate setup and hold time,
but the signals can also be driven on the rising edge of the clock.
2 The packet_valid signal has to be asserted on the same clock as
when the first byte of a packet (the header byte), is driven onto the
data bus.
3 Since the header byte contains the address, this tells the router to
which output channel the packet should be routed (data_out_0,
data_out_1, or data_out_2).
4 Each subsequent byte of data should be driven on the data bus
with each new rising/falling clock.
5 After the last payload byte has been driven, on the next
rising/falling clock, the packet_valid signal must be deasserted ,
and the packet parity byte should be driven. This signals packet
completion.
6 The input data bus value cannot change while the suspend_data
signal is active (indicating a FIFO overflow). The packet driver
should not send any more bytes and should hold the value on the
data bus. The width of suspend_data signal assertion should not
exceed 100 cycles.
The err signal asserts when a packet with bad parity is detected in the
router, within 1 to 10 cycles of packet completion.
reset
packet_valid
data H D D D P H D D D P
vld_out_0
response delay
read_enb_0
data_out_0 H D D D P
received
Packet 1 (addr = 0)
packet
1 All output signals are active high and can be synchronized to the
rising/falling edge of the clock. Thus, the packet receiver will drive sample
data at the rising/falling edge of the clock. The router will drive and sample
data at the rising edge of clock.
2 Each output port data_out_X (data_out_0, data_out_1, data_out_2) is
internally buffered by a FIFO of 1 byte width and 16 location depth.
3 The router asserts the vld_out_X (vlld_out_0, vld_out_1 or vld_out_2)
signal when valid data appears on the vld_out_X (data_out_0, data_out_1
or data_out_2) output bus. This is a signal to the packet receiver that valid
data is available on a particular router.
4 The packet receiver will then wait until it has enough space to hold the
bytes of the packet and then respond with the assertion of the read_enb_X
(read_enb_0, read_enb1 or read_enb_2) signal that is an input to the router.
2 The read_enb_X (read_enb0, read_enb_1 or read_enb_2) input signal can
be asserted on the rising/falling clock edge in which data are read from the
data_out_X (data_out_0, data_out_1 or data_out_2) bus.
3 As long as the read_enb_X (read_enb_0, read_enb_1 or read_enb_2)
signal remains active, the data_out_X (data_out_0, data_out_1 or
data_out_2) bus drives a valid packet byte on each rising clock edge.
4 The packet receiver cannot request the router to suspend data transmission
in the middle of the packet. Therefore, the packet receiver must assert the
read_enb_X (read_enb_0, read_enb_1 or read_enb_2) signal only after it
ensures that there is adequate space to hold the entire packet.
5 The read_enb_X (read_enb_0, read_enb_1 or read_enb_2) must be
asserted within 30 clock cycles of the vld_out_X (vld_out_0, vld_out_1 or
vld_out_2) being asserted. Otherwise, there is too much congestion in the
packet receiver.
5 The DUV data_out_X (data_out_0, data_out_1 or data_out_2) bus must
not be tri-stated (high Z) when the DUV signal vld_out_X (vld_out_0,
vld_out_1or vld_out_2) is asserted (high) and the input signal read_enb_X
(read_enb_0, read_enb_1 or read_enb_2) is also asserted high.
Router_1X3 Architecture
This design consists of 6 main blocks. Which are fsm_router, router_reg,
ff_sync, and 3 fifo.
The fsm_router block provides the control signals to the fifo, and
router_reg module.
The router_reg module contains the status, data and parity registers for the
router_1x3.
These registers are latched to new status or input data through the control
signals provided by the fsm_router.
There are 3 fifo for each output port, which stores the data coming from
input port based on the control signals provided by fsm_router module.
1. FIFO BLOCK
There are 3 fifos used in the router design. Each fifo is of 8 bit width and
16 bit depth.
The fifo works on system clock. It has synchronous input signal reset.
Write operation:
The data from input data_in is sampled at rising edge of the clock
when input write_enb is high and fifo is not full.
Read Operation:
The data is read from output data_out at rising edge of the clock,
when read_enb is high and fifo is not empty.
Full – it indicates that all the locations inside fifo has been written.
Empty – it indicates that all the locations of fifo are empty.
2. FF_SYNC BLOCK
First data byte i.e., header is latched inside the internal register
first_byte when detect_add and packet_valid signals are high, So that it
can be latched to output dout when lfd_state signal goes high.
Then the input data i.e., payload is latched to output dout if ld_state
signal is high and fifo_full is low.
Then the input data i.e., parity is latched to output dout if lp_state
signal is high and fifo_full is low.
The input data is latched to internal register full_state_byte when
ld_state and fifo_full are high; this full_state_byte data is latched inside
the output dout when laf_state goes high.
Internal parity register stores the parity calculated for packet data,
when packet is transmitted fully, the internal calculated parity is compared
with parity byte of the packet. An error signal is generated if packet parity
is not equal to the calculated parity.
3. FSM BLOCK
suspend_data
clock
write_enb_reg
resetn
detect_add
packet_valid ld_state
8 lp_state
data
fifo_full laf_state
fifo_empty fsm_router lfd_state
parity_done
full_state
low_packet_valid
reset_int_reg
STATE - DECODE_ADDRESS
This is the default state. It waits for the packet_valid assertion, After
packet_valid signal goes high, if the address is valid and fifo for that
address is empty (fifo_empty signal will be high), data can be loaded, so, it
goes to the next state LOAD_FIRST_DATA.
If fifo is not empty it goes to WAIT_TILL_EMPTY so that, new
data couldn’t be accepted till fifo is ready.
The output signal detect_add is made high, so that ff_sync module
can detect the address of fifo to be used. detect_add signal is also used by
router_reg module to latch the first byte in internal register.
STATE - LOAD_FIRST_DATA
STATE - LOAD_DATA
STATE – LOAD_PARITY
STATE – FIFO_FULL_STATE
In this state neither new data is accepted nor any data is latched. So
suspend_data signal is made high and write_enb_reg signal is made low.
Signal full_state is generated for router_reg module. This state
changes to LOAD_AFTER_FULL state when fifo_full becomes low.
STATE – LOAD_AFTER_FULL
STATE – WAIT_TILL_EMPTY
STATE – CHECK_PARITY_ERROR
In this state reset_int_reg signal is generated, which resets the status
and parity registers inside the router_reg module. Neither any data is
latched nor any input data is accepted. Router_reg compares the data
parity from packet with calculated parity during this state.
This state changes to default state DECODE_ADDRESS with next
clock edge.
CODE
module router_fsm(clk,
resetn,
packet_valid,
data_in,
fifo_full1,
fifo_full2,
fifo_full3,
fifo_empty1,
fifo_empty2,
fifo_empty3,
suspend_data,
valid_chanel1,
valid_chanel2,
valid_chanel3,
we1,
we2,
we3,
data_out1,
data_out2,
data_out3,
err);
input clk,
resetn,
packet_valid,
fifo_full1,
fifo_full2,
fifo_full3,
fifo_empty1,
fifo_empty2,
fifo_empty3;
output valid_chanel1,
valid_chanel2,
valid_chanel3;
wt_till_emp :
begin
if ((packet_valid
== 1) && (data_in[1:0]==0) &&
(fifo_empty1== 1))
begin
next_state <=
load_data0;
parity1 <= 0;
parity2 <= 0;
parity3 <= 0;
end
else if
((packet_valid == 1) && (data_in[1:0]==1)
&& (fifo_empty2==1))
begin
next_state <=
load_data1;
parity1 <= 0;
parity2 <= 0;
parity3 <= 0;
end
else if
((packet_valid == 1) && (data_in[1:0]==2)
&& (fifo_empty3==1))
begin
next_state <=
load_data2;
parity1 <= 0;
parity2 <= 0;
parity3 <= 0;
end
else
begin
parity1 <= 0;
parity2 <= 0;
parity3 <= 0;
next_state <=
wt_till_emp;
end
end
load_data0 : begin
if ((fifo_full1 ==
1) && (packet_valid == 1))
begin
next_state <=
fifo_ful0;
parity1 <= 0;
parity2 <= 0;
parity3 <= 0;
end
else if
((packet_valid == 0) && (fifo_full1 == 0))
begin
next_state <=
ld_parity0;
parity1 <= 0;
parity2 <= 0;
parity3 <= 0;
end
else
begin
parity1 <= 0;
parity2 <= 0;
parity3 <= 0;
next_state <=
load_data0;
end
end
load_data1 : begin
if ((fifo_full2 == 1)
&& (packet_valid == 1))
begin
next_state <=
fifo_ful1;
parity1 <= 0;
parity2 <= 0;
parity3 <= 0;
end
else if
((packet_valid == 0) && (fifo_full2 == 0))
begin
next_state <=
ld_parity1;
parity1 <= 0;
parity2 <= 0;
parity3 <= 0;
end
else
begin
parity1 <= 0;
parity2 <= 0;
parity3 <= 0;
next_state <=
load_data1;
end
end
load_data2 : begin
if ((fifo_full3 == 1)
&& (packet_valid == 1))
begin
next_state <=
fifo_ful2;
parity1 <= 0;
parity2 <= 0;
parity3 <= 0;
end
else if ((packet_valid
== 0) && (fifo_full3 == 0))
begin
next_state
<= ld_parity2;
parity1 <= 0;
parity2 <= 0;
parity3 <= 0;
end
else
begin
parity1
<= 0;
parity2 <= 0;
parity3 <= 0;
next_state <=
load_data2;
end
end
fifo_ful0 : begin
if ((packet_valid == 1)
&& (fifo_full1 == 0))
begin
next_state <=
load_data0;
parity1
<= 0;
parity2 <= 0;
parity3 <= 0;
end
else if ((packet_valid
== 0) && (fifo_full1 == 0))
begin
next_state <=
ld_parity0;
parity1
<= 0;
parity2 <= 0;
parity3 <= 0;
end
else
begin
parity1
<= 0;
parity2 <= 0;
parity3 <= 0;
next_state <=
fifo_ful0;
end
end
fifo_ful1 : begin
if ((packet_valid ==
1) && (fifo_full2 == 0))
begin
next_state <=
load_data1;
parity1
<= 0;
parity2 <= 0;
parity3 <= 0;
end
else if ((packet_valid
== 0) && (fifo_full2 == 0))
begin
next_state <=
ld_parity1;
parity1
<= 0;
parity2 <= 0;
parity3 <= 0;
end
else
begin
parity1
<= 0;
parity2 <= 0;
parity3 <= 0;
next_state <=
fifo_ful1;
end
end
fifo_ful2 : begin
if ((packet_valid == 1)
&& (fifo_full3 == 0))
begin
next_state <=
load_data2;
parity1
<= 0;
parity2 <= 0;
parity3 <= 0;
end
else if ((packet_valid
== 0) && (fifo_full3 == 0))
begin
next_state <=
ld_parity2;
parity1
<= 0;
parity2 <= 0;
parity3 <= 0;
end
else
begin
parity1
<= 0;
parity2 <= 0;
parity3 <= 0;
next_state <=
fifo_ful2;
end
end
ld_parity0 : begin
parity1 <= data_in;
parity2 <= 0;
parity3 <= 0;
next_state <=
chk_parity0;
end
ld_parity1 : begin
parity1 <= 0;
parity2 <= data_in;
parity3 <= 0;
next_state <= chk_parity1;
end
ld_parity2 : begin
parity1 <= 0;
parity2 <= 0;
parity3 <= data_in;
next_state <= chk_parity2;
end
chk_parity0 : begin
next_state <= dec_add;
end
chk_parity1 : begin
next_state <= dec_add;
end
chk_parity2 : begin
next_state <= dec_add;
end
endcase
end
//output logic
always @ (*)
begin
if (!resetn)
begin
suspend_data <= 0;
data_out1 <= 0;
data_out2 <= 0;
data_out3 <= 0;
err <= 0;
we1 <= 0;
we2 <= 0;
we3 <= 0;
end
else if ((pre_state ==
dec_add) && (data_in[1:0] == 0))
begin
suspend_data <= 0;
data_out1 <=
data_in;
data_out2 <= 0;
data_out3 <= 0;
err <= 0;
we1 <= 1;
we2 <= 0;
we3 <= 0;
end
else if (pre_state ==
wt_till_emp)
begin
suspend_data <= 1;
data_out1 <= 0;
data_out2 <= 0;
data_out3 <= 0;
err <= 0;
we1 <= 0;
we2 <= 0;
we3 <= 0;
end
else
begin
suspend_data <= 0;
data_out1 <= 0;
data_out2 <= 0;
data_out3 <= 0;
err <= 0;
we1 <= 0;
we2 <= 0;
we3 <= 0;
end
end
always @(posedge clk or negedge resetn)
begin
if(!resetn)
parity <= 0;
else if (pre_state ==
dec_add)
parity <= data_in;
else if (packet_valid && !
fifo_full1 && !fifo_full2 && !fifo_full3
&& !suspend_data )
parity <= parity ^ data_in;
end
assign valid_chanel1 =
((~fifo_empty1))?1:0;
assign valid_chanel2 =
((~fifo_empty2))?1:0;
assign valid_chanel3 =
((~fifo_empty3))?1:0;
endmodule
module fifo(clk,
resetn,
data_in,
we,
re,
data_out,
fifo_full,
fifo_empty);
input clk,
resetn,
we,
re;
input[7:0] data_in;
output[7:0] data_out;
output fifo_full,
fifo_empty;
always@(posedge clk)
begin
if(we && !fifo_full)
mem[write_pointer] <= data_in ;
if(re && !fifo_empty)
data_out <= mem[read_pointer] ;
end
endmodule
input clk,
resetn,
packet_valid,
re1,
re2,
re3;
input [7:0]data_in;
output suspend_data,
err,
valid_chanel1,
valid_chanel2,
valid_chanel3;
wire w1,w2,w3,w4,w5,w6,w7,w8,w9;
wire [7:0] w10,w11,w12;
router_fsm fsm1(.clk(clk),
.resetn(resetn),
.packet_vali
d(packet_valid),
.data_in(dat
a_in),
.fifo_full1(
w1),
.fifo_full2(
w2),
.fifo_full3(
w3),
.fifo_empty1
(w4),
.fifo_empty2
(w5),
.fifo_empty3
(w6),
.suspend_dat
a(suspend_data),
.valid_chane
l1(valid_chanel1),
.valid_chane
l2(valid_chanel2),
.valid_chane
l3(valid_chanel3),
.we1(w7),
.we2(w8),
.we3(w9),
.data_out1(w
10),
.data_out2(w
11),
.data_out3(w
12),
.err(err));
fifo f1(.clk(clk),
.resetn(resetn),
.data_in(w10),
.we(w7),
.re(re1),
.data_out(ch_out1),
.fifo_full(w1),
.fifo_empty(w4));
fifo f2(.clk(clk),
.resetn(resetn),
.data_in(w11),
.we(w8),
.re(re2),
.data_out(ch_out2),
.fifo_full(w2),
.fifo_empty(w5));
fifo f3(.clk(clk),
.resetn(resetn),
.data_in(w12),
.we(w9),
.re(re3),
.data_out(ch_out3),
.fifo_full(w3),
.fifo_empty(w6));
endmodule
module router_fsm_tb();
reg clk,
resetn,
packet_valid,
fifo_full1,
fifo_full2,
fifo_full3,
fifo_empty1,
fifo_empty2,
fifo_empty3;
reg [7:0] data_in;
wire suspend_data,
valid_chanel1,
valid_chanel2,
valid_chanel3,
we1,
we2,
we3,
err;
wire [7:0] data_out1,
data_out2,
data_out3;
router_fsm f1(clk,
resetn,
packet_valid,
data_in,
fifo_full1,
fifo_full2,
fifo_full3,
fifo_empty1,
fifo_empty2,
fifo_empty3,
suspend_data,
valid_chanel1,
valid_chanel2,
valid_chanel3,
we1,
we2,
we3,
data_out1,
data_out2,
data_out3,
err);
task initialize();
begin
packet_valid = 0;
data_in = 8'b00000000;
fifo_full1 = 0;
fifo_full2 = 0;
fifo_full3 = 0;
fifo_empty1 = 0;
fifo_empty2 = 0;
fifo_empty3 = 0;
end
endtask
task reset();
begin
resetn=1'b0;
#10 resetn =~resetn;
end
endtask
task fifo_full(input i,j,k);
begin
fifo_full1 = i;
fifo_full2 = j;
fifo_full3 = k;
end
endtask
initial
clk=1'b0;
always
# 5 clk= ~clk;
initial
begin
reset;
@(negedge clk);
//initialize;
packet_valid = 1'b1;
fifo_full (0,0,0);
fifo_empty (1,1,1);
wait(!suspend_data);
@(negedge clk);
data_in = 8'b00001000;
#10;
wait(!suspend_data);
@(negedge clk);
data_in = 8'b00101010;
#10;
wait(!suspend_data);
fifo_empty (0,1,1);
@(negedge clk);
data_in = 8'b01001010;
#10;
fifo_full (1,1,1);
#30;
fifo_full (0,0,0);
wait(!suspend_data);
@(negedge clk);
data_in = 8'b10001010;
#10;
packet_valid = 1'b0;
wait(!suspend_data);
@(negedge clk);
data_in = 8'b11100010;
@(negedge clk);
@(negedge clk);
data_in = 8'hxx;
#100;
$finish;
end
endmodule