Professional Documents
Culture Documents
UDP:
Stateless transmission
High speed
SOCKETS
Definition: A socket is a software construction
representing a single connection between two
networking applications.
BSD SOCKETS
•struct sock *sk
•struct proto_ops *ops
INET SOCKETS
•struct sk_buff_head (receive/write)_queue
•__u32 saddr
•struct proto *prot
Establishing
Connections
Server =
gethostbyname(SERVER_NAME)
sockfd =
socket(AF_INET,SOCK_STREAM, 0);
connect(sockfd,
&address,sizeof(address));
Socket Call Walk-
Through
Check for errors in call
Create (allocate memory for) socket object
Put socket into INODE list
Establish pointers to protocol functions (INET)
Store values for socket type and protocol
family
Set socket state to closed
Initialize packet queues
Connect Call Walk-
Through
Check for errors
Determine route to destination:
Store pointer to routing entry in socket
Call protocol specific connection function
(e.g., send a TCP connection packet)
Set socket state to established
Close Walk-Through
2. Frame transmits
in both directions
3. Every NIC
receives the
frame; do MAC
address matching
4. Intended NIC
picks up the
frame; rest drop it
CSMA/CD Algorithm
Sense for carrier.
If carrier present, wait until carrier
ends.
– Sending would force a collision and waste
time
Send packet and sense for collision.
If no collision detected, consider
packet delivered.
CSMA/CD Algorithm
Otherwise if collision detected
Send Jam Signal
Abort immediately
Perform “exponential back off” and send
packet again.
– Start to send at a random time picked from an
interval
– Length of the interval increases with every
retransmission
Collision Detection
A B C
Time
Collision Detection:
ImplicationsA B C
All nodes must be able to
detect the collision.
– Any node can be sender
The implication is that either
we must have a short wires,
or long packets.
– Or a combination of both
Can calculate length/distance
based on transmission rate
and propagation speed.
– Minimum packet size is 64 bytes
Cable length ~256 bit times
– Example: maximum coax cable
length is 2.5 km
CSMA/CD: Some
Details
When a sender detects a collision, it
sends a “jam signal”.
– Make sure that all nodes are aware of the
collision
– Length of the jam signal is 32 bit times
Exponential backoff operates in
multiples of 512 bit times.
– Longer than a roundtrip time
– Guarantees that nodes that back off longer
will notice the earlier retransmission before
starting to send
Ethernet Frame
Format
8 6 6 2 4