Sep 26, 2007

TCP/IP Protocol







4. Application DNS, TFTP, TLS/SSL, FTP, Gopher, HTTP, IMAP, IRC, NNTP, POP3, SIP, SMTP, SNMP, SSH, TELNET, ECHO, BitTorrent, RTP, PNRP, rlogin, ENRP, …
Routing protocols like BGP, which for a variety of reasons run over TCP, may also be considered part of the application or network layer.
3. Transport TCP, UDP, DCCP, SCTP, IL, RUDP, …
2. Internet Routing protocols like OSPF, which run over IP, are also to be considered part of the network layer, as they provide path selection. ICMP and IGMP run over IP and are considered part of the network layer, as they provide control information.
IP (IPv4, IPv6)
ARP and RARP operate underneath IP but above the link layer so they belong somewhere in between.
1. Network access Ethernet, Wi-Fi, token ring, PPP, SLIP, FDDI, ATM, Frame Relay, SMDS, …

OSI

OSI Model

Data unit Layer Function
Host
layers
Data 7. Application Network process to application
6. Presentation Data representation and encryption
5. Session Interhost communication
Segments 4. Transport End-to-end connections and reliability (TCP)
Media
layers
Packets 3. Network Path determination and logical addressing (IP)
Frames 2. Data link Physical addressing (MAC & LLC)
Bits 1. Physical Media, signal and binary transmission

TCP/IP & Internet

1969 ARPA (Advanced Research Projects Agency) funded a research and development project to create ARPAnet network.
1975 Converted from an experimental network to an operational network.
1983 TCP/IP protocols were adopted as Military Standards (MIL STD)
Internet: MILNET plus ARPAnet

Sep 18, 2007

Convert string to html table

#!/bin/sh
sed -e '/^[A-Za-z0-9]*[^\:]$/{
d
}' < source_file > tmp_file
echo "<table>" > destination_file.html
sed -e '/:/{
s/^/<tr><td>/g
s/\:/<\/td><td>/g
s/$/<\/td><\/tr>/g
}' < tmp_file >> destination_file.html
echo "</table>" >> destination_file.html

Sep 14, 2007

Replace file contents by perl

#!/usr/bin/perl -w
# use strict;

sub replace_str($$$)
{
my $line = shift;
my $old_string = shift;
my $new_string = shift;

if($line =~ m/($old_string)/)
{
$line =~ s/$old_string/$new_string/;
}
return $line;
}

open (SOURCE_FILE, "source.txt");
open (DESTINATION_FILE, '>>destination.txt');

while ($line = <source_file>) {
$line = replace_str($line,"2","3");
print DESTINATION_FILE $line;
}

close(SOURCE_FILE);
close (DESTINATION_FILE);

SED notes

Replace in sed
sed -e '/pattern/{
s/old1/new1/g
s/old2/new2/g
}' < source_file > destination_file