CSS434 Networking
This presentation is the property of its rightful owner.
Sponsored Links
1 / 15

CSS434 Networking Textbook Ch3 PowerPoint PPT Presentation


  • 132 Views
  • Uploaded on
  • Presentation posted in: General

CSS434 Networking Textbook Ch3. Professor: Munehiro Fukuda. Outline. OSI 7 layers Physical/data link layers (layer 1 & 2) Network layer – IP (layer 3) Transport layer – TCP UDP (layer 4) Application layer – RSH (layer 7) Socket examples. OSI 7 Layers. Site A. Site B.

Download Presentation

CSS434 Networking Textbook Ch3

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Css434 networking

CSS434 Networking

Textbook Ch3

Professor: Munehiro Fukuda

CSS434 Networking


Outline

Outline

  • OSI 7 layers

  • Physical/data link layers (layer 1 & 2)

  • Network layer – IP (layer 3)

  • Transport layer – TCP UDP (layer 4)

  • Application layer – RSH (layer 7)

  • Socket examples

CSS434 Networking


Osi 7 layers

OSI 7 Layers

Site

A

Site

B

Application protocol

7

Application

rsh, ftp, Telnet

Application

Presentation protocol

Presentation

6

Dealing with heterogeneity

And cryptography

Presentation

Session protocol

5

Session

Dialog control

(rarely supported)

Session

Transport protocol

Transport

4

UDP, TCP

Transport

Network protocol

Network

Network

3

IP

Data link protocol

IEEE802.2

connection or connectionless

Data link

Data link

2

Ethernet

Physical protocol

Physical

1

Physical

Network

CSS434 Networking


Osi protocol summary

Layer

Description

Examples

Application

Protocols that are designed to meet the communication requirements of

FTP

HTTP,

,

SMTP,

specific applications, often defining the interface to a service.

CORBA IIOP

Presentation

Protocols at this level transmit data in a network representation that is

Secure Sockets

independent of the representations used in individual computers, which may

(

SSL),CORBA Data

differ. Encryption is also performed in this layer, if required.

Rep.

Session

At this level reliability and adaptation are performed, such as detection of

failures and automatic recovery.

Transport

This is the lowest level at which messages (rather than packets) are handled.

TCP,

UDP

Messages are addressed to communication ports attached to processes,

Protocols in this layer may be connection-oriented or connectionless.

Network

Transfers data packets between computers in a specific network. In a WAN

IP,

ATM virtual

or an internetwork this involves the generation of a route passing through

circuits

routers. In a single LAN no routing is required.

Data link

Responsible for transmission of packets between nodes that are directly

Ethernet MAC,

connected by a physical link. In a WAN transmission is between pairs of

ATM cell transfer,

routers or between routers and hosts. In a LAN it is between any pair of hosts.

PPP

Physical

The circuits and hardware that drive the network. It transmits sequences of

Ethernet base- band

binary data by analogue signalling, using amplitude or frequency modulation

signalling,

ISDN

of electrical signals (on cable circuits), light signals (on fibre optic circuits)

or other electromagnetic signals (on radio and microwave circuits).

OSI Protocol Summary

CSS434 Networking


Physical data link layer example csma cd and token ring

Physical/Data Link LayerExample: CSMA/CD and Token Ring

  • IEEE802.3: CSMA/CD (Carrier sense multiple access with collision detection)

    • Listening to the shared medium

    • Transmitting a data packet

    • Detecting collision on the medium

    • Deferring and retransmitting a packet in 2k–time base collision window

  • IEEE802.5: Token Ring

    • Receiving a free token from my (left) neighbor

    • Attaching a data packet to the token

    • Forwarding the token to my (right) neighbor

    • Detaching a packet from the token if it is addressed here

1 listen

3. detect

2 transmit

1. Free token

2. Attach

4. Detach

3. busy token

CSS434 Networking


Network layer example ip

Class A

Octet 2 – 4

(1,677,716)

Octet 1

0-127

0

Net #

Host #

Net #

Host #

1

0

S

S

D

D

L

L

1

1

0

Net #

Host#

Class B

IP packet ID and size

IP packet ID and size

Destination IP address

Destination IP address

Octet 1

128-191

Octet 3 – 4

(65,536)

Octet 2

Source IP address

Source IP address

Class C

Octet 4

(256)

Octet 1

128-191

Octet 2 – 3

Network LayerExample: IP

Transportation layer

Datagram

fragmentation

reassembly

Data link layer

Best-effort deliver semantics

Class D: for broadcasting

CSS434 Networking


Transport layer example1 udp

Transport Layer:Example1: UDP

  • User Datagram Protocol

    • Connectionless

    • May be lost

    • No FIFO order

    • Multicast feature

    • Unix datagram

    • Example: TFTP, rwho

client

server

socket()

socket()

Create a sock descriptor

bind()

bind()

Bind it to an IP address

recvfrom()

sendto()

Blocks until data received

sendto()

recvfrom()

CSS434 Networking


Transport layer example2 tcp

Transport Layer:Example2: TCP

client

server

  • Transport Control Protocol

    • Connection-oriented

    • Reliable

    • FIFO order

    • No Multicast feature

    • Unix stream socket

    • Example: ftp, http, rsh all major applications

socket()

socket()

Create a sock descriptor

bind()

Bind it to an IP address

liseten()

Declare this is connection-oriented

accept()

Wait for a connection

Connection established

connect()

Blocks until connection established

read()

write()

read()

wrte()

CSS434 Networking


Application layer example rsh

Application LayerExample: RSH

Client

Server

inetd

shell

TCP connection

request

Command

rsh ls- l

rshd

shell

TCP connection

Inherited all the way

To a child

Command

ls -l

CSS434 Networking


Summary of tcp ip layers

Message

Layers

Application

Messages (UDP) or Streams (TCP)

Transport

UDP or TCP packets

Internet

IP datagrams

Network interface

Network-specific frames

Underlying network

Summary of TCP/IP Layers

CSS434 Networking


Socket programming socket h

Socket Programming: Socket.h

#include <iostream>

extern "C"

{

#include <sys/types.h> // for sockets

#include <sys/socket.h>

#include <netinet/in.h>

#include <arpa/inet.h>

#include <netdb.h> // for gethostbyname( )

#include <unistd.h> // for close( )

#include <string.h> // for bzero( )

}

#define NULL_FD -1

#define MAXSIZE 20

class Socket {

public:

Socket( int );

~Socket( );

int getClientSocket( char[] );

int getServerSocket( );

private:

int port;

int clientFd;

int serverFd;

};

CSS434 Networking


Socket programming socket cpp client

Socket Programming: Socket.cpp (Client)

// Fill in the structure "sendSockAddr" with the server address.

sockaddr_in sendSockAddr;

bzero( (char*)&sendSockAddr, sizeof( sendSockAddr ) );

sendSockAddr.sin_family = AF_INET; //Address Family Internet

sendSockAddr.sin_addr.s_addr =

inet_addr( inet_ntoa( *(struct in_addr*)*host->h_addr_list ) );

sendSockAddr.sin_port = htons( port );

// Open a TCP socket (an Internet strem socket).

if( ( clientFd = socket( AF_INET, SOCK_STREAM, 0 ) ) < 0 ) {

cerr << "Cannot open a client TCP socket." << endl;

return NULL_FD;

}

// Connect to the server.

while ( connect( clientFd, (sockaddr*)&sendSockAddr,

sizeof( sendSockAddr ) ) < 0 );

// Connected

return clientFd;

}

#include "Socket.h"

Socket::Socket( int port )

: port( port ), clientFd( NULL_FD ),

serverFd( NULL_FD ) {

}

Socket::~Socket( ) {

if ( clientFd != NULL_FD )

close( clientFd );

if ( serverFd != NULL_FD )

close( serverFd );

}

int Socket::getClientSocket( char ipName[] ) {

// Get the host entry corresponding to ipName

struct hostent* host = gethostbyname( ipName );

if( host == NULL ) {

cerr << "Cannot find hostname." << endl;

return NULL_FD;

}

CSS434 Networking


Socket programming socket cpp server

Socket Programming: Socket.cpp (Server)

int Socket::getServerSocket( ) {

if ( serverFd == NULL_FD ) { // Server not ready

sockaddr_in acceptSockAddr;

// Open a TCP socket (an internet stream socket).

if( ( serverFd = socket( AF_INET, SOCK_STREAM, 0 ) ) < 0 ) {

cerr << "Cannot open a server TCP socket." << endl;

return NULL_FD;

}

// Bind our local address so that the client can send to us

bzero( (char*)&acceptSockAddr, sizeof( acceptSockAddr ) );

acceptSockAddr.sin_family = AF_INET; // Address Family Internet

acceptSockAddr.sin_addr.s_addr = htonl( INADDR_ANY );

acceptSockAddr.sin_port = htons( port );

if( bind( serverFd, (sockaddr*)&acceptSockAddr,

sizeof( acceptSockAddr ) ) < 0 ) {

cerr << "Cannot bind the local address to the server socket." << endl;

return NULL_FD;

}

listen( serverFd, 5 );

}

// Read to accept new requests

int newFd = NULL_FD;

sockaddr_in newSockAddr;

socklen_t newSockAddrSize = sizeof( newSockAddr );

if( ( newFd =

accept( serverFd, (sockaddr*)&newSockAddr, &newSockAddrSize ) ) < 0 ) {

cerr << "Cannot accept from another host." << endl;

return NULL_FD;

}

return newFd;

}

CSS434 Networking


Socket programming main

Socket Programming: Main

#include "Socket.h"

#define PORT 10000 // You are given a specific pot from the instructor

int main( int argc, char *argv[] ) {

Socket sock( PORT );

int fd;

if ( argc == 1 ) { // I'm a server

while ( true ) {

if ( ( fd = sock.getServerSocket( ) ) == NULL_FD )

return -1;

char recvMessage[MAXSIZE];

read( fd, recvMessage, MAXSIZE );

cout << recvMessage << endl;

close( fd );

}

}

if ( argc == 2 ) { // I'm a client

if ( ( fd = sock.getClientSocket( argv[1] ) ) == NULL_FD )

return -1;

char sendMessage[MAXSIZE];

cin >> sendMessage;

write( fd, sendMessage, MAXSIZE );

}

return 0;

}

CSS434 Networking


Exercises no turn in

Exercises (No turn-in)

  • Why do we need layered network protocols?

  • When implementing TCP with datagram, what do we have to take care of?

  • Compare UDP and TCP for the implementation of each of the following application-level or presentation-level protocols (textbook p142, Q3.7):

    • Telnet

    • FTP

    • Rwho, finger

    • HTTP

    • RPC or RMI

CSS434 Networking


  • Login